Skip to content

Commit 1803f9f

Browse files
committed
Ecosystem patches → snapshots
1 parent 9ffd437 commit 1803f9f

24 files changed

Lines changed: 154 additions & 70 deletions

.github/workflows/integration.yml

Lines changed: 60 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ name: Publish preview & run ecosystem tests
22

33
on:
44
workflow_dispatch:
5+
inputs:
6+
update_snapshots:
7+
description: Regenerate ecosystem snapshots and upload as artifact
8+
type: boolean
9+
default: false
510
pull_request:
611
push:
712
branches:
@@ -58,6 +63,9 @@ jobs:
5863
runs-on: ubuntu-latest
5964
env:
6065
PKG_URL: https://pkg.pr.new/knip@${{ needs.publish.outputs.sha }}
66+
SNAP: ${{ github.workspace }}/.github/workflows/scripts/snap.sh
67+
UPDATE_SNAPSHOTS: ${{ inputs.update_snapshots && '1' || '' }}
68+
SNAPSHOT_OUT_DIR: /tmp/snapshot-updates
6169
strategy:
6270
fail-fast: false
6371
matrix:
@@ -66,52 +74,52 @@ jobs:
6674
repo: birchill/10ten-ja-reader
6775
commands: |
6876
pnpm install
69-
pnpm dlx $PKG_URL
77+
bash $SNAP 10ten-ja-reader -- pnpm dlx $PKG_URL
7078
7179
- name: argos
7280
repo: argos-ci/argos
7381
commands: |
7482
pnpm install
7583
pnpm build
7684
pnpm add -D -w $PKG_URL
77-
pnpm run knip
85+
bash $SNAP argos -- pnpm run knip
7886
7987
- name: astro
8088
repo: withastro/astro
8189
commands: |
8290
pnpm install --config.minimumReleaseAge=0
8391
pnpm build
8492
pnpm add -D -w $PKG_URL --config.minimumReleaseAge=0
85-
pnpm knip --fix
93+
bash $SNAP astro -- pnpm knip --fix
8694
87-
- name: create-typescript-app
88-
repo: JoshuaKGoldberg/create-typescript-app
89-
commands: |
90-
pnpm install
91-
pnpm add -D $PKG_URL
92-
pnpm lint:knip
95+
# - name: create-typescript-app
96+
# repo: JoshuaKGoldberg/create-typescript-app
97+
# commands: |
98+
# pnpm install
99+
# pnpm add -D $PKG_URL
100+
# bash $SNAP create-typescript-app -- pnpm lint:knip
93101

94102
- name: DefinitelyTyped-tools
95103
repo: microsoft/DefinitelyTyped-tools
96104
commands: |
97105
pnpm install
98-
pnpm dlx $PKG_URL
106+
bash $SNAP DefinitelyTyped-tools -- pnpm dlx $PKG_URL
99107
100108
- name: eslint
101109
repo: eslint/eslint
102110
commands: |
103111
npm install
104112
npm install --prefix docs
105113
npm install -D $PKG_URL
106-
npm run lint:unused -- --cache
107-
npm run lint:unused -- --cache
114+
bash $SNAP eslint -- npm run lint:unused -- --cache
115+
npm run lint:unused -- --cache --no-exit-code
108116
109117
- name: mocha
110118
repo: mochajs/mocha
111119
commands: |
112120
npm ci
113121
npm install -D $PKG_URL
114-
npm run lint:knip
122+
bash $SNAP mocha -- npm run lint:knip
115123
116124
- name: InvokeAI
117125
repo: invoke-ai/InvokeAI
@@ -120,17 +128,17 @@ jobs:
120128
cd invokeai/frontend/web
121129
pnpm install
122130
pnpm add -D $PKG_URL
123-
bunx --bun knip --tags=-knipignore
124-
bunx --bun knip --tags=-knipignore --production --fix --allow-remove-files --format
125-
bunx --bun knip --tags=-knipignore --production
131+
bash $SNAP InvokeAI -- bunx --bun knip --tags=-knipignore
132+
bunx --bun knip --tags=-knipignore --production --fix --allow-remove-files --format --no-exit-code
133+
bash $SNAP InvokeAI-prod -- bunx --bun knip --tags=-knipignore --production
126134
127135
- name: npmx.dev
128136
repo: npmx-dev/npmx.dev
129137
commands: |
130138
pnpm install
131139
pnpm add -D -w $PKG_URL
132-
pnpm knip
133-
pnpm knip --production --exclude dependencies --fix
140+
bash $SNAP npmx.dev -- pnpm knip
141+
bash $SNAP npmx.dev-prod -- pnpm knip --production --exclude dependencies --fix
134142
135143
- name: prettier
136144
repo: prettier/prettier
@@ -141,50 +149,51 @@ jobs:
141149
yarn --cwd scripts/tools/eslint-plugin-prettier-internal-rules
142150
yarn --cwd website
143151
yarn add -D knip@$PKG_URL
144-
yarn knip
152+
bash $SNAP prettier -- yarn knip
145153
146154
- name: query
147155
repo: TanStack/query
148156
commands: |
149157
pnpm install
150158
pnpm add -D -w $PKG_URL
151-
pnpm test:knip --cache
152-
pnpm test:knip --cache
159+
bash $SNAP query -- pnpm test:knip --cache
160+
pnpm test:knip --cache --no-exit-code
153161
154162
- name: rolldown
155163
repo: rolldown/rolldown
156164
commands: |
157165
pnpm install
158166
pnpm add -D -w knip@$PKG_URL
159-
pnpm knip
167+
bash $SNAP rolldown -- pnpm knip
160168
161169
- name: sanity
162170
repo: sanity-io/sanity
163171
commands: |
164172
pnpm install --no-frozen-lockfile --config.minimumReleaseAge=0
165173
pnpm add -D -w $PKG_URL --config.minimumReleaseAge=0
166-
pnpm knip --exclude duplicates
174+
bash $SNAP sanity -- pnpm knip --exclude duplicates
167175
168176
- name: sentry
169177
repo: getsentry/sentry
170178
commands: |
171179
pnpm install
172180
pnpm add -D $PKG_URL
173-
pnpm run knip --fix
174-
pnpm run knip:prod
181+
bash $SNAP sentry -- pnpm run knip --fix
182+
bash $SNAP sentry-prod -- pnpm run knip:prod
175183
176184
- name: slonik
177185
repo: gajus/slonik
178186
commands: |
179187
pnpm install --no-frozen-lockfile
180-
pnpm dlx $PKG_URL
188+
bash $SNAP slonik -- pnpm dlx $PKG_URL
181189
182190
- name: TypeScript
183191
repo: microsoft/TypeScript
184192
commands: |
185193
npm ci
186194
npm install -D $PKG_URL
187-
npm run knip
195+
npx hereby generate-diagnostics
196+
bash $SNAP TypeScript -- npx knip
188197
189198
steps:
190199
- uses: actions/checkout@v6
@@ -196,12 +205,6 @@ jobs:
196205
path: ${{ matrix.project.name }}
197206
sparse-checkout: ${{ matrix.project.sparse-checkout }}
198207

