Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 102 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ on:

concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

permissions:
contents: read
Expand Down Expand Up @@ -56,7 +56,7 @@ jobs:
"https://github.com/godotengine/godot/releases/download/${GODOT_VERSION}-stable/${GODOT_ZIP}"
echo "$GODOT_SHA512 $RUNNER_TEMP/$GODOT_ZIP" | sha512sum --check
unzip -q "$RUNNER_TEMP/$GODOT_ZIP" -d ~/godot
mv ~/godot/Godot_v${GODOT_VERSION}-stable_linux.x86_64 ~/godot/godot
mv "$HOME/godot/Godot_v${GODOT_VERSION}-stable_linux.x86_64" "$HOME/godot/godot"
chmod +x ~/godot/godot

- name: Run checks
Expand Down Expand Up @@ -92,7 +92,7 @@ jobs:
"https://github.com/godotengine/godot/releases/download/${GODOT_VERSION}-stable/${GODOT_ZIP}"
echo "$GODOT_SHA512 $RUNNER_TEMP/$GODOT_ZIP" | sha512sum --check
unzip -q "$RUNNER_TEMP/$GODOT_ZIP" -d ~/godot
mv ~/godot/Godot_v${GODOT_VERSION}-stable_linux.x86_64 ~/godot/godot
mv "$HOME/godot/Godot_v${GODOT_VERSION}-stable_linux.x86_64" "$HOME/godot/godot"
chmod +x ~/godot/godot

- name: Cache Web export templates
Expand All @@ -107,7 +107,9 @@ jobs:
run: tools/install_godot_templates.sh

- name: Verify Web tooling
run: python3 -m unittest discover -s tools -p test_web_tools.py
run: |
python3 -m unittest discover -s tools -p test_web_tools.py
python3 -m unittest discover -s tools -p test_vercel_deploy.py

- name: Export browser bundles
timeout-minutes: 30
Expand All @@ -122,6 +124,7 @@ jobs:
uses: actions/upload-artifact@v6
with:
name: farlanding-web-${{ github.sha }}
overwrite: true
path: |
build/web/
tools/serve_web.py
Expand All @@ -131,7 +134,7 @@ jobs:

- uses: actions/setup-node@v6
with:
node-version: 24
node-version: 26
cache: npm
cache-dependency-path: tools/web_tests/package-lock.json

Expand Down Expand Up @@ -167,9 +170,103 @@ jobs:
uses: actions/upload-artifact@v6
with:
name: farlanding-web-evidence-${{ github.sha }}
overwrite: true
path: |
build/logs/
tools/web_tests/test-results/
tools/web_tests/playwright-report/
if-no-files-found: warn
retention-days: 14

deploy-production:
name: Deploy production
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: [web]
runs-on: ubuntu-latest
timeout-minutes: 25
permissions:
contents: read
actions: read
environment:
name: production
url: ${{ vars.VERCEL_PRODUCTION_URL }}
concurrency:
group: production-deploy
cancel-in-progress: false
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
steps:
- uses: actions/checkout@v7

- uses: actions/setup-node@v6
with:
node-version: 26
cache: npm
cache-dependency-path: tools/web_tests/package-lock.json

- name: Prepare the tested release for Vercel
env:
GH_TOKEN: ${{ github.token }}
run: |
python3 tools/prepare_vercel.py --repository "$GITHUB_REPOSITORY" \
--run-id "$GITHUB_RUN_ID" --commit "$GITHUB_SHA"

- name: Pull Vercel environment information
run: npx --yes vercel@65.16.0 pull --cwd .vercel-source --yes --environment=production --token="$VERCEL_TOKEN"

- name: Build the tested artifact on Vercel
id: deployment
env:
GH_TOKEN: ${{ github.token }}
run: |
npx --yes vercel@65.16.0 deploy --cwd .vercel-source --yes --prod --skip-domain \
--build-env "GH_TOKEN=$GH_TOKEN" --json --token="$VERCEL_TOKEN" > "$RUNNER_TEMP/deployment.json"
python3 - <<'PY'
import json, os
from pathlib import Path
deployment = json.loads((Path(os.environ['RUNNER_TEMP']) / 'deployment.json').read_text())['deployment']
assert deployment['readyState'] == 'READY'
with open(os.environ['GITHUB_OUTPUT'], 'a') as output:
output.write('url=' + deployment['url'] + '\n')
PY

- name: Install hosted browser test runtime
working-directory: tools/web_tests
run: |
npm ci
npx playwright install --with-deps chromium

