Files
luxe/.github/workflows/ci.yml
Evan Whittaker fe34822d57 Browser tests run in Playwright's image, with nothing fetched from Ubuntu's mirror
The phone app's WebKit e2e also fetched its system libraries with `playwright install
--with-deps`, and a slow mirror ran that job out of time too. It now runs in Playwright's image
through `docker run`, with the workspace mounted at its own path so the test finds the `luxe` the
job built, after removing the runner's unused Android SDK to make room for the image. Both images
take their tag from the suite's lockfile, read in `what changed`, so a Dependabot bump of
Playwright moves its image with it.

In the image, site-cross's dev server came up on localhost and refused every probe: the server
and the client resolved localhost to different loopbacks. Both servers now bind 127.0.0.1 and
everything dials it. site-cross also reports why a dev server never answered: what the last probe
got and the server's last lines of output.
2026-10-23 18:25:04 -05:00

457 lines
20 KiB
YAML

# CI — the canonical quality gate + supply-chain checks on every push/PR.
#
# Mirrors the local gate (AGENTS.md / PROJECT.md) and adds `--locked` everywhere
# so a PR can never silently drift `Cargo.lock` (the core supply-chain guard).
# Third-party actions are pinned to commit SHAs (trailing `# vX` = the tag);
# Dependabot bumps the SHAs in the development repository. SHA-pinned `uses:`
# lines necessarily exceed 80 cols — that's expected.
name: CI
# A commit that touches only prose cannot change what the compiler or the suite says, and this
# workflow costs three runners (Windows sets the wall clock at ~10 minutes warm). The journal moves
# on nearly every iteration, so this is where the minutes actually go.
#
# So the workflow always starts, and `changes` (scripts/ci-changes.py) decides whether the jobs
# have work; a prose-only change skips them and `CI passed` still reports. That one job is what a
# ruleset requires: a required check that never starts, which is what a path filter on the trigger
# made of every job here, blocks a merge for good.
on:
# Re-run the gate on demand — how a timing change to this file gets measured against a warm cache,
# and how a run that failed on something external gets another go without an empty commit.
workflow_dispatch:
push:
branches: [master, main]
pull_request:
branches: [master, main]
# Least privilege: CI only needs to read the repo.
permissions:
contents: read
# Cancel superseded runs on the same ref to save CI minutes.
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
CARGO_NET_RETRY: "3"
# Nothing here opens a debugger, and the debug info CI does not use is expensive to produce — on
# Windows every one of the workspace's ~40 test binaries gets a PDB written beside it, which is a
# large part of what makes that runner the slowest thing in this file. Line tables keep a
# backtrace readable, and the `file:line` in an assertion comes from `#[track_caller]` rather than
# from here, so a failure still says where it happened.
CARGO_PROFILE_DEV_DEBUG: line-tables-only
CARGO_PROFILE_TEST_DEBUG: line-tables-only
jobs:
changes:
name: what changed
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
code: ${{ steps.diff.outputs.code }}
web_playwright: ${{ steps.playwright.outputs.web }}
app_playwright: ${{ steps.playwright.outputs.app }}
steps:
# Full history: the diff is taken from a merge base
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
- name: The classifier's own tests
run: python3 scripts/ci_changes_test.py
# A pull request diffs against its target, a push against the tip it replaced
- name: Whether anything but prose changed
id: diff
run: python3 scripts/ci-changes.py "$BASE" >> "$GITHUB_OUTPUT"
env:
BASE: ${{ github.event.pull_request.base.sha || github.event.before }}
# The browser suites run in Playwright's image, whose browsers only work with the Playwright
# that matches its tag. Read from the lockfiles, so a Dependabot bump moves the image with it
- name: Playwright versions
id: playwright
run: |
for suite in web=web app=crates/luxe-remote/app-tests; do
version=$(jq -r '.packages["node_modules/playwright"].version // empty' "${suite#*=}/package-lock.json")
[ -n "$version" ] || { echo "::error::no playwright in ${suite#*=}/package-lock.json"; exit 1; }
echo "${suite%%=*}=$version" >> "$GITHUB_OUTPUT"
done
gate:
name: build · test · clippy · fmt
needs: changes
if: needs.changes.outputs.code == 'true'
runs-on: ubuntu-latest
# A bound, because the absence of one cost real money. This job's test step has been hanging on
# `ubuntu-latest` — the same `cargo nextest run` that takes ~11s locally and passes on the macOS
# and Windows runners — and without a timeout it burned 50 minutes before the runner was lost, on
# every push and every Dependabot PR.
#
# It is also the diagnostic: on timeout GitHub signals the process, and nextest answers a signal
# by naming the tests still in flight. A capped run therefore says *which* test is stuck, which
# 50 minutes of silence and a discarded log never did.
timeout-minutes: 25
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install Rust (stable + clippy + rustfmt)
uses: dtolnay/rust-toolchain@4cda84d5c5c54efe2404f9d843567869ab1699d4 # stable
with:
components: clippy, rustfmt
- name: Cache cargo + target
uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
- name: Install nextest
uses: taiki-e/install-action@26e9283f268b880168bdbd2c545dfcd60ec2c6ab # v2.87.13
with:
tool: nextest
- name: Format check
run: cargo fmt --all --check
- name: Clippy (deny warnings)
run: cargo clippy --workspace --all-targets --locked -- -D warnings
- name: Build
run: cargo build --workspace --all-targets --locked
# One command again. The bisect that lived here found both hangs, and neither was slowness:
# `command_hooks` wrote a 256KB event into a hook that never reads its stdin with no bound on
# the write, and `program::kill_tree` then shelled out to `kill(1)` — a blocking spawn-and-wait
# on the async runtime's thread, through a `PATH` lookup, to a binary whose argument handling
# differs between util-linux and procps-ng. Ubuntu had the second `kill`; macOS and Arch did
# not, which is why exactly one runner hung.
- name: Test (nextest, ci profile)
run: cargo nextest run --workspace --profile ci --locked
# The example targets carry their own guards, and both `cargo test` and nextest skip them
# unless the target opts in with `test = true`. Belt and braces: run them explicitly, so a
# dropped opt-in cannot silently retire a generator's tests the way it already did once.
- name: Test (examples)
run: cargo test --workspace --examples --locked
# Everything under web/src/assets/generated is derived from this repo — the logotype from the
# art constants, the color tokens from the theme JSON, the screenshots and demos from the
# production view path. Stale assets are how a site quietly starts advertising a build that no
# longer exists, so regeneration is checked rather than trusted.
- name: Site assets are current
run: scripts/site-assets.sh --check
# The webfonts are subset to exactly the characters those assets draw, and they are rebuilt by
# hand — so an asset regenerated above can quietly outgrow them, and every character it gained
# renders as a box with its own codepoint printed inside. That shipped for nine days across
# thirty-one glyphs, every Nerd Font icon among them. This half needs no fonttools: the build
# records what it covered and this compares two sorted lists.
- name: Webfonts cover the assets
run: scripts/site-fonts.sh --check
# The part of docs/brand/voice.md a machine can judge: banned words and British spellings
- name: Voice
run: python3 scripts/voice-check.py
# The guide's links, frontmatter and, on rewritten pages, its voice. Its config examples,
# flags and slash commands are checked by `guide_check`, in the test step above.
- name: Guide
run: python3 scripts/docs-check.py
# Ratchets: a file or function over its limit fails unless allowlisted, and the lists only
# shrink. See the scripts' own docs for the limits.
- name: File sizes
run: python3 scripts/size-check.py
- name: Function lengths
run: python3 scripts/fn-length-check.py
# The docs are held where the comment passes left them: a broken intra-doc link, or a bare URL,
# is a warning rustdoc prints and nobody reads, so it fails here instead.
- name: Docs build clean
run: cargo doc --workspace --no-deps --locked
env:
RUSTDOCFLAGS: -D warnings
# The phone app's end-to-end test drives a real `luxe` (a session, the bridge, pairing) in
# WebKit, the only engine an iPhone has. It runs here because the Build step above already
# made `target/debug/luxe`: a job of its own would compile the workspace a second time, and
# the binary is too large to hand between jobs cheaply. The app's types and unit tests need
# no Rust, so they stay in `remote-app`.
#
# In Playwright's image, which has WebKit and the Ubuntu libraries it loads, rather than
# fetching those from Ubuntu's mirror on every run, where a slow mirror ran the job out of
# time. The workspace is mounted at its own path, so the test finds `target/debug/luxe`
# where it expects it, and runs as the runner's user, so what it writes stays cleanable.
#
# The build and test binaries leave the disk all but full, too full for the image, and
# `target/` can't give any back because the cache step saves it after this. The Android SDK
# the runner image ships is about 10 GB that nothing here uses.
- name: Phone app end to end (WebKit)
run: |
sudo rm -rf /usr/local/lib/android
df -h / | tail -1
docker run --rm --ipc=host --user "$(id -u):$(id -g)" -e HOME=/tmp/home \
-v "$GITHUB_WORKSPACE:$GITHUB_WORKSPACE" -w "$GITHUB_WORKSPACE/crates/luxe-remote/app-tests" \
"mcr.microsoft.com/playwright:v$PLAYWRIGHT-noble" sh -c 'npm ci && npm run e2e'
env:
PLAYWRIGHT: ${{ needs.changes.outputs.app_playwright }}
# Does it build and pass on the platforms nobody develops on? Linux above is the canonical gate —
# `fmt` is an answer about the source, not about the OS, so running it three times would only
# triple the noise from one rule. What cannot be known without a real runner is whether the code
# *compiles and behaves* off unix: a `cfg` that forgot Windows, a `$HOME` that isn't set, a POSIX
# shell that isn't there. That is what this job is for.
#
# Clippy does run per-platform, and for a reason the Windows audit turned up: a lint only ever sees
# the code its target compiles, so every `#[cfg(windows)]` block in the tree is invisible to the
# Linux gate. Without this, Windows-only code is the one code path that ships unlinted.
portability:
name: build · clippy · test (${{ matrix.os }})
needs: changes
if: needs.changes.outputs.code == 'true'
runs-on: ${{ matrix.os }}
# Windows sets the wall clock for the whole workflow: ~10 minutes warm and ~15 cold, building,
# linting and testing the whole workspace on the slowest runner. This is headroom over that, not
# a target.
timeout-minutes: 45
strategy:
# One platform's failure should not hide another's, and there are only two.
fail-fast: false
matrix:
os: [macos-latest, windows-latest]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install Rust (stable + clippy)
uses: dtolnay/rust-toolchain@4cda84d5c5c54efe2404f9d843567869ab1699d4 # stable
with:
components: clippy
# Defender scans every file rustc writes, and a Rust build writes a great many small ones. The
# runner is thrown away at the end of the job, so there is nothing here to protect — and an
# exclusion that cannot be set costs speed, not correctness, which is why this never fails the
# build.
- name: Exclude the build from Defender (Windows)
if: runner.os == 'Windows'
continue-on-error: true
shell: pwsh
run: |
Add-MpPreference -ExclusionPath $env:GITHUB_WORKSPACE, "$env:USERPROFILE\.cargo", $env:TEMP
# MSVC's `link.exe` is the slow half of a Windows build, and LLVM's drop-in replacement ships
# on the image. Resolved rather than assumed: if an image ever drops it the default linker is
# still there and this step is a no-op. Set before the cache step, because the cache key
# includes `RUSTFLAGS` and artifacts built by one linker must not be restored for the other.
- name: Link with lld (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
if (Get-Command lld-link.exe -ErrorAction SilentlyContinue) {
"RUSTFLAGS=-Clinker=lld-link.exe" >> $env:GITHUB_ENV
} else {
Write-Host "lld-link.exe is not on PATH; keeping the default MSVC linker"
}
- name: Cache cargo + target
uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
with:
key: ${{ matrix.os }}
- name: Install nextest
uses: taiki-e/install-action@26e9283f268b880168bdbd2c545dfcd60ec2c6ab # v2.87.13
with:
tool: nextest
- name: Build
run: cargo build --workspace --all-targets --locked
- name: Clippy (deny warnings)
run: cargo clippy --workspace --all-targets --locked -- -D warnings
# Unix-only fixtures (an executable shell stub, a re-exec dance) are `#![cfg(unix)]`, so on
# Windows this runs a smaller suite by construction rather than by exclusion.
- name: Test (nextest, ci profile)
run: cargo nextest run --workspace --profile ci --locked
# Does the workspace build on the `rust-version` it claims? `cargo install` on an older toolchain
# trusts that number, and it said 1.85 for months while the dependencies needed 1.88.
msrv:
name: msrv
needs: changes
if: needs.changes.outputs.code == 'true'
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install Rust (the declared rust-version)
uses: dtolnay/rust-toolchain@4cda84d5c5c54efe2404f9d843567869ab1699d4 # stable
with:
toolchain: "1.89"
- name: Cache cargo + target
uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
- name: Check
run: cargo +1.89 check --workspace --all-targets --locked
supply-chain:
name: cargo-deny
needs: changes
if: needs.changes.outputs.code == 'true'
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install Rust (stable)
uses: dtolnay/rust-toolchain@4cda84d5c5c54efe2404f9d843567869ab1699d4 # stable
- name: Install cargo-deny
uses: taiki-e/install-action@26e9283f268b880168bdbd2c545dfcd60ec2c6ab # v2.87.13
with:
tool: cargo-deny
# Single supply-chain gate: RustSec advisories, license allow-list, banned/
# duplicate crates, source registries — with deny.toml's documented ignores.
# (cargo-audit is omitted: it can't read those ignores, so it would
# false-fail on advisories we've already triaged.)
- name: cargo deny
run: cargo deny check
# The website. Its own job because it needs Node and nothing else does — and because a broken site
# build should not read as a broken harness.
website:
name: web build
needs: changes
if: needs.changes.outputs.code == 'true'
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: 24
cache: npm
cache-dependency-path: web/package-lock.json
- name: Install
run: npm ci
working-directory: web
- name: Types and templates
run: npm run check
working-directory: web
- name: Build
run: npm run build
working-directory: web
# `check` type-checks and `Build` emits files; neither one opens a page. This serves the built
# site the way Cloudflare does — `_headers`, so the real CSP — and asserts every page renders
# with no uncaught exceptions and no CSP violations. It exists because the demo players
# shipped blank: the player's WebAssembly was blocked and nothing was looking.
- name: Render check
run: ./scripts/site-check.sh --no-build
# One engine is not coverage. The render check above drives Chrome, and the site has since shipped
# two defects that Chrome could not see — a demo player whose dynamic import Firefox refused
# outright, and a layout that only Chrome's box metrics agreed with. WebKit is here for Safari,
# which nothing else in this pipeline speaks for.
#
# Inside Playwright's own image, which carries all three browsers and the Ubuntu libraries they
# load (WebKit wants Ubuntu's ICU and libxml2 sonames). `playwright install --with-deps` fetched
# those from Ubuntu's mirror on every run, about 120 MB, and a slow mirror held the job past its
# timeout. Its own job because the render check needs the runner's system Chrome, which the
# image doesn't have.
website-cross:
name: web cross-browser
needs: changes
if: needs.changes.outputs.code == 'true'
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/playwright:v${{ needs.changes.outputs.web_playwright }}-noble
# Firefox won't run as root in a home it doesn't own, and Actions' home is the runner user's
options: --user 1001
timeout-minutes: 15
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: 24
cache: npm
cache-dependency-path: web/package-lock.json
- name: Install
run: npm ci
working-directory: web
- name: Build
run: npm run build
working-directory: web
# The built site first — that is what a reader gets — then the dev server, which is where the
# Firefox failure actually lived and which no other job opens at all.
- name: Cross-browser (built)
run: node ../scripts/site-cross.mjs --built --require webkit
working-directory: web
- name: Cross-browser (dev server)
run: node ../scripts/site-cross.mjs --require webkit
working-directory: web
# The phone app `luxe remote` serves. It ships as written, with no build step, so this is where a
# type error gets caught: its JSDoc checked by tsc, and its folds unit-tested. The end-to-end
# test, one whole turn in WebKit, runs in `gate`, which already has a `luxe` built.
remote-app:
name: phone app
needs: changes
if: needs.changes.outputs.code == 'true'
runs-on: ubuntu-latest
timeout-minutes: 20
defaults:
run:
working-directory: crates/luxe-remote/app-tests
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: 24
cache: npm
cache-dependency-path: crates/luxe-remote/app-tests/package-lock.json
- name: Install
run: npm ci
- name: Types
run: npm run check
- name: Unit tests
run: npm test
# The one check a ruleset requires. A skipped job reports as passing but a skipped matrix job
# reports under no name a ruleset can hold, so this sums them up: it fails when any job failed or
# was cancelled, `changes` included, and passes when each one passed or had nothing to check.
passed:
name: CI passed
needs: [changes, gate, portability, msrv, supply-chain, website, website-cross, remote-app]
if: always()
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Every job passed or had nothing to check
run: |
echo "results: $RESULTS"
for result in $RESULTS; do
case "$result" in
success | skipped) ;;
*) echo "a job ended $result" >&2; exit 1 ;;
esac
done
env:
RESULTS: ${{ join(needs.*.result, ' ') }}