-
Notifications
You must be signed in to change notification settings - Fork 1
548 lines (459 loc) · 18.8 KB
/
Copy pathci.yml
File metadata and controls
548 lines (459 loc) · 18.8 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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
name: CI
on:
push:
branches: ["main", "master"]
pull_request:
permissions:
contents: read
jobs:
# Multi-platform build matrix
build:
permissions:
contents: read
actions: read
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
include:
- os: ubuntu-latest
platform: web
- os: macos-latest
platform: macos
runs-on: ${{ matrix.os }}
env:
SNAPSHOT_TESTS: ${{ matrix.platform == 'macos' && '1' || '0' }}
SNAPSHOT_RECORD: "0"
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v6
with:
fetch-depth: 0
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
- name: Setup Node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
node-version: 20
- name: Setup pnpm
uses: pnpm/action-setup@08c4be7e2e672a47d11bd04269e27e5f3e8529cb # v4
with:
version: 10.33.0
- name: Get pnpm store directory
shell: bash
run: echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm cache
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v5
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Setup Swift (macOS only)
if: matrix.os == 'macos-latest'
run: |
swift --version
xcrun --find swift
- name: Install deps
run: pnpm install --frozen-lockfile --prod=false
- name: Check version synchronization
run: pnpm sync:versions:check
- name: Fetch base ref (PR only)
if: github.event_name == 'pull_request'
run: git fetch origin ${{ github.base_ref }} --depth=1
- name: Detect apps-sdk-ui version change
id: apps-sdk-change
run: node scripts/check-apps-sdk-ui-version.mjs
- name: Agent design prepare evidence (web platform PR only)
if: github.event_name == 'pull_request' && matrix.platform == 'web'
env:
AGENT_DESIGN_PREPARE_BASE: origin/${{ github.base_ref }}
run: pnpm agent-design:prepare:changed
- name: Run Apps SDK UI drift tests
if: steps.apps-sdk-change.outputs.changed == 'true'
run: pnpm test:drift
- name: Stamp upstream alignment log
if: steps.apps-sdk-change.outputs.changed == 'true'
run: pnpm ds:alignment:stamp
- name: Ensure alignment stamp committed
if: steps.apps-sdk-change.outputs.changed == 'true'
run: git diff --exit-code docs/design-system/UPSTREAM_ALIGNMENT.md
- name: Lint (web platform only)
if: matrix.platform == 'web'
run: pnpm lint
- name: Policy checks (web platform only)
if: matrix.platform == 'web'
run: pnpm test:policy
- name: Design system coverage matrix check (web platform only)
if: matrix.platform == 'web'
run: pnpm ds:matrix:check
- name: Quality debt check (warn-first, web platform only)
if: matrix.platform == 'web'
continue-on-error: true
run: pnpm quality-debt:check
- name: Quality debt report (warn-first, web platform only)
if: matrix.platform == 'web'
continue-on-error: true
run: pnpm quality-debt:report -- --output reports/qa/quality-debt-burndown-ci.md
- name: Format check (web platform only)
if: matrix.platform == 'web'
run: pnpm format:check
- name: Compliance checks (web platform only)
if: matrix.platform == 'web'
run: pnpm lint:compliance
- name: Onboarding parity + outcome checks (web platform only)
if: matrix.platform == 'web'
run: pnpm onboarding:check
- name: Type-check packages (web platform only)
if: matrix.platform == 'web'
run: |
pnpm -C packages/ui type-check
pnpm -C packages/runtime type-check
pnpm -C packages/tokens type-check
- name: Strict type-check (informational — tracks migration to noUncheckedIndexedAccess)
if: matrix.platform == 'web'
continue-on-error: true
run: |
set +e
pnpm exec tsc -p tsconfig.strict.json --noEmit > /tmp/strict-typecheck.log 2>&1
strict_status=$?
if [ "$strict_status" -ne 0 ]; then
echo "Strict type-check remains informational; see sanitized tail below."
tail -20 /tmp/strict-typecheck.log | sed -E 's/^([^()]+)\(([0-9]+),([0-9]+)\): error TS/strict-typecheck \1:\2:\3 TS/'
fi
exit "$strict_status"
- name: Icon generation property tests (web platform only)
if: matrix.platform == 'web'
run: pnpm test:astudio-icons
- name: Runtime host adapter contract tests (web platform only)
if: matrix.platform == 'web'
run: pnpm test:runtime
- name: MCP tool contract tests (web platform only)
if: matrix.platform == 'web'
run: pnpm test:mcp-contract
- name: Install Playwright (web + macOS exemplar lanes)
if: matrix.platform == 'web' || matrix.platform == 'macos'
run: |
if [ "${{ runner.os }}" = "Linux" ]; then
pnpm exec playwright install --with-deps chromium
else
pnpm exec playwright install chromium
fi
- name: Exemplar evaluation (macOS baseline lane)
if: matrix.platform == 'macos'
run: pnpm test:exemplar-evaluation
- name: Enhanced build pipeline
run: node scripts/build-pipeline.mjs --platforms ${{ matrix.platform }}
- name: Bundle size budgets (web platform only)
if: matrix.platform == 'web'
run: pnpm bundle:monitor:strict
- name: Upload build artifacts
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: build-artifacts-${{ matrix.platform }}
path: |
packages/*/dist/
swift/*/.build/
swift/**/__Snapshots__/
.build-cache/
reports/qa/quality-debt-burndown-ci.md
retention-days: 7
a11y:
permissions:
contents: read
actions: read
runs-on: ubuntu-latest
needs: build
outputs:
storybook_changed: ${{ steps.storybook_changes.outputs.changed || 'false' }}
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v6
with:
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
node-version: 20
- name: Setup pnpm
uses: pnpm/action-setup@08c4be7e2e672a47d11bd04269e27e5f3e8529cb # v4
with:
version: 10.33.0
- name: Get pnpm store directory
shell: bash
run: echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm cache
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v5
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install deps
run: pnpm install --frozen-lockfile --prod=false
- name: Download build artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: build-artifacts-web
path: .
- name: Install Playwright
run: pnpm exec playwright install --with-deps chromium
- name: Detect Storybook-related changes (PR only)
if: github.event_name == 'pull_request'
id: storybook_changes
shell: bash
run: |
git fetch origin "${{ github.base_ref }}" --depth=1
if git diff --name-only "origin/${{ github.base_ref }}...HEAD" | rg -q '^(platforms/web/apps/storybook/|\.storybook/|.*\.stories\.(ts|tsx|js|jsx|mdx)$)'; then
echo "changed=true" >> "$GITHUB_OUTPUT"
else
echo "changed=false" >> "$GITHUB_OUTPUT"
fi
- name: Cache UI dist
id: ui-dist-cache
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v5
with:
path: packages/ui/dist
key: ${{ runner.os }}-ui-dist-${{ hashFiles('packages/ui/src/**', 'packages/ui/package.json', 'pnpm-lock.yaml') }}
- name: Build UI (if cache miss)
if: steps.ui-dist-cache.outputs.cache-hit != 'true'
run: pnpm -C packages/ui build
- name: Build Storybook
if: github.event_name != 'pull_request' || steps.storybook_changes.outputs.changed == 'true'
run: pnpm storybook:build
- name: Run Storybook tests (a11y + interactions)
if: github.event_name != 'pull_request' || steps.storybook_changes.outputs.changed == 'true'
run: pnpm storybook:test
- name: Upload Storybook static output
if: github.event_name != 'pull_request' || steps.storybook_changes.outputs.changed == 'true'
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: storybook-static
path: platforms/web/apps/storybook/storybook-static/
retention-days: 7
- name: Run widget a11y audit
run: pnpm test:a11y:widgets:ci
env:
A11Y_STRICT: "1"
visual:
permissions:
contents: read
actions: read
issues: write
pull-requests: write
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v6
- name: Setup Node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
node-version: 20
- name: Setup pnpm
uses: pnpm/action-setup@08c4be7e2e672a47d11bd04269e27e5f3e8529cb # v4
with:
version: 10.33.0
- name: Get pnpm store directory
shell: bash
run: echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm cache
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v5
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install deps
run: pnpm install --frozen-lockfile --prod=false
- name: Download build artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: build-artifacts-web
path: .
- name: Install Playwright
run: pnpm exec playwright install --with-deps chromium
- name: Run visual regression (Playwright)
run: pnpm test:visual:web
continue-on-error: true
- name: Upload screenshot artifacts (on failure)
if: failure()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: visual-screenshots-diff
path: |
apps/web/tests/visual/__snapshots__/
apps/web/playwright-report/visual/
retention-days: 7
- name: Fail job if visual tests failed
if: failure()
run: exit 1
- name: Comment PR with visual diff results
if: failure() && github.event_name == 'pull_request'
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
script: |
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const botComment = comments.find(comment =>
comment.user.type === 'Bot' &&
comment.body.includes('Visual Regression Tests')
);
const body = `## Visual Regression Tests Failed
Screenshots have changed and may require review.
### Steps to review:
1. Download the [visual-screenshots-diff artifact](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
2. Compare images in \`__snapshots__\` with the actual results
3. If changes are intentional, run \`pnpm test:visual:update\` locally
\`${{ github.sha }}\``;
if (botComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: body,
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: body,
});
}
smoke-agent-browser:
permissions:
contents: read
actions: read
if: ${{ github.event_name != 'pull_request' }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v6
- name: Setup Node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
node-version: 20
- name: Setup pnpm
uses: pnpm/action-setup@08c4be7e2e672a47d11bd04269e27e5f3e8529cb # v4
with:
version: 10.33.0
- name: Get pnpm store directory
shell: bash
run: echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm cache
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v5
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install deps
run: pnpm install --frozen-lockfile --prod=false
- name: Download build artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: build-artifacts-web
path: .
- name: Build web app
run: pnpm -C platforms/web/apps/web build
env:
VITE_WIDGETS_BASE: http://127.0.0.1:4173
- name: Install Chromium
run: pnpm exec agent-browser install
- name: Install Playwright browser (smoke prereq)
run: pnpm exec playwright install --with-deps chromium
- name: Run smoke tests
run: pnpm test:agent-browser:ci
- name: Upload smoke test artifacts (on failure)
if: failure()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: smoke-test-agent-browser
path: test-results/agent-browser/**
retention-days: 7
# ─── Deploy Storybook to Cloudflare Pages ─────────────────────────────────
# Runs on every push to main (production deployment) and on PRs that touch
# stories (preview deployment with a unique URL per branch).
#
# Required secrets:
# CLOUDFLARE_API_TOKEN — Pages deployment token (Edit Pages permission)
# CLOUDFLARE_ACCOUNT_ID — Cloudflare account ID
#
# After first deploy, the production URL will be:
# https://design-system-storybook.pages.dev
deploy-storybook:
name: Deploy Storybook → Cloudflare Pages
runs-on: ubuntu-latest
needs: [a11y]
# Deploy on main push always; on PRs only if stories changed
if: |
github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
|| github.event_name == 'pull_request' && needs.a11y.outputs.storybook_changed == 'true'
permissions:
contents: read
deployments: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v6
- name: Download Storybook static output
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: storybook-static
path: storybook-static/
# If the a11y job skipped the build (no story changes on PR), this
# artifact won't exist. Continue so we can gate below.
continue-on-error: true
- name: Check artifact exists
id: artifact_check
run: |
if [ -d "storybook-static" ] && [ "$(ls -A storybook-static)" ]; then
echo "exists=true" >> "$GITHUB_OUTPUT"
else
echo "exists=false" >> "$GITHUB_OUTPUT"
fi
- name: Deploy to Cloudflare Pages
if: steps.artifact_check.outputs.exists == 'true'
id: cf_deploy
uses: cloudflare/wrangler-action@ebbaa1584979971c8614a24965b4405ff95890e0 # v4.0.0
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy storybook-static --project-name=design-system-storybook --branch=${{ github.head_ref || github.ref_name }}
- name: Comment preview URL on PR
if: |
github.event_name == 'pull_request' &&
steps.artifact_check.outputs.exists == 'true' &&
steps.cf_deploy.outputs.deployment-url != ''
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
script: |
const url = '${{ steps.cf_deploy.outputs.deployment-url }}';
const sha = context.sha.substring(0, 7);
const body = `## 📚 Storybook Preview\n\n| | |\n|---|---|\n| **URL** | ${url} |\n| **Commit** | \`${sha}\` |\n| **Branch** | \`${{ github.head_ref }}\` |\n\nBrowse components, run interaction tests, and check accessibility in the deployed Storybook.`;
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const existing = comments.find(c =>
c.user.type === 'Bot' && c.body.includes('Storybook Preview')
);
if (existing) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existing.id,
body,
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body,
});
}