199-
- name: Apply patch if exists
200-
working-directory: ${{ matrix.project.name }}
201-
run: |
202-
PATCH_FILE="${{ github.workspace }}/.github/workflows/patches/${{ matrix.project.name }}.patch"
203-
[ -f "$PATCH_FILE" ] && git apply --verbose -C0 --ignore-whitespace "$PATCH_FILE" || true
204-
205208
- uses: actions/setup-node@v6
206209
with:
207210
node-version: 24
@@ -215,3 +218,27 @@ jobs:
215218
run: |
216219
set -x
217220
${{ matrix.project.commands }}
221+
222+
- name: Upload updated snapshots
223+
if: ${{ inputs.update_snapshots }}
224+
uses: actions/upload-artifact@v4
225+
with:
226+
name: snapshots-${{ matrix.project.name }}
227+
path: /tmp/snapshot-updates/
228+
if-no-files-found: ignore
229+
230+
aggregate-snapshots:
231+
name: Aggregate updated snapshots
232+
if: ${{ inputs.update_snapshots }}
233+
needs: integration
234+
runs-on: ubuntu-latest
235+
steps:
236+
- uses: actions/download-artifact@v4
237+
with:
238+
pattern: snapshots-*
239+
path: snapshots/
240+
merge-multiple: true
241+
- uses: actions/upload-artifact@v4
242+
with:
243+
name: snapshots
244+
path: snapshots/

.github/workflows/patches/TypeScript.patch

Lines changed: 0 additions & 25 deletions
This file was deleted.

.github/workflows/patches/create-typescript-app.patch

Lines changed: 0 additions & 12 deletions
This file was deleted.

.github/workflows/scripts/snap.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env bash
2+
set -uo pipefail
3+
4+
NAME="${1:?snapshot name required}"
5+
shift
6+
[ "${1:-}" = "--" ] && shift
7+
8+
DIR="${GITHUB_WORKSPACE:-$PWD}/.github/workflows/snapshots"
9+
OUT_DIR="${SNAPSHOT_OUT_DIR:-$DIR}"
10+
SNAP="$DIR/$NAME.txt"
11+
OUT="$(mktemp)"
12+
13+
EXTRA=(--reporter compact --no-exit-code)
14+
if [ "${1:-}" = "npm" ] && [ "${2:-}" = "run" ] && ! printf '%s\n' "$@" | grep -qx -- '--'; then
15+
EXTRA=(-- "${EXTRA[@]}")
16+
fi
17+
18+
NO_COLOR=1 "$@" "${EXTRA[@]}" >"$OUT" || { echo "::error::knip crashed for $NAME"; cat "$OUT"; exit 1; }
19+
20+
if [ "${UPDATE_SNAPSHOTS:-}" = "1" ]; then
21+
mkdir -p "$OUT_DIR"
22+
cp "$OUT" "$OUT_DIR/$NAME.txt"
23+
echo "::notice::Updated $OUT_DIR/$NAME.txt"
24+
exit 0
25+
fi
26+
27+
[ -f "$SNAP" ] || { echo "::error::No snapshot at $SNAP — run with update_snapshots=true"; cat "$OUT"; exit 1; }
28+
diff -u "$SNAP" "$OUT" || { echo "::error::Snapshot mismatch for $NAME — re-run with update_snapshots=true if expected"; exit 1; }

.github/workflows/snapshots/10ten-ja-reader.txt

Whitespace-only changes.

.github/workflows/snapshots/DefinitelyTyped-tools.txt

Whitespace-only changes.

.github/workflows/snapshots/InvokeAI-prod.txt

Whitespace-only changes.

.github/workflows/snapshots/InvokeAI.txt

Whitespace-only changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Unused exports (2)
2+
src/compiler/sys.ts: sysLog (ts)
3+
src/compiler/tracing.ts: tracingEnabled (ts)

0 commit comments

Comments
 (0)