Repository navigation
514 lines (458 loc) · 22.5 KB
/
Copy pathwebsite-deploy.yml
File metadata and controls
514 lines (458 loc) · 22.5 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
name: Website Deploy
on:
push:
branches:
- master
paths:
- 'apps/website/**'
- 'apps/desktop/**'
- 'packages/editor/**'
- 'packages/engine/**'
- 'packages/scene/**'
- 'packages/platform/**'
- 'packages/home/**'
- 'packages/ui/**'
- 'packages/shared/**'
- 'tests/e2e/browser/**'
- '.github/workflows/website-deploy.yml'
- 'playwright.website.config.ts'
- 'playwright.demo-dist.config.mts'
- 'scripts/website/**'
- 'scripts/check-claims.mjs'
- 'scripts/claims-allowlist.json'
# Only the release-data fetcher and its inputs affect website output.
# Release verification helpers do not change the published site.
- 'scripts/release/fetch-website-release.mjs'
- 'scripts/release/verify-release-data.mjs'
- 'scripts/release/website-release-data.mjs'
- 'scripts/release/product.mjs'
- 'scripts/release/github-fetch.mjs'
- 'CHANGELOG.md'
- 'package.json'
- 'pnpm-lock.yaml'
# A human-published release dispatches a repository event so the download
# page is rebuilt from the exact published assets (see
# scripts/release/fetch-website-release.mjs — drafts never appear).
# workflow_run remains as a protected-default-branch fallback, but its
# release-data job verifies that a published release exists before building;
# a draft-producing run therefore cannot deploy.
workflow_run:
workflows: ['Release']
types: [completed]
repository_dispatch:
types: [varve-release-published]
workflow_dispatch:
inputs:
release_tag:
description: 'Published release to deploy or recover (leave both release inputs empty for source deployment)'
required: false
default: ''
type: string
release_sha:
description: 'Exact 40-character source SHA of that published release'
required: false
default: ''
type: string
permissions:
contents: read
concurrency:
# GitHub keeps only one pending run per group. The Release workflow's
# workflow_run notification after a workflow_dispatch is intentionally a
# no-op; isolate it so it cannot replace the publication repository_dispatch
# while a source deployment is running.
group: "pages-${{ github.event_name == 'workflow_run' && github.event.workflow_run.event == 'workflow_dispatch' && 'noop' || 'deploy' }}"
cancel-in-progress: false
env:
PNPM_VERSION: '11.9.0'
NODE_VERSION: '26.10.0'
# Public build-time configuration. Consent is still required in-browser;
# this only enables the consent UI and GoatCounter transport for varve.studio.
ANALYTICS_DOMAIN: 'varve.studio'
jobs:
# ── 1. Website-source certification (source changes only) ────────────────
test:
name: Website quality gates
runs-on: ubuntu-latest
timeout-minutes: 30
# A release publication does not change website source. Its release-data
# path is checked separately below, so do not repeat the complete website
# functional/a11y/visual corpus for every successful Release run.
if: >-
github.event_name != 'workflow_run' && github.event_name != 'repository_dispatch' &&
!(github.event_name == 'workflow_dispatch' && (inputs.release_tag != '' || inputs.release_sha != ''))
env:
# Trust-boundary canary: present on the build steps, then asserted
# absent from the artifacts (docs/security/trust-boundaries.md
# §Canary tests).
VARVE_PRIVATE_TEST_CANARY: VARVE_PRIVATE_TEST_CANARY_DO_NOT_SHIP
VARVE_E2E_OUTPUT_DIR: website-deploy-${{ github.sha }}-${{ github.run_id }}-${{ github.run_attempt }}
VARVE_CI_PLAYWRIGHT_REPORT: test-results/website-deploy-${{ github.sha }}-${{ github.run_id }}-${{ github.run_attempt }}/playwright.json
VARVE_CI_COMMIT_SHA: ${{ github.sha }}
VARVE_WEBSITE_E2E_PORT: '15643'
VARVE_WEBSITE_E2E_PORT_ROOT: '15644'
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
ref: ${{ github.sha }}
persist-credentials: false
- name: Verify exact event source
run: test "$(git rev-parse --verify 'HEAD^{commit}')" = "${{ github.sha }}"
- uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115
with:
version: ${{ env.PNPM_VERSION }}
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1
with:
node-version: ${{ env.NODE_VERSION }}
cache: pnpm
cache-dependency-path: pnpm-lock.yaml
- name: Install dependencies (frozen)
run: pnpm install --frozen-lockfile
- name: Plan exact website browser source
run: |
mkdir -p "test-results/${VARVE_E2E_OUTPUT_DIR}"
node scripts/quality/ci-plan.mjs --base "$GITHUB_SHA" --head "$GITHUB_SHA" \
--output "test-results/${VARVE_E2E_OUTPUT_DIR}/plan.json"
- name: Type check + unit tests (incl. release-data states)
run: pnpm test:website
- name: Check public claims
run: pnpm audit:claims
# Both deployment modes must build from the same source: the production
# custom-domain build (base /, built from the astro.config.mjs defaults)
# and the legacy /varve project-site mode. The e2e suite (link crawl,
# asset existence, axe-core, canonical/sitemap/robots/404, mobile nav)
# runs against both builds, served beneath the real /varve path.
- name: Build production (custom-domain) mode
run: pnpm build:website
- name: Build legacy project-site mode
run: pnpm build:website:pages
# The website is an untrusted public client: its output must never
# contain private configuration. The canary proves the build embeds
# nothing it is not told to.
- name: Scan website artifacts (secret + canary)
run: |
node scripts/secret-scan.mjs --dir apps/website/dist --canary "$VARVE_PRIVATE_TEST_CANARY"
node scripts/secret-scan.mjs --dir apps/website/dist-pages --canary "$VARVE_PRIVATE_TEST_CANARY"
- name: Install Playwright browsers
timeout-minutes: 8
run: |
node scripts/ci/configure-ubuntu-browser-apt.mjs
pnpm exec playwright install --with-deps chromium
- name: Discover complete website case inventory
run: >-
node scripts/quality/browser-inventory.mjs --lane website-e2e
--config playwright.website.config.ts --plan "test-results/${VARVE_E2E_OUTPUT_DIR}/plan.json"
--output "test-results/${VARVE_E2E_OUTPUT_DIR}/browser-inventory.json"
- name: E2E in both modes
run: >-
node scripts/quality/heavy-lease.mjs "website deploy: source modes" --
pnpm exec playwright test -c playwright.website.config.ts
--workers=1 --retries=0 --update-snapshots=none --fail-on-flaky-tests --trace=retain-on-failure
- name: Verify website browser evidence
if: always()
run: >-
node scripts/quality/ci-execution-report.mjs --category website --lanes website-e2e
--plan "test-results/${VARVE_E2E_OUTPUT_DIR}/plan.json"
--matrix ubuntu-latest --status "${{ job.status }}"
--output "test-results/${VARVE_E2E_OUTPUT_DIR}/execution-evidence.json"
--playwright-report "website-e2e=${VARVE_CI_PLAYWRIGHT_REPORT}"
--playwright-inventory "${VARVE_CI_PLAYWRIGHT_REPORT}=test-results/${VARVE_E2E_OUTPUT_DIR}/browser-inventory.json"
# Preserve screenshots, diffs, and Playwright's JSON case history on every
# outcome. This makes a remote visual regression actionable without
# copying thousands of lines from the Actions log.
- name: Upload website E2E diagnostics
if: always()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9
with:
name: website-e2e-diagnostics-${{ github.sha }}-${{ github.run_id }}-${{ github.run_attempt }}
path: |
test-results/${{ env.VARVE_E2E_OUTPUT_DIR }}/
if-no-files-found: ignore
retention-days: 7
# ── 2. Release-data validation (release publication only) ─────────────────
release-data:
name: Release-data validation
outputs:
published: ${{ steps.release-state.outputs.published }}
tag: ${{ steps.release-state.outputs.tag }}
published_sha: ${{ steps.release-state.outputs.published_sha }}
runs-on: ubuntu-latest
timeout-minutes: 5
if: >-
(github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.event != 'workflow_dispatch') ||
github.event_name == 'repository_dispatch' ||
(github.event_name == 'workflow_dispatch' && (inputs.release_tag != '' || inputs.release_sha != ''))
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
ref: ${{ github.sha }}
persist-credentials: false
sparse-checkout-cone-mode: false
sparse-checkout: |
/scripts/release/verify-website-publication.mjs
/scripts/release/website-release-data-check.mjs
/apps/website/src/data/release-manifest.json
- name: Verify release-data workflow source
run: test "$(git rev-parse --verify 'HEAD^{commit}')" = "${{ github.sha }}"
- name: Verify the release is actually published
id: release-state
env:
GH_TOKEN: ${{ github.token }}
GITHUB_REPOSITORY: ${{ github.repository }}
RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && inputs.release_tag || github.event_name == 'repository_dispatch' && github.event.client_payload.tag || github.event.workflow_run.head_branch }}
RELEASE_SHA: ${{ github.event_name == 'workflow_dispatch' && inputs.release_sha || github.event_name == 'repository_dispatch' && github.event.client_payload.sha || github.event.workflow_run.head_sha }}
ALLOW_UNPUBLISHED: ${{ github.event_name == 'workflow_run' }}
run: |
set -euo pipefail
node scripts/release/verify-website-publication.mjs \
--repo "$GITHUB_REPOSITORY" --tag "$RELEASE_TAG" --sha "$RELEASE_SHA" \
--allow-unpublished "$ALLOW_UNPUBLISHED"
# This validates the committed no-release/published-release shape. The
# build job subsequently fetches and verifies the exact published GitHub
# release before replacing this data; drafts never become download cards.
- name: Validate committed release-data state
if: steps.release-state.outputs.published == 'true'
run: node scripts/release/website-release-data-check.mjs
# ── 3. Build + upload ──────────────────────────────────────────────────────
build:
name: Build and upload Pages artifact
outputs:
source_sha: ${{ steps.source.outputs.source_sha }}
needs: [test, release-data]
runs-on: ubuntu-latest
timeout-minutes: 40
env:
VARVE_DEMO_EXPECTED_SHA: ${{ needs.release-data.outputs.published_sha || github.sha }}
VARVE_DEMO_DIST_URL: http://127.0.0.1:15645
VARVE_E2E_OUTPUT_DIR: website-demo-${{ needs.release-data.outputs.published_sha || github.sha }}-${{ github.run_id }}-${{ github.run_attempt }}
VARVE_CI_PLAYWRIGHT_REPORT: test-results/website-demo-${{ needs.release-data.outputs.published_sha || github.sha }}-${{ github.run_id }}-${{ github.run_attempt }}/playwright.json
# On normal source changes, test must pass and release-data is deliberately
# skipped. On a verified release publication, only the small release-data
# job must pass; the website source suite has already been certified.
if: >-
always() &&
((needs.release-data.result == 'success' &&
needs.release-data.outputs.published == 'true') ||
(needs.release-data.result == 'skipped' &&
needs.test.result == 'success'))
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
# Source pushes build the event SHA. Release publications build the
# exact published tag SHA returned by release-data; the two paths
# cannot silently borrow a newer default-branch checkout.
ref: ${{ needs.release-data.outputs.published_sha || github.sha }}
# Nothing in this workflow pushes; never persist the token.
persist-credentials: false
- name: Verify and record exact build source
id: source
env:
EXPECTED_SOURCE_SHA: ${{ needs.release-data.outputs.published_sha || github.sha }}
run: |
set -euo pipefail
ACTUAL_SOURCE_SHA="$(git rev-parse --verify 'HEAD^{commit}')"
test "$ACTUAL_SOURCE_SHA" = "$EXPECTED_SOURCE_SHA"
echo "source_sha=$ACTUAL_SOURCE_SHA" >> "$GITHUB_OUTPUT"
- uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115
with:
version: ${{ env.PNPM_VERSION }}
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1
with:
node-version: ${{ env.NODE_VERSION }}
cache: pnpm
cache-dependency-path: pnpm-lock.yaml
- name: Install dependencies (frozen)
run: pnpm install --frozen-lockfile
# ── WASM engine build (for the browser demo at /try/) ──────────────
- uses: dtolnay/rust-toolchain@683b588c487a69d01f6c6ddf40f036ff682cc2c8
with:
toolchain: 1.97.1
- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0
- name: Install just
uses: taiki-e/install-action@3a3daafd3b7f23b8f65d9f5ba2db203fb59b79e2
with:
tool: just@1.54.0
- name: Install wasm-pack (pinned, verified)
uses: taiki-e/install-action@3a3daafd3b7f23b8f65d9f5ba2db203fb59b79e2
with:
tool: wasm-pack@0.13.1
checksum: true
fallback: none
- name: wasm build (base + simd + colour)
run: just wasm-build-all
# The download page is rebuilt from the published release (channel
# policy: latest stable, else latest published prerelease; drafts never
# appear). When a Release run only produced a draft, this rewrites the
# no-release state — an idempotent rebuild of identical content.
- name: Fetch release data from GitHub
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_TAG: ${{ needs.release-data.outputs.tag }}
run: |
set -euo pipefail
if [[ -n "${RELEASE_TAG}" ]]; then
node scripts/release/fetch-website-release.mjs --tag "${RELEASE_TAG}"
else
node scripts/release/fetch-website-release.mjs
fi
- name: Build website
run: pnpm --filter @varve/website build
# The uploaded artifact must be clean of private configuration; the
# guard inside the build already rejected forbidden env vars.
- name: Scan built website artifact
run: node scripts/secret-scan.mjs --dir apps/website/dist
# ── Browser demo (/try/) build + staging ────────────────────────────
- name: Build browser demo
run: pnpm --filter @varve/desktop build:try
- name: Stage demo into website dist
run: node scripts/website/stage-demo.mjs
- name: Scan demo artifact (secret + canary)
run: |
node scripts/secret-scan.mjs --dir apps/website/dist/try
# The update owner rewrites the served service worker. Give it a
# disposable copy, then prove every byte of the Pages upload is intact.
- name: Prepare disposable combined demo artifact
id: demo-input
run: node scripts/website/demo-dist-validation.mjs prepare
- name: Install built-demo Playwright browser
timeout-minutes: 8
run: |
node scripts/ci/configure-ubuntu-browser-apt.mjs
pnpm exec playwright install --with-deps chromium
- name: List all built-demo owning cases
id: demo-list
env:
VARVE_CI_PLAYWRIGHT_REPORT: test-results/website-demo-${{ needs.release-data.outputs.published_sha || github.sha }}-${{ github.run_id }}-${{ github.run_attempt }}/expected-cases.json
run: >-
node scripts/quality/heavy-lease.mjs "website deploy: built demo inventory" --
pnpm exec playwright test -c playwright.demo-dist.config.mts --list
--workers=1 --retries=0 --update-snapshots=none --fail-on-flaky-tests --trace=retain-on-failure
- name: Validate built production demo
timeout-minutes: 17
run: >-
node scripts/quality/heavy-lease.mjs "website deploy: built production demo" --
pnpm exec playwright test -c playwright.demo-dist.config.mts
--workers=1 --retries=0 --update-snapshots=none --fail-on-flaky-tests --trace=retain-on-failure
- name: Verify complete built-demo browser evidence
if: always() && steps.demo-list.outcome == 'success'
run: node scripts/website/demo-dist-validation.mjs verify-report
- name: Verify Pages upload artifact remains unchanged
if: always() && steps.demo-input.outcome == 'success'
run: node scripts/website/demo-dist-validation.mjs assert-unchanged
- name: Upload built-demo diagnostics
if: always()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9
with:
name: website-demo-diagnostics-${{ needs.release-data.outputs.published_sha || github.sha }}-${{ github.run_id }}-${{ github.run_attempt }}
path: test-results/${{ env.VARVE_E2E_OUTPUT_DIR }}/
if-no-files-found: ignore
retention-days: 7
- name: Upload artifact
uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9
with:
path: apps/website/dist
include-hidden-files: true
# ── 4. Deploy + post-deployment smoke check ───────────────────────────────
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
# Either source quality or release-data validation is deliberately skipped.
# Override skipped-ancestor success() while requiring a successful build
# and refusing publication after workflow cancellation.
if: ${{ !cancelled() && needs.build.result == 'success' }}
timeout-minutes: 15
# Pages deployment needs exactly: read the repo, write Pages, and an OIDC
# token for actions/deploy-pages. Nothing else — no contents write, no
# secrets beyond the default token.
permissions:
contents: read
pages: write
id-token: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
# The smoke check only reads scripts/website/smoke-pages.mjs; the
# checkout exists for that script. No push capability needed.
ref: ${{ needs.build.outputs.source_sha }}
persist-credentials: false
- name: Verify exact deployed source
run: test "$(git rev-parse --verify 'HEAD^{commit}')" = "${{ needs.build.outputs.source_sha }}"
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@368f82528645a54fb793d4d04e342629a3f51346
# Bounded-retry smoke check against the live URL: homepage, download,
# docs, releases, sitemap, robots, security.txt, favicons, 404
# behaviour and the canonical origin (https://varve.studio). A
# deployment that 404s or canonicalizes to the wrong host is a failed
# deploy.
- name: Smoke check the live deployment
run: node scripts/website/smoke-pages.mjs "${{ steps.deployment.outputs.page_url }}" --expect-origin https://varve.studio
# upload-pages-artifact drops hidden files unless include-hidden-files
# is set. Fail the deploy if /.well-known/security.txt is missing.
- name: Verify security.txt is live
run: |
url='https://varve.studio/.well-known/security.txt'
code=''
for _ in 1 2 3 4 5 6 7 8; do
code=$(curl -sS -o /tmp/varve-security.txt -w '%{http_code}' --max-time 20 "$url" || true)
if [ "$code" = 200 ]; then
test -s /tmp/varve-security.txt
exit 0
fi
sleep 15
done
echo "security.txt returned HTTP ${code:-error}" >&2
exit 1
# Report-only live Lighthouse after a successful smoke check. This job
# checks out the trusted workflow ref and fetches https://varve.studio —
# it must not install or execute the deployed source_sha. Failures here
# must not roll back a successful deploy.
lighthouse-live:
name: Lighthouse report (live, non-blocking)
runs-on: ubuntu-latest
needs: deploy
if: ${{ !cancelled() && needs.deploy.result == 'success' }}
timeout-minutes: 15
continue-on-error: true
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
ref: ${{ github.sha }}
persist-credentials: false
- uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115
with:
version: ${{ env.PNPM_VERSION }}
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1
with:
node-version: ${{ env.NODE_VERSION }}
cache: pnpm
cache-dependency-path: pnpm-lock.yaml
- name: Install Lighthouse report dependencies
run: pnpm install --frozen-lockfile
- name: Install Chromium for Lighthouse
run: pnpm exec playwright install chromium
- name: Lighthouse report (live, non-blocking)
env:
LHCI_BASE_URL: https://varve.studio
LHCI_FORM_FACTOR: mobile
LHCI_NUMBER_OF_RUNS: '1'
LHCI_REPORT_ONLY: '1'
run: |
export CHROME_PATH
CHROME_PATH="$(node -e "const {chromium}=require('playwright'); console.log(chromium.executablePath())")"
test -n "$CHROME_PATH"
test -x "$CHROME_PATH"
npx --yes @lhci/cli@0.15.1 autorun --config=apps/website/lighthouserc.cjs
- name: Upload live Lighthouse report
if: always()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9
with:
name: website-lighthouse-live-${{ github.sha }}-${{ github.run_id }}
path: .lighthouseci/mobile/
if-no-files-found: ignore
retention-days: 14