- name: Verify the staged game before promotion
working-directory: tools/web_tests
env:
WEB_DEPLOYMENT_URL: ${{ steps.deployment.outputs.url }}
WEB_DEPLOYMENT_COMMIT: ${{ github.sha }}
WEB_DEPLOYMENT_BYPASS_SECRET: ${{ secrets.VERCEL_AUTOMATION_BYPASS_SECRET }}
run: npx playwright test --config playwright.deployment.config.cjs

- name: Promote production
env:
DEPLOYMENT_URL: ${{ steps.deployment.outputs.url }}
run: npx --yes vercel@65.16.0 promote "$DEPLOYMENT_URL" --yes --token="$VERCEL_TOKEN"

- name: Verify the public production domain
working-directory: tools/web_tests
env:
WEB_DEPLOYMENT_URL: ${{ vars.VERCEL_PRODUCTION_URL }}
WEB_DEPLOYMENT_COMMIT: ${{ github.sha }}
WEB_DEPLOYMENT_PUBLIC_ONLY: '1'
run: npx playwright test --config playwright.deployment.config.cjs

- name: Upload hosted browser evidence
if: always()
uses: actions/upload-artifact@v6
with:
name: farlanding-production-evidence-${{ github.sha }}
overwrite: true
path: |
tools/web_tests/test-results/
tools/web_tests/playwright-report/
if-no-files-found: ignore
retention-days: 14
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@ node_modules/
tools/web_tests/test-results/
tools/web_tests/playwright-report/
.audit/
.vercel/
.vercel-source/
39 changes: 37 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ at this origin. Wait for the saved confirmation before reloading. Denied storage
or failed persistence produces a warning. Clearing site data or changing the port
or origin can make existing progress unavailable. Fullscreen requires a user
click. Leaving the tab pauses the mission; resume explicitly when returning.
Keyboard and mouse are required. Mobile and hosting are outside this milestone.
Keyboard and mouse are required. Mobile controls remain outside this milestone.

Every successful CI `web` job publishes `farlanding-web-<commit>` in the run's
Artifacts section. Download and extract it, then run the same manifest verification
Expand All @@ -152,7 +152,7 @@ and every bundle file's hash. It describes required HTTP headers; a ZIP has none

### Browser checks

Node **20+** is needed only for testing. Export diagnostics separately:
Node **26.x** is needed only for testing and deployment. Export diagnostics separately:

