-
Notifications
You must be signed in to change notification settings - Fork 0
278 lines (240 loc) · 9.07 KB
/
ci.yml
File metadata and controls
278 lines (240 loc) · 9.07 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
275
276
277
278
name: CI
on:
push:
branches: [main, dev]
paths:
- 'packages/**'
- 'examples/**'
- 'scripts/**'
- '!examples/stackwright-docs/content/**'
pull_request:
paths:
- 'packages/**'
- 'examples/**'
- 'scripts/**'
- '!examples/stackwright-docs/content/**'
permissions:
contents: read
env:
# Turborepo remote cache (Vercel)
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
TURBO_REMOTE_CACHE: ${{ vars.TURBO_REMOTE_CACHE || 'false' }}
jobs:
lint-and-format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-stackwright
- name: Setup Turborepo
uses: actions/cache@v5
with:
path: .turbo
key: ${{ runner.os }}-turbo-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-
- name: Dependency vulnerability audit
run: pnpm audit --audit-level=high
- run: pnpm turbo:format
- run: pnpm turbo:lint
audit:
runs-on: ubuntu-latest
needs: [lint-and-format]
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-stackwright
- name: Dependency vulnerability audit
run: pnpm audit --audit-level=high
test:
runs-on: ubuntu-latest
needs: [lint-and-format]
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-stackwright
with:
build: true
- name: Setup Turborepo
uses: actions/cache@v5
with:
path: .turbo
key: ${{ runner.os }}-turbo-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-
- run: pnpm test
scaffold-smoke-test:
runs-on: ubuntu-latest
needs: [lint-and-format]
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-stackwright
with:
build: true
- name: Setup Turborepo
uses: actions/cache@v5
with:
path: .turbo
key: ${{ runner.os }}-turbo-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-
- name: Build workspace packages with turbo
run: pnpm turbo:build --filter='!./examples/**'
- name: Pack workspace packages as tarballs
run: |
mkdir -p /tmp/stackwright-tarballs
for pkg in types themes icons collections core nextjs build-scripts ui-shadcn cli sbom-generator; do
pnpm --filter "@stackwright/$pkg" pack --pack-destination /tmp/stackwright-tarballs
done
- name: Scaffold a test project
run: node packages/cli/dist/cli.js scaffold /tmp/test-site --title "Test Site" --theme default --json
- name: Override scaffold deps with local tarballs
run: |
node -e "
const fs = require('fs');
const pkg = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
const tarballs = fs.readdirSync('/tmp/stackwright-tarballs');
const names = ['types','themes','icons','collections','core','nextjs','build-scripts','ui-shadcn','cli','sbom-generator'];
const overrides = {};
for (const name of names) {
const tarball = tarballs.find(t => t.startsWith('stackwright-' + name + '-'));
if (tarball) overrides['@stackwright/' + name] = '/tmp/stackwright-tarballs/' + tarball;
}
for (const section of ['dependencies', 'devDependencies']) {
for (const dep of Object.keys(pkg[section] || {})) {
if (overrides[dep]) pkg[section][dep] = overrides[dep];
}
}
pkg.pnpm = { overrides };
fs.writeFileSync('./package.json', JSON.stringify(pkg, null, 2) + '\n');
"
working-directory: /tmp/test-site
- name: Install scaffold dependencies
run: pnpm install --no-frozen-lockfile
working-directory: /tmp/test-site
- name: Build scaffold output
run: pnpm build
working-directory: /tmp/test-site
check-agent-docs:
runs-on: ubuntu-latest
needs: [lint-and-format]
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-stackwright
with:
build: true
- name: Setup Turborepo
uses: actions/cache@v5
with:
path: .turbo
key: ${{ runner.os }}-turbo-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-
- name: Regenerate AGENTS.md tables
run: node packages/cli/dist/cli.js generate-agent-docs
- name: Fail if AGENTS.md is out of sync with schemas
run: |
git diff --exit-code AGENTS.md || \
(echo "AGENTS.md is out of sync. Run 'pnpm stackwright -- generate-agent-docs' and commit the result." && exit 1)
e2e:
runs-on: ubuntu-latest
needs: [lint-and-format]
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-stackwright
with:
build: true
relink-bins: true
- name: Setup Turborepo
uses: actions/cache@v5
with:
path: .turbo
key: ${{ runner.os }}-turbo-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-
- name: Install Playwright browsers
run: pnpm --filter @stackwright/e2e exec playwright install --with-deps chromium
- name: Run E2E tests
# Visual regression baselines are generated locally. In CI, --update-snapshots
# makes visual tests act as render-smoke-tests (verify components render without
# crashing) rather than pixel comparisons, since font rendering differs across
# platforms. Pixel-perfect comparison runs locally where baselines were generated.
#
# a11y and performance tests are excluded here — they have dedicated workflows
# (accessibility.yml, performance.yml) with their own reporting and thresholds.
# NOTE: Do NOT add extra -- before 'test' - it breaks --project filtering
run: >-
pnpm --filter @stackwright/e2e exec playwright
test
tests/smoke.spec.ts
tests/visual.spec.ts
tests/render-tools.spec.ts
tests/e2e/
tests/edge-cases/
--project=chromium
--update-snapshots
- name: Upload Playwright report
uses: actions/upload-artifact@v4
if: failure()
with:
name: playwright-report
path: packages/e2e/playwright-report/
retention-days: 14
check-schemas:
runs-on: ubuntu-latest
needs: [lint-and-format]
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-stackwright
with:
build: true
- name: Setup Turborepo
uses: actions/cache@v5
with:
path: .turbo
key: ${{ runner.os }}-turbo-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-
- name: Regenerate JSON schemas
run: cd packages/types && pnpm generate-schemas
- name: Fail if JSON schemas are out of sync with types
run: |
git diff --exit-code packages/types/schemas/ || \
(echo "JSON schemas are out of sync. Run 'cd packages/types && pnpm generate-schemas' and commit the result." && exit 1)
check-template-sync:
runs-on: ubuntu-latest
steps:
- name: Checkout monorepo
uses: actions/checkout@v4
- name: Checkout template repo
uses: actions/checkout@v4
with:
repository: Per-Aspera-LLC/stackwright-template-nextjs
path: _template-repo
- name: Compare bundled templates with template repo
run: |
TEMPLATE_SRC="packages/cli/templates/scaffold-template"
DIFFS=""
# Compare all files in the bundled template against the template repo
while IFS= read -r -d '' file; do
rel="${file#$TEMPLATE_SRC/}"
if [ ! -f "_template-repo/$rel" ]; then
DIFFS="${DIFFS}Only in bundled: $rel\n"
elif ! diff -q "$file" "_template-repo/$rel" > /dev/null 2>&1; then
DIFFS="${DIFFS}Changed: $rel\n"
fi
done < <(find "$TEMPLATE_SRC" -type f -print0)
# Check for files in template repo not in bundled (excluding README.md, .git)
while IFS= read -r -d '' file; do
rel="${file#_template-repo/}"
if [ ! -f "$TEMPLATE_SRC/$rel" ]; then
DIFFS="${DIFFS}Only in template repo: $rel\n"
fi
done < <(find _template-repo -type f -not -path '*/.git/*' -not -name 'README.md' -print0)
if [ -n "$DIFFS" ]; then
echo "::warning::Template repo is out of sync with bundled templates (informational — not blocking)"
echo -e "$DIFFS"
echo ""
echo "The sync-template-repo workflow will update the template repo automatically when this PR merges to dev."
echo "If you need to sync manually, copy packages/cli/templates/scaffold-template/ to the template repo."
else
echo "Template repo is in sync with bundled templates."
fi