Skip to content

Commit 2f98a40

Browse files
ci: bump checkout v4->v6, add CLI tests to CI, add GitHub Action for health scanning
- Updated all 3 workflows to actions/checkout@v6 - Added test-cli job to validate.yml (npm test + --version check) - Created cli/action.yml for GitHub Marketplace: inputs: path, threshold, include-dev, github-token outputs: results (JSON), average-score, critical-count Features: CI annotations, threshold-based failure
1 parent 20eb4f0 commit 2f98a40

File tree

4 files changed

+106
-3
lines changed

4 files changed

+106
-3
lines changed

.github/workflows/evidence-daily.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515

1616
steps:
1717
- name: Checkout
18-
uses: actions/checkout@v4
18+
uses: actions/checkout@v6
1919

2020
- name: Setup Git Identity
2121
run: |

.github/workflows/publish-cli.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717

1818
steps:
1919
- name: Checkout
20-
uses: actions/checkout@v4
20+
uses: actions/checkout@v6
2121

2222
- name: Setup Node.js
2323
uses: actions/setup-node@v4

.github/workflows/validate.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,29 @@ jobs:
1212

1313
steps:
1414
- name: Checkout
15-
uses: actions/checkout@v4
15+
uses: actions/checkout@v6
1616

1717
- name: Validate configuration and scripts
1818
shell: pwsh
1919
run: |
2020
./scripts/validate-repo.ps1
21+
22+
test-cli:
23+
runs-on: ubuntu-latest
24+
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v6
28+
29+
- name: Setup Node.js
30+
uses: actions/setup-node@v4
31+
with:
32+
node-version: '20'
33+
34+
- name: Run CLI unit tests
35+
working-directory: cli
36+
run: npm test
37+
38+
- name: Verify CLI runs
39+
working-directory: cli
40+
run: node bin/scan.js --version

cli/action.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: "OSS Health Scan"
2+
description: "Scan your dependencies for abandoned, unmaintained, or unhealthy npm packages. Get health scores (0-100) for every dependency."
3+
author: "dusan-maintains"
4+
5+
branding:
6+
icon: "shield"
7+
color: "blue"
8+
9+
inputs:
10+
path:
11+
description: "Path to directory containing package.json (default: repo root)"
12+
required: false
13+
default: "."
14+
threshold:
15+
description: "Fail if any package scores below this threshold (0-100)"
16+
required: false
17+
default: "0"
18+
include-dev:
19+
description: "Include devDependencies in scan"
20+
required: false
21+
default: "false"
22+
github-token:
23+
description: "GitHub token for higher API rate limits (recommended)"
24+
required: false
25+
default: ${{ github.token }}
26+
27+
outputs:
28+
results:
29+
description: "JSON scan results"
30+
value: ${{ steps.scan.outputs.results }}
31+
average-score:
32+
description: "Average health score across all dependencies"
33+
value: ${{ steps.scan.outputs.average }}
34+
critical-count:
35+
description: "Number of packages with critical health scores"
36+
value: ${{ steps.scan.outputs.critical }}
37+
38+
runs:
39+
using: "composite"
40+
steps:
41+
- name: Setup Node.js
42+
uses: actions/setup-node@v4
43+
with:
44+
node-version: '20'
45+
46+
- name: Install oss-health-scan
47+
shell: bash
48+
run: npm install -g oss-health-scan@latest
49+
50+
- name: Run health scan
51+
id: scan
52+
shell: bash
53+
env:
54+
GITHUB_TOKEN: ${{ inputs.github-token }}
55+
run: |
56+
FLAGS=""
57+
if [ "${{ inputs.include-dev }}" = "true" ]; then
58+
FLAGS="$FLAGS --dev"
59+
fi
60+
if [ "${{ inputs.threshold }}" != "0" ]; then
61+
FLAGS="$FLAGS --threshold ${{ inputs.threshold }}"
62+
fi
63+
64+
# Run JSON scan for outputs
65+
RESULTS=$(oss-health-scan ${{ inputs.path }} --json $FLAGS 2>/dev/null || true)
66+
echo "results<<EOF" >> $GITHUB_OUTPUT
67+
echo "$RESULTS" >> $GITHUB_OUTPUT
68+
echo "EOF" >> $GITHUB_OUTPUT
69+
70+
# Extract stats
71+
AVG=$(echo "$RESULTS" | node -e "const d=require('fs').readFileSync(0,'utf8');try{const j=JSON.parse(d);const s=j.results.filter(r=>r.health_score!=null);console.log((s.reduce((a,r)=>a+r.health_score,0)/s.length).toFixed(1))}catch{console.log('N/A')}")
72+
CRIT=$(echo "$RESULTS" | node -e "const d=require('fs').readFileSync(0,'utf8');try{const j=JSON.parse(d);console.log(j.results.filter(r=>r.risk_level==='critical').length)}catch{console.log(0)}")
73+
echo "average=$AVG" >> $GITHUB_OUTPUT
74+
echo "critical=$CRIT" >> $GITHUB_OUTPUT
75+
76+
# Print human-readable report
77+
oss-health-scan ${{ inputs.path }} $FLAGS --ci || true
78+
79+
# Fail if critical packages found and threshold > 0
80+
if [ "${{ inputs.threshold }}" != "0" ] && [ "$CRIT" -gt 0 ]; then
81+
echo "::error::$CRIT package(s) scored below threshold ${{ inputs.threshold }}"
82+
exit 1
83+
fi

0 commit comments

Comments
 (0)