-
-
Notifications
You must be signed in to change notification settings - Fork 2
86 lines (77 loc) · 3.06 KB
/
knip.yml
File metadata and controls
86 lines (77 loc) · 3.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
name: Knip Dead Code Check
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
permissions:
contents: read
jobs:
knip:
name: Run Knip
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
egress-policy: block
allowed-endpoints: >
api.github.com:443
codeload.github.com:443
github.com:443
nodejs.org:443
objects.githubusercontent.com:443
registry.npmjs.org:443
- name: Checkout repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- name: Setup Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: '26'
cache: 'npm'
cache-dependency-path: |
package-lock.json
.github/workflows/knip.yml
- name: Install dependencies
run: npm ci
- name: Run Knip (blocking — files, dependencies, duplicates)
# Blocks the workflow on actionable findings: unused files, unused/unlisted/
# unresolved dependencies, unused binaries, and duplicate exports. Unused
# exports/types are intentionally informational only (see next step) — most
# are barrel re-exports that form the public API of internal libraries.
run: |
echo "🔍 Running Knip dead-code detector (blocking subset)..."
echo ""
if npx knip --no-progress --include files,dependencies,unlisted,binaries,unresolved,duplicates > knip-blocking.txt 2>&1; then
echo "✅ No actionable dead-code findings."
cat knip-blocking.txt
else
echo "❌ Knip found actionable issues:"
cat knip-blocking.txt
echo ""
echo "Triage options for each finding:"
echo " a) Used but not detected → update knip.json (entry/ignoreDependencies)."
echo " b) Should be used but isn't → wire it up in the consumer."
echo " c) Truly unused → delete the file/dep/binary."
exit 1
fi
- name: Run Knip (informational — exports & types)
# Non-blocking: surfaces unused exports/types so reviewers can spot drift
# without forcing every barrel re-export to be hand-pruned. Failures here
# do NOT fail the workflow.
if: always()
continue-on-error: true
run: |
echo "🔎 Running Knip (informational — unused exports / types)..."
echo ""
npx knip --no-progress --include exports,nsExports,types,nsTypes,enumMembers > knip-informational.txt 2>&1 || true
cat knip-informational.txt
- name: Upload Knip Report
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: knip-report
path: |
knip-blocking.txt
knip-informational.txt
retention-days: 30