```sh
tools/export.sh Web WebDiagnostics
Expand All @@ -174,3 +174,38 @@ opt-in to avoid competing with software WebGL on CI runners. The broad mission
matrix also runs from CI's manual **Run workflow** action. `WebDiagnostics` is for
testing only; play the release under `build/web`. Browser versions and acceptance
evidence are tracked in [the Web results](docs/WEB_CI_RESULTS.md).

### Production deployment

Successful pushes to `main` deploy to [Farlanding](https://farlanding.vercel.app)
after native checks and browser gameplay pass. Pull requests and manual test runs
do not deploy. Both the CI Node steps and the Vercel project use Node 26.x.

The Vercel Hobby project uses the same team and CI-controlled deployment policy as
Space Explorer. Its Git auto-deploys are disabled. Because the exported game exceeds
Hobby's 100 MB CLI source-upload limit, CI uploads a small build script referring
to that run's tested GitHub artifact by ID and digest. Vercel resolves a fresh
download URL when its build starts, using that CI job's short-lived GitHub token
as a build-only secret with repository contents/Actions read permissions. It is
never stored in source files or public assets and is not forwarded to artifact
storage. The build verifies GitHub's archive digest and the release's complete
file inventory and commit. Godot is not rebuilt on Vercel.

CI first creates an unaliased production deployment and runs real browser input
against it, including the isolation headers and WebAssembly MIME type. Only a
passing staged game is promoted. CI then checks the public production domain
without authentication. Use that stable domain for play so browser saves stay at
the same origin across deployments.

Repository secrets: `VERCEL_TOKEN`, `VERCEL_ORG_ID`, `VERCEL_PROJECT_ID`, and
`VERCEL_AUTOMATION_BYPASS_SECRET`. The last one lets the staged browser check pass
Vercel's preview protection; traces are disabled when it is used so request
credentials are not recorded. `VERCEL_PRODUCTION_URL` is a repository variable.
The deployment uses the GitHub `production` environment and Vercel CLI 65.16.0.

Deploy through CI rather than rebuilding an old deployment in the Vercel dashboard:
the job's GitHub token expires when that job finishes. Rerun the deployment job in
a push-to-`main` workflow while its tested artifact is retained, or rerun that entire push workflow
to create a fresh artifact. Manual **Run workflow** runs remain test-only.
Existing ready deployments can still be promoted or rolled back without
downloading the source artifact again.
5 changes: 5 additions & 0 deletions docs/AUDIO_STYLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -1001,6 +1001,11 @@ and the details are random. Across four runs the calm scenes spanned 1.5–2.6 L
The finale's peak varied most (−1.9 to −5.0 dBFS): it is the campaign's one unducked climax, with
explosions landing on top of the cue.

CI qualification now seeds the audio service, music director, and ambience director's
own RNGs and restarts score/ambience playback for each scene. A global seed alone did
not control random bed offsets or prior playback state. The 3.5/4.5 LU limits stay
unchanged; this fixture reset does not change the game's production mix or variety.

Fixed in Phase 9:

- **Hollow Meridian calm was 2.5–4 LU hot** (−25.5 against about −28.5). Its `calm` state played
Expand Down
32 changes: 30 additions & 2 deletions docs/WEB_CI_RESULTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,33 @@ limit of the first browser milestone, not a passing result for the original targ
A human listening receipt, a complete campaign playthrough in Safari, and GPU /
WebAssembly memory-leak qualification have not been represented as completed.
Automated mixer evidence supplements those checks; it is not a fabricated listener.
Hosting, mobile controls, PWA, cloud saves, and branch-protection changes remain
outside this milestone.
Mobile controls, PWA, cloud saves, and branch-protection changes remain outside
this milestone. Hosting is covered by the Vercel follow-up below.

## Vercel follow-up

The Vercel Hobby project and both projects' CI Node steps use Node 26.x. A staged
Farlanding deployment successfully retrieved the green `7d92b3e` CI artifact,
verified its archive digest and all nine release files, and served the full game
without a plan upgrade. The hosted browser smoke reached a Kessel landing with no
browser errors. It reproduced missing audio worklets on a protected deployment
until the automation bypass cookie was enabled; the corrected check passed.

Review also caught GitHub's one-minute artifact-redirect lifetime. Preparation now
stores only artifact identity and digest; the build resolves the URL immediately
before downloading with a job-scoped read-only token. Six deployment-tool tests
cover that handoff and rejection of incorrect/dirty/diagnostic/corrupt releases.
The revised download path also retrieved and verified the real nine-file artifact
locally. It does not forward authorization to the redirected storage host.

A native CI run failed the calm-scene comparison at 3.517 LU against its 3.5 LU
limit. The mix fixture seeded only the global RNG, leaving the directors' private
RNGs and bed playback positions uncontrolled. It now resets those scene inputs
without changing production audio or the loudness limits. The full native audio
suite passed 416 tests / 6,374 assertions with no engine errors or warnings; the
calm-scene spread was approximately 2.6 LU.

Production promotion is wired into CI after native/browser gates and the staged
hosted game check. A separate unauthenticated check verifies the stable production
domain after promotion. See [ADR 0020](adr/0020-vercel-ci-deployment.md) for the
artifact handoff, headers, credentials, and rollback constraints.
3 changes: 2 additions & 1 deletion docs/adr/0019-web-runtime.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ player-node playback enums use a different numbering.
Serve on loopback for development. Threaded exports need a secure context and
`Cross-Origin-Opener-Policy: same-origin` plus
`Cross-Origin-Embedder-Policy: require-corp`. Localhost qualifies. Future hosting
must supply these headers and the WebAssembly MIME type. No hosting is configured.
must supply these headers and the WebAssembly MIME type. Vercel CI deployment is
described in [ADR 0020](0020-vercel-ci-deployment.md).

## Reasons

Expand Down
34 changes: 34 additions & 0 deletions docs/adr/0020-vercel-ci-deployment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# 0020. Publish the tested Web artifact through Vercel CI

Deploy production only after the native and browser jobs succeed on a push to
`main`. Disable Vercel Git auto-deploys, use a GitHub production environment,
and serialize main runs so older production deployments cannot overtake newer
ones. Node 26.x and Vercel CLI 65.16.0 are pinned for the deployment tooling.

Use the existing Vercel Hobby team, matching Space Explorer's CI ownership of
production. The Web release is about 168 MB, above Hobby's 100 MB CLI source-upload
limit. A small source upload therefore contains only the static hosting config,
a Python build script, and the current CI run's artifact identity and digest.
Resolve GitHub's one-minute download redirect inside the build, immediately before
fetching it. Pass only the deployment job's temporary, repository-scoped GitHub
token as a build-only secret, with contents/Actions read permissions. Never put it
in source files, public assets, or requests to redirected artifact storage.
The build checks GitHub's immutable artifact archive SHA-256, the expected source
commit, clean release preset, and the complete
exported file inventory. Only `build/web` becomes public. Godot is not rebuilt.

Serve COOP `same-origin`, COEP `require-corp`, and `application/wasm` on the engine
binary. Revalidate stable filenames rather than caching them immutably across
production releases. Missing paths remain missing; there is no SPA fallback.

Create a production deployment with `--skip-domain`, exercise the actual hosted
game, then promote only after that check passes. The staged check uses an
automation bypass header and cookie so audio worklets can load on a protected
deployment. Do not record traces containing the bypass credential. After
promotion, check the production domain without authentication. Keep play and
saves on the stable production origin.

The GitHub job token expires after the job. CI supplies a fresh token for each
deployment; dashboard source rebuilds of old deployments are not supported.
Existing ready deployments can be promoted or rolled back. Do not upgrade the Vercel plan or add an asset
hosting service for this workflow.
11 changes: 11 additions & 0 deletions game/tests/audio/test_final_mix.gd
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,18 @@ var _vent: Node3D


func before_each() -> void:
Events.campaign_screen_changed.emit(&"")
# These directors own RNGs: the global seed does not control bed offsets,
# wandering or one-shot variations. Start each scene from the same mix state.
Audio.ambience().stop()
Audio.ambience()._use_set(AmbienceSet.new())
await wait_process_frames(1)
seed(1729)
Audio._rng.seed = 1729
Audio._last_variation.clear()
Audio.ambience()._rng.seed = 1729
Audio.music()._rng.seed = 1729
Audio.play_score(load(KESSEL_SCORE) as MusicScore)
_mix = MixScene.new()
# Positional players only mix with a camera in the viewport (the game always
# has one; the test runner does not).
Expand Down
51 changes: 51 additions & 0 deletions tools/prepare_vercel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env python3
"""Create a tiny Vercel source upload referring to this run's immutable artifact."""
import argparse
import json
import os
from pathlib import Path
import re
import shutil
import subprocess
from urllib.request import Request, urlopen

ROOT = Path(__file__).resolve().parent.parent


def prepare(repository, run_id, commit, output):
token = os.environ.get('GH_TOKEN') or os.environ.get('GITHUB_TOKEN')
if not token:
token = subprocess.check_output(['gh', 'auth', 'token'], text=True).strip()
headers = {'Authorization': f'Bearer {token}', 'Accept': 'application/vnd.github+json',
'X-GitHub-Api-Version': '2022-11-28'}
api = f'https://api.github.com/repos/{repository}/actions'
request = Request(f'{api}/runs/{run_id}/artifacts?per_page=100', headers=headers)
with urlopen(request, timeout=30) as response:
artifacts = json.load(response)['artifacts']
matches = [item for item in artifacts if item['name'] == f'farlanding-web-{commit}'
and not item['expired'] and str(item['workflow_run']['id']) == str(run_id)]
if len(matches) != 1:
raise ValueError('Expected exactly one release artifact from the current run')
artifact = matches[0]
digest = artifact.get('digest', '')
if not re.fullmatch(r'sha256:[0-9a-f]{64}', digest):
raise ValueError('GitHub did not supply a SHA-256 archive digest')
output.mkdir(parents=True, exist_ok=True)
shutil.copyfile(ROOT / 'vercel.json', output / 'vercel.json')
shutil.copyfile(ROOT / 'tools/vercel_build.py', output / 'build.py')
(output / '.vercelignore').write_text('public/\n.vercel/\n')
(output / 'artifact.json').write_text(json.dumps({
'repository': repository, 'artifact_id': artifact['id'],
'sha256': digest.removeprefix('sha256:'), 'commit': commit,
}))
Comment thread
vriesd marked this conversation as resolved.
Resolved
print(f'Prepared Vercel source for tested artifact {artifact["id"]} at {commit}')


if __name__ == '__main__':
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--repository', required=True)
parser.add_argument('--run-id', required=True)
parser.add_argument('--commit', required=True)
parser.add_argument('--output', type=Path, default=Path('.vercel-source'))
args = parser.parse_args()
prepare(args.repository, args.run_id, args.commit, args.output)
Loading
Loading