forked from webpro-nl/knip
-
Notifications
You must be signed in to change notification settings - Fork 0
274 lines (239 loc) · 9.31 KB
/
Copy pathintegration.yml
File metadata and controls
274 lines (239 loc) · 9.31 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
name: Publish preview & run ecosystem tests
on:
workflow_dispatch:
inputs:
update_snapshots:
description: Regenerate ecosystem snapshots and upload as artifact
type: boolean
default: false
pull_request:
push:
branches:
- '**'
# Automatically cancel in-progress actions on the same branch
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions: {}
jobs:
publish:
name: Build and publish Knip
runs-on: ubuntu-latest
permissions:
contents: read # checkout repository
issues: write # comment on referenced issues
outputs:
sha: ${{ steps.publish.outputs.sha }}
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
with:
persist-credentials: false
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
with:
node-version: 24
- uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5
- run: pnpm install --frozen-lockfile
working-directory: packages/knip
- run: pnpm run build
working-directory: packages/knip
- id: publish
run: |
pnpx pkg-pr-new publish --compact './packages/knip' './packages/language-server' './packages/mcp-server'
- name: Comment on referenced issues
if: github.event_name == 'push'
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
env:
PUBLISH_SHA: ${{ steps.publish.outputs.sha }}
with:
script: |
const sha = process.env.PUBLISH_SHA;
const commits = context.payload.commits || [];
const messages = commits.map(commit => commit.message).join('\n');
const issueRefs = messages.match(/#(\d+)/g) || [];
const issues = new Set(issueRefs.map(ref => parseInt(ref.slice(1))));
const isClosingMatch = /(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?)\s+#(\d+)/gi;
const closingIssues = new Set([...messages.matchAll(isClosingMatch)].map(m => parseInt(m[1])));
for (const issue_number of issues) {
try {
const { owner, repo } = context.repo;
const { data } = await github.rest.issues.get({ owner, repo, issue_number });
if (data.state === 'open' || closingIssues.has(issue_number)) {
const body = `Preview release available:\n\`\`\`sh\nnpm i -D https://pkg.pr.new/knip@${sha}\n\`\`\``;
await github.rest.issues.createComment({ owner, repo, issue_number, body });
}
} catch(error) {
console.log(`Could not comment on #${issue_number}: ${error.message}`);}
}
integration:
name: Run Knip in ${{ matrix.project.name }}
needs: publish
runs-on: ubuntu-latest
permissions:
contents: read # checkout repository
env:
PKG_URL: https://pkg.pr.new/knip@${{ needs.publish.outputs.sha }}
SNAP: ${{ github.workspace }}/.github/workflows/scripts/snap.sh
UPDATE_SNAPSHOTS: ${{ inputs.update_snapshots && '1' || '' }}
SNAPSHOT_OUT_DIR: /tmp/snapshot-updates
PNPM_CONFIG_MINIMUM_RELEASE_AGE: '0'
PNPM_CONFIG_TRUST_POLICY: 'off'
PNPM_CONFIG_VERIFY_DEPS_BEFORE_RUN: 'false'
strategy:
fail-fast: false
matrix:
project:
- name: 10ten-ja-reader
repo: birchill/10ten-ja-reader
commands: |
pnpm install
bash $SNAP 10ten-ja-reader -- pnpm dlx $PKG_URL
- name: argos
repo: argos-ci/argos
commands: |
pnpm install
pnpm build
pnpm add -D -w $PKG_URL
bash $SNAP argos -- pnpm run knip
- name: astro
repo: withastro/astro
commands: |
pnpm install
pnpm add -D -w $PKG_URL
bash $SNAP astro -- pnpm knip --fix --exclude unresolved
- name: create-typescript-app
repo: JoshuaKGoldberg/create-typescript-app
commands: |
pnpm install
pnpm add -D $PKG_URL
bash $SNAP create-typescript-app -- pnpm lint:knip
- name: DefinitelyTyped-tools
repo: microsoft/DefinitelyTyped-tools
commands: |
pnpm install
bash $SNAP DefinitelyTyped-tools -- pnpm dlx $PKG_URL
- name: eslint
repo: eslint/eslint
commands: |
npm install
npm install --prefix docs
npm install -D $PKG_URL
bash $SNAP eslint -- npm run lint:unused -- --cache
npm run lint:unused -- --cache --no-exit-code
- name: mocha
repo: mochajs/mocha
commands: |
npm ci
npm install -D $PKG_URL
bash $SNAP mocha -- npm run lint:knip
- name: InvokeAI
repo: invoke-ai/InvokeAI
sparse-checkout: invokeai/frontend/web
commands: |
cd invokeai/frontend/web
pnpm install
pnpm add -D $PKG_URL
bash $SNAP InvokeAI -- bunx --bun knip --tags=-knipignore
bunx --bun knip --tags=-knipignore --production --fix --allow-remove-files --format --no-exit-code
bash $SNAP InvokeAI-prod -- bunx --bun knip --tags=-knipignore --production
- name: npmx.dev
repo: npmx-dev/npmx.dev
commands: |
pnpm install
pnpm add -D -w $PKG_URL
bash $SNAP npmx.dev -- pnpm knip
bash $SNAP npmx.dev-prod -- pnpm knip --production --exclude dependencies --fix
- name: prettier
repo: prettier/prettier
commands: |
yarn
yarn --cwd scripts/release
yarn --cwd scripts/tools/bundle-test
yarn --cwd scripts/tools/eslint-plugin-prettier-internal-rules
yarn --cwd website
yarn add -D knip@$PKG_URL
bash $SNAP prettier -- yarn knip
- name: query
repo: TanStack/query
commands: |
pnpm install
pnpm add -D -w $PKG_URL
bash $SNAP query -- pnpm test:knip --cache
pnpm test:knip --cache --no-exit-code
- name: rolldown
repo: rolldown/rolldown
commands: |
pnpm install
pnpm add -D -w knip@$PKG_URL
bash $SNAP rolldown -- pnpm knip
- name: sanity
repo: sanity-io/sanity
commands: |
pnpm install --no-frozen-lockfile
pnpm add -D -w $PKG_URL
bash $SNAP sanity -- pnpm knip --exclude duplicates
- name: sentry
repo: getsentry/sentry
commands: |
pnpm install
pnpm add -D $PKG_URL
bash $SNAP sentry -- pnpm run knip --fix
bash $SNAP sentry-prod -- pnpm run knip:prod
- name: slonik
repo: gajus/slonik
commands: |
pnpm install --no-frozen-lockfile --ignore-scripts
bash $SNAP slonik -- pnpm dlx $PKG_URL
- name: TypeScript
repo: microsoft/TypeScript
commands: |
npm ci
npm install -D $PKG_URL
npx hereby generate-diagnostics
bash $SNAP TypeScript -- npx knip
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
with:
persist-credentials: false
- name: Check out ${{ matrix.project.repo }}
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
with:
repository: ${{ matrix.project.repo }}
path: ${{ matrix.project.name }}
sparse-checkout: ${{ matrix.project.sparse-checkout }}
persist-credentials: false
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
with:
node-version: 24
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
with:
no-cache: true
- uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5
- name: Run Knip in ${{ matrix.project.repo }}
working-directory: ${{ matrix.project.name }}
run: |
set -x
${{ matrix.project.commands }}
- name: Upload updated snapshots
if: ${{ inputs.update_snapshots }}
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: snapshots-${{ matrix.project.name }}
path: /tmp/snapshot-updates/
if-no-files-found: ignore
aggregate-snapshots:
name: Aggregate updated snapshots
if: ${{ inputs.update_snapshots }}
needs: integration
runs-on: ubuntu-latest
permissions:
contents: read # download and upload artifacts
steps:
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
with:
pattern: snapshots-*
path: snapshots/
merge-multiple: true
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: snapshots
path: snapshots/