Skip to content

Commit

Permalink
Merge pull request #238 from ytetsuro/develop
Browse files Browse the repository at this point in the history
chore: for fail npx.
  • Loading branch information
ytetsuro authored May 16, 2022
2 parents 84c0604 + 1954e7d commit f8ec1d2
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 71 deletions.
81 changes: 81 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Build
on:
push:
branches:
- master
workflow_dispatch:
jobs:
generateBadge:
name: GenerateBadge
runs-on: ubuntu-latest
strategy:
matrix:
node-version: ['16.x']
fail-fast: false
steps:
- uses: actions/checkout@v1
- name: Setting up Node.js (v${{ matrix.node-version }}.x)
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Get Coverage for badge
run: |
SUMMARY="$(npm test -- --silent --coverage --coverageReporters='text-summary' | tail -4 | head -1)"
TOKENS=($SUMMARY)
echo "COVERAGE=$(echo ${TOKENS[2]})" >> $GITHUB_ENV
echo "COVERAGE_COLOR=$(([[ ${TOKENS[2]%%.*} -ge 80 ]] && echo "green") || ([[ ${TOKENS[2]%%.*} -ge 50 ]] && echo "yellow") || echo "red")" >> $GITHUB_ENV
SUMMARY=$(npx sabik ./src -t JSON | jq -r '.summaries | (."LogicalLineOfCode(Average per method)".value|tostring) + " " + (."CognitiveComplexity(Max)".value|tostring) + " " + (."Maintainability(Min)".value|tostring)')
TOKENS=($SUMMARY)
echo "LINE_OF_CODE=$(printf "%.2f\n" ${TOKENS[0]})" >> $GITHUB_ENV
echo "LINE_OF_CODE_COLOR=$(([[ ${TOKENS[0]%%.*} -le 15 ]] && echo "green") || ([[ ${TOKENS[0]%%.*} -le 20 ]] && echo "yellow") || echo "red")" >> $GITHUB_ENV
echo "COGNITIVE_COMPLEXITY=$(printf "%.2f\n" ${TOKENS[1]})" >> $GITHUB_ENV
echo "COGNITIVE_COMPLEXITY_COLOR=$(([[ ${TOKENS[1]%%.*} -le 8 ]] && echo "green") || echo "red")" >> $GITHUB_ENV
echo "MAINTAINABILITY=$(printf "%.2f\n" ${TOKENS[2]})" >> $GITHUB_ENV
echo "MAINTAINABILITY_COLOR=$(([[ ${TOKENS[2]%%.*} -ge 80 ]] && echo "green") || ([[ ${TOKENS[2]%%.*} -ge 50 ]] && echo "yellow") || echo "red")" >> $GITHUB_ENV
REF=${{ github.ref }}
echo "github.ref: $REF"
IFS='/' read -ra PATHS <<< "$REF"
BRANCH_NAME="${PATHS[1]}_${PATHS[2]}"
echo $BRANCH_NAME
echo "BRANCH=$(echo ${BRANCH_NAME})" >> $GITHUB_ENV
- name: Create the Coverage Badge
uses: schneegans/[email protected]
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: 32248b8c823155bb09711c7a5b960d3d
filename: sabik_coverage_${{ env.BRANCH }}.json
label: Test Coverage
message: ${{ env.COVERAGE }}
color: ${{ env.COVERAGE_COLOR }}
namedLogo: jest

- name: Create the LineOfCode Badge
uses: schneegans/[email protected]
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: 32248b8c823155bb09711c7a5b960d3d
filename: sabik_line_of_code_${{ env.BRANCH }}.json
label: LogicalLineOfCode(Average per method)
message: ${{ env.LINE_OF_CODE }}
color: ${{ env.LINE_OF_CODE_COLOR }}

- name: Create the CognitiveComplexity Badge
uses: schneegans/[email protected]
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: 32248b8c823155bb09711c7a5b960d3d
filename: sabik_cognitive_complexity_${{ env.BRANCH }}.json
label: CognitiveComplexity(Max)
message: ${{ env.COGNITIVE_COMPLEXITY }}
color: ${{ env.COGNITIVE_COMPLEXITY_COLOR }}

