Skip to content

Commit 5657f62

Browse files
committed
add lint and format checks
1 parent d10f071 commit 5657f62

1 file changed

Lines changed: 41 additions & 5 deletions

File tree

.github/workflows/run_npm_ci_scripts.yml

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,19 +66,51 @@ jobs:
6666
echo "build_status=failed" >> $GITHUB_OUTPUT
6767
fi
6868
69+
- name: Lint
70+
id: lint
71+
continue-on-error: true
72+
run: |
73+
if ! [ -f package.json ] || ! jq -e '.scripts.lint:check' package.json > /dev/null; then
74+
echo "No lint script found in package.json."
75+
echo "lint_status=notpresent" >> $GITHUB_OUTPUT
76+
exit 0
77+
fi
78+
if npm run lint:check; then
79+
echo "lint_status=passed" >> $GITHUB_OUTPUT
80+
else
81+
echo "lint_status=failed" >> $GITHUB_OUTPUT
82+
fi
83+
84+
- name: Format
85+
id: format
86+
continue-on-error: true
87+
run: |
88+
if ! [ -f package.json ] || ! jq -e '.scripts.format:check' package.json > /dev/null; then
89+
echo "No format script found in package.json."
90+
echo "format_status=notpresent" >> $GITHUB_OUTPUT
91+
exit 0
92+
fi
93+
if npm run format:check; then
94+
echo "format_status=passed" >> $GITHUB_OUTPUT
95+
else
96+
echo "format_status=failed" >> $GITHUB_OUTPUT
97+
fi
98+
6999
- name: Job Summary
70100
if: always()
71101
env:
72102
AUDIT_STATUS: ${{ steps.audit-npm.outputs.gate_passed == 'true' && 'success' || 'failure' }}
73103
AUDIT_SUMMARY: ${{ steps.audit-npm.outputs.gate_summary }}
74104
BUILD_STATUS: ${{ steps.build.outputs.build_status || steps.build.outcome }}
105+
LINT_STATUS: ${{ steps.lint.outputs.lint_status || steps.lint.outcome }}
106+
FORMAT_STATUS: ${{ steps.format.outputs.format_status || steps.format.outcome }}
75107
run: |
76108
status_emoji () {
77109
case "$1" in
78110
success) echo "✅";;
79111
failure) echo "❌";;
80112
cancelled) echo "➖";;
81-
skipped|"") echo "⏩";;
113+
skipped|""|notpresent) echo "⏩";;
82114
*) echo "❓";;
83115
esac
84116
}
@@ -89,21 +121,25 @@ jobs:
89121
echo "Run: [#${{ github.run_number }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})"
90122
echo ""
91123
echo ""
92-
echo "| Audit | Build |"
93-
echo "|:-----:|:-----:|"
94-
echo "| $(status_emoji "$AUDIT_STATUS") "$AUDIT_STATUS" | $(status_emoji "$BUILD_STATUS") "$BUILD_STATUS" |"
124+
echo "| Audit | Build | Lint | Format |"
125+
echo "|:-----:|:-----:|:----:|:------:|"
126+
echo "| $(status_emoji "$AUDIT_STATUS") "$AUDIT_STATUS" | $(status_emoji "$BUILD_STATUS") "$BUILD_STATUS" | $(status_emoji "$LINT_STATUS") "$LINT_STATUS" | $(status_emoji "$FORMAT_STATUS") "$FORMAT_STATUS" |"
95127
echo ""
96128
echo "$AUDIT_SUMMARY"
97129
} > job-summary.md
98130
cat job-summary.md >> "$GITHUB_STEP_SUMMARY"
99131
100132
- name: Set Run Outcome
101-
if: ${{ steps.audit-npm.outputs.gate_passed == 'false' || steps.build.outputs.build_status == 'failure' }}
133+
if: ${{ steps.audit-npm.outputs.gate_passed == 'false' || steps.build.outputs.build_status == 'failure' || steps.lint.outputs.lint_status == 'failure' || steps.format.outputs.format_status == 'failure' }}
102134
env:
103135
AUDIT_STATUS: ${{ steps.audit-npm.outputs.gate_passed == 'true' && 'passed' || 'failed' }}
104136
BUILD_STATUS: ${{ steps.build.outputs.build_status }}
137+
LINT_STATUS: ${{ steps.lint.outputs.lint_status }}
138+
FORMAT_STATUS: ${{ steps.format.outputs.format_status }}
105139
run: |
106140
echo "❌ One or more gate steps failed:"
107141
echo " Audit Gate: $AUDIT_STATUS"
108142
echo " Build: $BUILD_STATUS"
143+
echo " Lint: $LINT_STATUS"
144+
echo " Format: $FORMAT_STATUS"
109145
exit 1

0 commit comments

Comments
 (0)