- name: Create the Maintainability Badge
uses: schneegans/[email protected]
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: 32248b8c823155bb09711c7a5b960d3d
filename: sabik_maintainability_${{ env.BRANCH }}.json
label: Maintainability(Min)
message: ${{ env.MAINTAINABILITY }}
color: ${{ env.MAINTAINABILITY_COLOR }}
10 changes: 5 additions & 5 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: Publish
on:
push:
branches:
- master
workflow_dispatch:
workflow_run:
workflows: [Build]
types:
- completed
jobs:
deploy:
name: Build
name: Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down
66 changes: 0 additions & 66 deletions .github/workflows/review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,72 +29,6 @@ jobs:
node-version: ${{ matrix.node-version }}
- run: npm ci --ignore-scripts
- run: npm run test
- if: ${{ matrix.node-version == '18.x' }}
name: Get Coverage for badge
run: |
SUMMARY="$(npm test -- --silent --coverage --coverageReporters='text-summary' | tail -4 | head -1)"
TOKENS=($SUMMARY)
echo "COVERAGE=$(echo ${TOKENS[2]})" >> $GITHUB_ENV
echo "COVERAGE_COLOR=$(([[ ${TOKENS[2]%%.*} -ge 80 ]] && echo "green") || ([[ ${TOKENS[2]%%.*} -ge 50 ]] && echo "yellow") || echo "red")" >> $GITHUB_ENV
SUMMARY=$(npx sabik ./src -t JSON | jq -r '.summaries | (."LogicalLineOfCode(Average per method)".value|tostring) + " " + (."CognitiveComplexity(Max)".value|tostring) + " " + (."Maintainability(Min)".value|tostring)')
TOKENS=($SUMMARY)
echo "LINE_OF_CODE=$(printf "%.2f\n" ${TOKENS[0]})" >> $GITHUB_ENV
echo "LINE_OF_CODE_COLOR=$(([[ ${TOKENS[0]%%.*} -le 15 ]] && echo "green") || ([[ ${TOKENS[0]%%.*} -le 20 ]] && echo "yellow") || echo "red")" >> $GITHUB_ENV
echo "COGNITIVE_COMPLEXITY=$(printf "%.2f\n" ${TOKENS[1]})" >> $GITHUB_ENV
echo "COGNITIVE_COMPLEXITY_COLOR=$(([[ ${TOKENS[1]%%.*} -le 8 ]] && echo "green") || echo "red")" >> $GITHUB_ENV
echo "MAINTAINABILITY=$(printf "%.2f\n" ${TOKENS[2]})" >> $GITHUB_ENV
echo "MAINTAINABILITY_COLOR=$(([[ ${TOKENS[2]%%.*} -ge 80 ]] && echo "green") || ([[ ${TOKENS[2]%%.*} -ge 50 ]] && echo "yellow") || echo "red")" >> $GITHUB_ENV
REF=${{ github.ref }}
echo "github.ref: $REF"
IFS='/' read -ra PATHS <<< "$REF"
BRANCH_NAME="${PATHS[1]}_${PATHS[2]}"
echo $BRANCH_NAME
echo "BRANCH=$(echo ${BRANCH_NAME})" >> $GITHUB_ENV
- if: ${{ matrix.node-version == '18.x' }}
name: Create the Coverage Badge
uses: schneegans/[email protected]
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: 32248b8c823155bb09711c7a5b960d3d
filename: sabik_coverage_${{ env.BRANCH }}.json
label: Test Coverage
message: ${{ env.COVERAGE }}
color: ${{ env.COVERAGE_COLOR }}
namedLogo: jest

- if: ${{ matrix.node-version == '18.x' }}
name: Create the LineOfCode Badge
uses: schneegans/[email protected]
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: 32248b8c823155bb09711c7a5b960d3d
filename: sabik_line_of_code_${{ env.BRANCH }}.json
label: LogicalLineOfCode(Average per method)
message: ${{ env.LINE_OF_CODE }}
color: ${{ env.LINE_OF_CODE_COLOR }}

- if: ${{ matrix.node-version == '18.x' }}
name: Create the CognitiveComplexity Badge
uses: schneegans/[email protected]
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: 32248b8c823155bb09711c7a5b960d3d
filename: sabik_cognitive_complexity_${{ env.BRANCH }}.json
label: CognitiveComplexity(Max)
message: ${{ env.COGNITIVE_COMPLEXITY }}
color: ${{ env.COGNITIVE_COMPLEXITY_COLOR }}

- if: ${{ matrix.node-version == '18.x' }}
name: Create the Maintainability Badge
uses: schneegans/[email protected]
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: 32248b8c823155bb09711c7a5b960d3d
filename: sabik_maintainability_${{ env.BRANCH }}.json
label: Maintainability(Min)
message: ${{ env.MAINTAINABILITY }}
color: ${{ env.MAINTAINABILITY_COLOR }}

build:
name: Build
Expand Down

0 comments on commit f8ec1d2

Please sign in to comment.