mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-23 16:41:35 +01:00
Pull requests no longer wait on the upload that sends Free Tests results to Trunk. It now runs on its own after Free Tests finishes. The quick test tier's flaky passes now reach Trunk too, so a test that fails once and passes on its retry shows up there wherever it ran. Nothing to do: no required check changes, and the upload still never affects whether a check passes. Refs: GST-3303 Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> Review-Finding: p1/red-team#1 reader=red-team Review-Finding: p1/red-team#2 reader=red-team
1020 lines
53 KiB
YAML
1020 lines
53 KiB
YAML
name: Free Tests
|
|
|
|
# A single duration-balanced plan covers every free test exactly once. Each
|
|
# shard runs serially on its own machine; the aggregate requires every receipt
|
|
# and strict outcome. Tree-mutating files, when present, get a separate machine.
|
|
#
|
|
# Deliberately SECRETLESS: free tests make no API calls, so this lane gets no
|
|
# provider keys at all — least privilege, and fork PRs get real test signal
|
|
# here (the eval matrix skips fork PRs because repository secrets can't reach
|
|
# them). test/free-tests-workflow-wiring.test.ts fails CI if a secret sneaks in.
|
|
# The one exception is TRUNK_API_TOKEN in the trunk-dynamic-ci observer, which
|
|
# runs no pull-request code and nothing depends on it (see that job). The Trunk
|
|
# Flaky Tests uploader runs after this workflow, in trunk-flaky-tests.yml.
|
|
#
|
|
# This is a REQUIRED check from day one (branch protection lists it). If it's
|
|
# red, fix or quarantine-with-issue — don't make it advisory; an advisory lane
|
|
# is permanent false comfort.
|
|
#
|
|
# Local `bun run test` still uses the existing bounded process pool.
|
|
#
|
|
# One full suite per tree (GSTA-156, docs/pregate.md#ci-reuse). The aggregate
|
|
# uploads a `tested-tree` record (tree.json) only after strict verification
|
|
# passes. A push to main first runs `reuse`: when the merged pull request's
|
|
# head has the pushed tree and a green pull_request or workflow_dispatch run of
|
|
# this workflow verifies (lib/run-evidence.ts), every suite job is skipped and
|
|
# the aggregate links that run instead. A pull request run reuses too, but
|
|
# only a run the pull request cannot control: a green push or dispatch run on
|
|
# main, or a dispatch run on its own branch, at the merge commit's exact tree,
|
|
# while the merge commit leaves this file, scripts/ci-tree-reuse.ts and
|
|
# lib/run-evidence.ts byte-identical to main. A pull_request run is never a
|
|
# source. Any other answer, a reuse failure included, runs every job as before.
|
|
# Dispatch runs never consume; reused runs never upload a record, so they are
|
|
# never reused.
|
|
|
|
on:
|
|
pull_request:
|
|
branches: [main]
|
|
# Also on main pushes: two individually-green PRs can merge into a red
|
|
# main; without this nothing runs the free suite on main until the next PR.
|
|
push:
|
|
branches: [main]
|
|
workflow_dispatch:
|
|
inputs:
|
|
free_runner:
|
|
description: 'Runner-sizing experiments only: Ubicloud runner for the free-suite shards (ubicloud-standard-2, -4, -8 or -16; empty keeps FREE_SUITE_RUNNER). Never cite such a run as a PR or train Free Tests result.'
|
|
type: string
|
|
default: ''
|
|
free_shards:
|
|
description: 'Runner-sizing experiments only: shard count, 1-40 (empty keeps FREE_SUITE_SHARDS)'
|
|
type: string
|
|
default: ''
|
|
free_jobs:
|
|
description: 'Runner-sizing experiments only: sub-shards per CI shard (--shard-jobs), 1-8 (empty keeps FREE_SUITE_JOBS)'
|
|
type: string
|
|
default: ''
|
|
|
|
# The one source of the free-suite runner, shard count and sub-shards per
|
|
# shard. pull_request and push runs never see workflow_dispatch inputs, so
|
|
# free-plan resolves these (or a dispatch override) into outputs and the plan
|
|
# that free-suite reads. FREE_SUITE_JOBS is k in `--ci-plan --shard-jobs k`:
|
|
# each shard runs min(k, its parallel files) sandboxed sub-shards side by side
|
|
# (scripts/lib/shard-jobs.ts); the exclusive host-state shard stays one child.
|
|
# FREE_SUITE_SETUP_SECONDS is a free-suite job's time outside the "Run free
|
|
# suite" step. --ci-plan adds it to each shard's runner wall and flaky-retry
|
|
# wall to emit that shard's job timeout (#3850), so GitHub never kills a job
|
|
# before the runner can name a hung file. Measured over 110 free-suite jobs in
|
|
# PR runs 41467261350..41478988224: p50 60 s, p90 80 s, max 142 s.
|
|
env:
|
|
FREE_SUITE_RUNNER: ubicloud-standard-8
|
|
FREE_SUITE_SHARDS: '10'
|
|
FREE_SUITE_JOBS: '4'
|
|
FREE_SUITE_SETUP_SECONDS: '300'
|
|
|
|
# Keyed on the PR number, not head_ref: a bare branch name carries no fork
|
|
# prefix, so same-name branches from two forks would share one group and a
|
|
# push to fork B's PR would cancel fork A's in-flight REQUIRED check.
|
|
concurrency:
|
|
group: free-tests-${{ github.event.pull_request.number || github.run_id }}
|
|
cancel-in-progress: true
|
|
|
|
# Least privilege: this job executes PR-controlled code (install lifecycle
|
|
# scripts + the test suite), so the GITHUB_TOKEN gets read-only contents and
|
|
# the checkout doesn't persist it into .git/config.
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
# Trunk Dynamic CI, LEARNING ONLY (GST-1400). Trunk records, for each
|
|
# same-repository pull request, whether it would have run or skipped the two
|
|
# named jobs below; every job still runs. It is an observer by construction:
|
|
# no job needs it, no condition reads it, it re-exports no outputs, so a mode
|
|
# change in Trunk's dashboard cannot skip anything here. It is the one job in
|
|
# this workflow that sees a secret, so it checks out nothing and runs no
|
|
# pull-request code: one pinned action and nothing else, with no GITHUB_TOKEN
|
|
# scopes (Trunk reads the diff itself) and telemetry off. It never fails the
|
|
# run: the action never fails its step, the step continues on error and has
|
|
# its own timeout, and the job continues on error. Fork pull requests, pushes
|
|
# and dispatches skip the job; a missing token skips its step. Review:
|
|
# docs/TESTING_INTERNALS.md.
|
|
trunk-dynamic-ci:
|
|
name: Trunk Dynamic CI (learning only)
|
|
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
|
|
runs-on: ubuntu-24.04
|
|
timeout-minutes: 5
|
|
continue-on-error: true
|
|
permissions: {}
|
|
env:
|
|
TRUNK_API_TOKEN: ${{ secrets.TRUNK_API_TOKEN }}
|
|
steps:
|
|
- name: Record Trunk's verdicts for free-suite and macos-named-regressions (nothing reads them)
|
|
if: env.TRUNK_API_TOKEN != ''
|
|
timeout-minutes: 3
|
|
continue-on-error: true
|
|
uses: trunk-io/dynamic-ci@5bcddbf3615c2b032c21eed1b514c91164bda4a8 # v0.1.7
|
|
env:
|
|
TRUNK_DISABLE_TELEMETRY: 'true'
|
|
with:
|
|
token: ${{ env.TRUNK_API_TOKEN }}
|
|
job-keys: free-suite,macos-named-regressions
|
|
github-token: ''
|
|
enable-annotation: 'true'
|
|
|
|
# Main pushes and pull requests only, and the one job with actions: read (it
|
|
# reads this repository's runs and their tested-tree artifacts). Every suite
|
|
# job below runs unless this job succeeded and reused a run; a skipped or
|
|
# failed reuse job runs them all. Their conditions start with !cancelled()
|
|
# because a skipped needed job would otherwise skip its dependents on dispatch
|
|
# runs, where reuse never runs.
|
|
reuse:
|
|
if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'pull_request'
|
|
runs-on: ubuntu-24.04
|
|
timeout-minutes: 5
|
|
permissions:
|
|
contents: read
|
|
actions: read
|
|
outputs:
|
|
reused: ${{ steps.find.outputs.reused }}
|
|
run_id: ${{ steps.find.outputs.run_id }}
|
|
run_url: ${{ steps.find.outputs.run_url }}
|
|
tree: ${{ steps.find.outputs.tree }}
|
|
steps:
|
|
# On a pull request this checks out main (the base commit), never the
|
|
# merge commit, so the reuse script, its imports and the run profile are
|
|
# main's code; bun ignores any .env or bunfig.toml in the checkout.
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
|
with:
|
|
ref: ${{ github.event.pull_request.base.sha || github.sha }}
|
|
persist-credentials: false
|
|
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
|
|
with:
|
|
bun-version: 1.4.2
|
|
- id: find
|
|
name: Find a green run of this exact tree that this run's pull request cannot control
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
run: bun --no-env-file --config=/dev/null run scripts/ci-tree-reuse.ts find --workflow free-tests.yml --profile ci-reuse/free-tests --pull-request
|
|
|
|
# R81 (docs/pregate.md#docs-only): a pull request whose every path is human docs runs
|
|
# docs-lane instead of the suites. The classifier is the base branch's copy, run on
|
|
# the merge commit against its first parent; any error reads as not docs-only.
|
|
docs-scope:
|
|
if: github.event_name == 'pull_request'
|
|
runs-on: ubuntu-24.04
|
|
timeout-minutes: 5
|
|
outputs:
|
|
docs_only: ${{ steps.scope.outputs.docs_only }}
|
|
tests: ${{ steps.scope.outputs.tests }}
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
|
with:
|
|
fetch-depth: 2
|
|
persist-credentials: false
|
|
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
|
|
with:
|
|
bun-version: 1.4.2
|
|
- id: scope
|
|
uses: ./.github/actions/docs-scope
|
|
|
|
docs-lane:
|
|
needs: docs-scope
|
|
if: needs.docs-scope.result == 'success' && needs.docs-scope.outputs.docs_only == 'true'
|
|
runs-on: ubuntu-24.04
|
|
timeout-minutes: 10
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
|
with:
|
|
fetch-depth: 2
|
|
persist-credentials: false
|
|
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
|
|
with:
|
|
bun-version: 1.4.2
|
|
- name: Install frozen dependencies
|
|
run: bun install --frozen-lockfile --ignore-scripts
|
|
- name: Configure git identity (docs reader tests init temp repos)
|
|
run: |
|
|
git config --global user.email "free-tests-ci@gstack.test"
|
|
git config --global user.name "Free Tests CI"
|
|
git config --global init.defaultBranch main
|
|
- name: Links on the lines this pull request added resolve
|
|
run: git diff --name-only -z --diff-filter=AMR HEAD^1 HEAD -- '*.md' | xargs -0 -r bun run scripts/check-doc-links.ts --base HEAD^1
|
|
- name: Run the tests that read docs by directory
|
|
env:
|
|
DOCS_TESTS: ${{ needs.docs-scope.outputs.tests }}
|
|
run: |
|
|
set -eu
|
|
if [ -z "$DOCS_TESTS" ]; then exit 0; fi
|
|
read -ra tests <<< "$DOCS_TESTS"
|
|
bun --no-env-file test --timeout=30000 "${tests[@]}"
|
|
|
|
# The planner runs beside reuse and docs-scope instead of after them, so the
|
|
# shards wait for one round of small jobs, not two (GST-3303: the second
|
|
# round cost 21 s at p50 and 363 s at p95 of GitHub queue). It only plans:
|
|
# free-suite and the aggregate still read reuse and docs-scope, so a reused
|
|
# main push or a docs-only pull request runs no shard. On those runs the
|
|
# plan and its artifact are unused; scripts/lib/ci-history.ts reads a run
|
|
# whose only artifact is free-plan as one that ran no shard.
|
|
free-plan:
|
|
runs-on: ubuntu-24.04
|
|
timeout-minutes: 5
|
|
outputs:
|
|
matrix: ${{ steps.plan.outputs.matrix }}
|
|
runner: ${{ steps.plan.outputs.runner }}
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
|
with:
|
|
persist-credentials: false
|
|
# Full history: the seed ratchet compares the allowlist with its
|
|
# merge-base copy, which a depth-1 checkout cannot read. Blobless:
|
|
# that copy is fetched on demand, and a failed read fails the ratchet.
|
|
fetch-depth: 0
|
|
filter: blob:none
|
|
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
|
|
with:
|
|
bun-version: 1.4.2
|
|
- id: plan
|
|
name: Inventory and balance the complete free suite
|
|
# Warns in the job summary when more than 5 files are unseeded.
|
|
env:
|
|
RUNNER_OVERRIDE: ${{ inputs.free_runner }}
|
|
SHARDS_OVERRIDE: ${{ inputs.free_shards }}
|
|
JOBS_OVERRIDE: ${{ inputs.free_jobs }}
|
|
run: |
|
|
set -euo pipefail
|
|
runner="${RUNNER_OVERRIDE:-$FREE_SUITE_RUNNER}"
|
|
shards="${SHARDS_OVERRIDE:-$FREE_SUITE_SHARDS}"
|
|
jobs="${JOBS_OVERRIDE:-$FREE_SUITE_JOBS}"
|
|
case "$runner" in
|
|
ubicloud-standard-2|ubicloud-standard-4|ubicloud-standard-8|ubicloud-standard-16) ;;
|
|
*) echo "::error::free_runner '$runner' is not ubicloud-standard-2, -4, -8 or -16"; exit 1 ;;
|
|
esac
|
|
case "$shards" in
|
|
''|*[!0-9]*) echo "::error::free_shards '$shards' is not a whole number"; exit 1 ;;
|
|
esac
|
|
if [ "$shards" -lt 1 ] || [ "$shards" -gt 40 ]; then echo "::error::free_shards $shards is outside 1-40"; exit 1; fi
|
|
case "$jobs" in
|
|
''|*[!0-9]*) echo "::error::free_jobs '$jobs' is not a whole number"; exit 1 ;;
|
|
esac
|
|
if [ "$jobs" -lt 1 ] || [ "$jobs" -gt 8 ]; then echo "::error::free_jobs $jobs is outside 1-8"; exit 1; fi
|
|
if [ "$runner" != "$FREE_SUITE_RUNNER" ] || [ "$shards" != "$FREE_SUITE_SHARDS" ] || [ "$jobs" != "$FREE_SUITE_JOBS" ]; then
|
|
echo "- Runner-sizing experiment: $shards shards on $runner at $jobs sub-shards each (defaults $FREE_SUITE_SHARDS on $FREE_SUITE_RUNNER at $FREE_SUITE_JOBS); not a PR or train Free Tests result" >> "$GITHUB_STEP_SUMMARY"
|
|
fi
|
|
matrix=$(bun run scripts/test-free-shards.ts --ci-plan "$RUNNER_TEMP/free-plan.json" --shards "$shards" --shard-jobs "$jobs" --job-setup-seconds "$FREE_SUITE_SETUP_SECONDS")
|
|
echo "matrix=$matrix" >> "$GITHUB_OUTPUT"
|
|
echo "runner=$runner" >> "$GITHUB_OUTPUT"
|
|
- name: Seed growth ratchet (60 s ceiling, shrink-only allowlist)
|
|
run: |
|
|
GSTACK_FREE_SEED_BASE="$(git merge-base HEAD origin/main)" bun test test/free-seed-ratchet.test.ts
|
|
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
|
|
with:
|
|
name: free-plan
|
|
path: ${{ runner.temp }}/free-plan.json
|
|
if-no-files-found: error
|
|
|
|
cso-macos-launcher:
|
|
needs: [reuse, docs-scope]
|
|
if: ${{ !cancelled() && (needs.reuse.result != 'success' || needs.reuse.outputs.reused != 'true') && !(needs.docs-scope.result == 'success' && needs.docs-scope.outputs.docs_only == 'true') }}
|
|
runs-on: macos-latest
|
|
timeout-minutes: 15
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
|
with:
|
|
persist-credentials: false
|
|
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
|
|
with:
|
|
bun-version: 1.4.2
|
|
- name: Install helper dependencies
|
|
run: bun install --frozen-lockfile --ignore-scripts
|
|
- name: Build and sign the native macOS startup boundary
|
|
run: bun run build:cso
|
|
- name: Exercise hardened-runtime startup and environment scrubbing
|
|
run: bun run test:cso:macos
|
|
env:
|
|
GSTACK_CSO_MACOS_TESTS: "1"
|
|
- name: Build browser lifecycle prerequisites
|
|
env:
|
|
GSTACK_STRICT_BUILD: '1'
|
|
run: |
|
|
bunx playwright install chromium
|
|
bun run build
|
|
- name: Exercise native agent ownership and linked settings
|
|
env:
|
|
TMPDIR: /tmp
|
|
run: |
|
|
files=(browse/test/terminal-agent-lifecycle.test.ts browse/test/terminal-agent-native-observation.test.ts browse/test/terminal-agent-watchdog.test.ts browse/test/server-embedder-terminal-port.test.ts browse/test/server-factory.test.ts test/gstack-settings-hook-symlink.test.ts test/gstack-settings-hook-schema-aware.test.ts)
|
|
for file in "${files[@]}"; do test -f "$file"; done
|
|
bun test "${files[@]}"
|
|
|
|
# Named regressions that only reproduce on macOS's default temp root:
|
|
# $TMPDIR sits under /var/folders and /var is a symlink to /private/var, so
|
|
# code that compares a realpath with an unresolved path passes on Linux's
|
|
# /tmp and fails here (#2982). TMPDIR is deliberately left at the runner's
|
|
# default, and the job fails if that layout is not symlinked. It also sources
|
|
# the Codex probe from zsh, macOS's default shell (#3024; no paid call), and
|
|
# runs ubi-runner under macOS's bsdtar and one-true-awk (#3680, #3679).
|
|
macos-named-regressions:
|
|
needs: [reuse, docs-scope]
|
|
if: ${{ !cancelled() && (needs.reuse.result != 'success' || needs.reuse.outputs.reused != 'true') && !(needs.docs-scope.result == 'success' && needs.docs-scope.outputs.docs_only == 'true') }}
|
|
runs-on: macos-latest
|
|
timeout-minutes: 20
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
|
with:
|
|
persist-credentials: false
|
|
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
|
|
with:
|
|
bun-version: 1.4.2
|
|
- name: Install dependencies
|
|
run: bun install --frozen-lockfile --ignore-scripts
|
|
- name: Build browser prerequisites
|
|
env:
|
|
GSTACK_STRICT_BUILD: '1'
|
|
run: |
|
|
bunx playwright install chromium
|
|
bun run build
|
|
- name: Configure git identity (tests init temp repos)
|
|
run: |
|
|
git config --global user.email "free-tests-ci@gstack.test"
|
|
git config --global user.name "Free Tests CI"
|
|
git config --global init.defaultBranch main
|
|
- name: Codex probe selects a model from zsh, run as a command and sourced (macOS default shell, no paid call)
|
|
working-directory: ${{ runner.temp }}
|
|
run: |
|
|
set -euo pipefail
|
|
run="$(zsh -c '"$GITHUB_WORKSPACE/bin/gstack-codex-probe" select-model exec' 2>&1)"
|
|
printf '%s\n' "$run"
|
|
printf '%s\n' "$run" | grep -E '^CODEX_SEL: [A-Za-z0-9._:/-]+$'
|
|
out="$(zsh -c 'source "$GITHUB_WORKSPACE/bin/gstack-codex-probe" && _gstack_codex_select_model exec' 2>&1)"
|
|
printf '%s\n' "$out"
|
|
printf '%s\n' "$out" | grep -E '^CODEX_MODEL: [A-Za-z0-9._:/-]+ \(exec; source: '
|
|
- name: Run the named macOS regressions on the default temp root
|
|
run: |
|
|
set -euo pipefail
|
|
tmp="${TMPDIR:-/tmp}"
|
|
resolved="$(realpath "$tmp")"
|
|
echo "temp root: $tmp -> $resolved"
|
|
test "$resolved" != "${tmp%/}"
|
|
files=(test/gstack-design-detect.test.ts browse/test/chromium-profile-isolation.test.ts test/cso-git-hardening.test.ts test/plan-count-file-permission.test.ts test/spec-quality-gate-secret-sink.test.ts test/gstack-memory-ingest.test.ts test/regression-issue3024-zsh-sourced-helpers.test.ts test/codex-probe-subcommands.test.ts browse/test/proxy-env-daemon.test.ts browse/test/proxy-direct-launch-args.test.ts test/regression-issue3680-ubicloud-bsd-userland.test.ts)
|
|
for file in "${files[@]}"; do test -f "$file"; done
|
|
bun test --timeout=30000 "${files[@]}"
|
|
|
|
cso-windows-launcher:
|
|
needs: [reuse, docs-scope]
|
|
if: ${{ !cancelled() && (needs.reuse.result != 'success' || needs.reuse.outputs.reused != 'true') && !(needs.docs-scope.result == 'success' && needs.docs-scope.outputs.docs_only == 'true') }}
|
|
runs-on: windows-latest
|
|
timeout-minutes: 15
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
|
with:
|
|
persist-credentials: false
|
|
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
|
|
with:
|
|
bun-version: 1.4.2
|
|
- name: Install helper dependencies
|
|
run: bun install --frozen-lockfile --ignore-scripts
|
|
- name: Build the native Windows startup boundary from Git Bash
|
|
shell: bash
|
|
run: bun run build:cso
|
|
- name: Exercise native startup, environment, and argument forwarding
|
|
run: bun run test:cso:windows
|
|
env:
|
|
GSTACK_CSO_WINDOWS_TESTS: "1"
|
|
- name: Upload #2894 lease diagnostics
|
|
if: failure()
|
|
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
|
|
with:
|
|
name: cso-lease-diagnostics-a${{ github.run_attempt }}
|
|
path: ${{ runner.temp }}/cso-lease-diagnostics
|
|
if-no-files-found: ignore
|
|
retention-days: 14
|
|
|
|
cso-docker-integration:
|
|
needs: [reuse, docs-scope]
|
|
if: ${{ !cancelled() && (needs.reuse.result != 'success' || needs.reuse.outputs.reused != 'true') && !(needs.docs-scope.result == 'success' && needs.docs-scope.outputs.docs_only == 'true') }}
|
|
runs-on: ubuntu-24.04
|
|
timeout-minutes: 20
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
|
with:
|
|
persist-credentials: false
|
|
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
|
|
with:
|
|
bun-version: 1.4.2
|
|
- name: Require local Docker containment prerequisites
|
|
# A missing daemon is a failed gate, never a skipped integration test.
|
|
run: |
|
|
command -v docker
|
|
docker --host unix:///var/run/docker.sock info
|
|
command -v cc
|
|
- name: Install helper dependencies
|
|
run: bun install --frozen-lockfile --ignore-scripts
|
|
- name: Compile trusted CSO helper and watchdog
|
|
run: bun run build:cso
|
|
# Only the file that can run here: the node-lifecycle and stack-cold
|
|
# files need GSTACK_CSO_TEST_STACK images and run in the CSO runtime
|
|
# workflows (test:cso:docker), so in this job they always skipped.
|
|
- name: Run CSO Docker integration gate
|
|
run: |
|
|
bun test --max-concurrency 1 test/cso-docker-integration.test.ts
|
|
env:
|
|
GSTACK_CSO_DOCKER_TESTS: "1"
|
|
DOCKER_HOST: unix:///var/run/docker.sock
|
|
|
|
typecheck:
|
|
needs: [reuse, docs-scope]
|
|
if: ${{ !cancelled() && (needs.reuse.result != 'success' || needs.reuse.outputs.reused != 'true') && !(needs.docs-scope.result == 'success' && needs.docs-scope.outputs.docs_only == 'true') }}
|
|
runs-on: ubuntu-24.04
|
|
timeout-minutes: 10
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
|
with:
|
|
persist-credentials: false
|
|
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
|
|
with:
|
|
bun-version: 1.4.2
|
|
- name: Install dependencies
|
|
run: bun install --frozen-lockfile --ignore-scripts
|
|
- name: Typecheck product code (zero errors)
|
|
run: bun run typecheck
|
|
- name: Test-code type-debt ratchet
|
|
run: bun run typecheck:test
|
|
- name: CSO source formatting
|
|
run: bun run format:cso:check
|
|
|
|
# Capy machines install GSTACK_BUN_DEFAULT (bin/gstack-bun-version.sh) when
|
|
# no project pin decides, above the 1.4.2 minimum every other lane pins, so
|
|
# the quick tier also runs on it. Its pin equals GSTACK_BUN_DEFAULT;
|
|
# test/bun-version-drift.test.ts checks this job exists and agrees.
|
|
quick-bun-default:
|
|
needs: [reuse, docs-scope]
|
|
if: ${{ !cancelled() && (needs.reuse.result != 'success' || needs.reuse.outputs.reused != 'true') && !(needs.docs-scope.result == 'success' && needs.docs-scope.outputs.docs_only == 'true') }}
|
|
runs-on: ubicloud-standard-8
|
|
timeout-minutes: 30
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
|
with:
|
|
persist-credentials: false
|
|
# Push runs check out main with `checkout -B main`, so the clone holds a
|
|
# local main; PR runs are a detached merge ref and train dispatches sit on
|
|
# train/<nonce>. A fixture that made its own main passed its PR and then
|
|
# failed every push to main (#3237, run 38999168852). Give every run the
|
|
# push layout so a PR run catches what the main push would.
|
|
- name: Match main's local branch layout on PR and dispatch runs
|
|
if: github.ref != 'refs/heads/main'
|
|
run: git checkout -q -B main
|
|
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
|
|
with:
|
|
bun-version: 1.4.4
|
|
- name: Install dependencies
|
|
run: bun install --frozen-lockfile
|
|
- name: Read the Playwright version for the browser cache key
|
|
id: playwright
|
|
run: echo "version=$(node -p 'require("playwright-core/package.json").version')" >> "$GITHUB_OUTPUT"
|
|
# Keyed on the Playwright version, which fixes the Chromium revision: a
|
|
# lockfile bump that keeps Playwright reuses the browser, and a Playwright
|
|
# bump never restores a stale revision.
|
|
- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
|
|
with:
|
|
path: ~/.cache/ms-playwright
|
|
key: linux-playwright-chromium-${{ steps.playwright.outputs.version }}
|
|
# --with-deps fetches about 38 MB of system packages from archive.ubuntu.com
|
|
# on every run. On 2026-11-19 that mirror served some runners at 85 to
|
|
# 280 kB/s: 17 of 456 first attempts hit the 5-minute limit, and each
|
|
# retry then died in seconds on the dpkg lock that the killed attempt's
|
|
# apt-get still held (run 44485949701). apt now waits for that lock, and
|
|
# the packages one run downloads are cached under a key made from the
|
|
# runner's installed package list and the Playwright version, so a later
|
|
# run on the same image installs them with dpkg and never touches the mirror.
|
|
- name: Make apt wait for its lock and keep the packages it downloads
|
|
run: printf 'DPkg::Lock::Timeout "240";\nAPT::Keep-Downloaded-Packages "true";\nBinary::apt::APT::Keep-Downloaded-Packages "true";\n' | sudo tee /etc/apt/apt.conf.d/90gstack-ci > /dev/null
|
|
- name: Fingerprint the runner's installed system packages
|
|
id: apt_base
|
|
env:
|
|
PLAYWRIGHT_VERSION: ${{ steps.playwright.outputs.version }}
|
|
run: echo "cache_key=linux-apt-debs-$(dpkg-query -W -f='${binary:Package}=${Version}\n' | sha256sum | cut -c1-16)-playwright-$PLAYWRIGHT_VERSION" >> "$GITHUB_OUTPUT"
|
|
- name: Restore the system packages an earlier run downloaded
|
|
id: apt_cache
|
|
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
|
|
with:
|
|
path: ~/.cache/gstack-apt-debs
|
|
key: ${{ steps.apt_base.outputs.cache_key }}
|
|
- name: Install the cached system packages without the network
|
|
id: apt_offline
|
|
if: steps.apt_cache.outputs.cache-hit == 'true'
|
|
continue-on-error: true
|
|
run: sudo dpkg -i "$HOME"/.cache/gstack-apt-debs/*.deb
|
|
# The cache restores the browser; --with-deps still runs apt for system
|
|
# libraries. On 2026-10-21 apt stalled on an archive.ubuntu.com fetch and
|
|
# held free-suite (12) for the whole 20-minute job timeout (run
|
|
# 39641712129). Each attempt gets 5 minutes (a warm install takes about
|
|
# 15 s) and the install alone is retried once. This retries infrastructure,
|
|
# never a test.
|
|
- name: Install Playwright Chromium
|
|
id: playwright_install
|
|
timeout-minutes: 5
|
|
continue-on-error: true
|
|
env:
|
|
SYSTEM_PACKAGES: ${{ steps.apt_offline.outcome }}
|
|
run: |
|
|
if [ "$SYSTEM_PACKAGES" = success ]; then npx playwright install chromium; else npx playwright install --with-deps chromium; fi
|
|
- name: Retry the Playwright Chromium install once
|
|
if: steps.playwright_install.outcome == 'failure'
|
|
timeout-minutes: 5
|
|
env:
|
|
SYSTEM_PACKAGES: ${{ steps.apt_offline.outcome }}
|
|
run: |
|
|
if [ "$SYSTEM_PACKAGES" = success ]; then npx playwright install chromium; else npx playwright install --with-deps chromium; fi
|
|
- name: Configure the bundled Chromium sandbox helper
|
|
run: |
|
|
set -euo pipefail
|
|
chrome=$(bun -e 'import { chromium } from "playwright"; import { realpathSync } from "node:fs"; console.log(realpathSync(chromium.executablePath()))')
|
|
case "$chrome" in
|
|
"$HOME"/.cache/ms-playwright/chromium-*/chrome-linux*/chrome) ;;
|
|
*) echo "Unexpected Chromium installation path" >&2; exit 1 ;;
|
|
esac
|
|
helper="${chrome%/*}/chrome_sandbox"
|
|
installed="${chrome%/*}/chrome-sandbox"
|
|
test -f "$helper" && test ! -L "$helper"
|
|
sudo install -T -o root -g root -m 4755 "$helper" "$installed"
|
|
# Runner image 20261026.1.0 keeps kernel.apparmor_restrict_unprivileged_userns=1
|
|
# but loads no AppArmor profiles, so Chromium's namespace sandbox aborts with
|
|
# "credentials.cc: Permission denied". Grant user namespaces to this one
|
|
# resolved binary, the way Ubuntu's own chrome profile does.
|
|
- name: Let the bundled Chromium create its sandbox namespaces
|
|
run: |
|
|
set -euo pipefail
|
|
chrome=$(bun -e 'import { chromium } from "playwright"; import { realpathSync } from "node:fs"; console.log(realpathSync(chromium.executablePath()))')
|
|
case "$chrome" in
|
|
"$HOME"/.cache/ms-playwright/chromium-*/chrome-linux*/chrome) ;;
|
|
*) echo "Unexpected Chromium installation path" >&2; exit 1 ;;
|
|
esac
|
|
profile=/etc/apparmor.d/gstack-playwright-chromium
|
|
printf 'abi <abi/4.0>,\ninclude <tunables/global>\nprofile gstack-playwright-chromium %s flags=(unconfined) {\n userns,\n}\n' "$chrome" | sudo tee "$profile" > /dev/null
|
|
sudo apparmor_parser -r "$profile"
|
|
- name: Install Xvfb + X11 utilities + gate tools
|
|
run: sudo apt-get install -y --no-install-recommends xvfb x11-utils poppler-utils fonts-noto-color-emoji zsh
|
|
- name: Keep the system packages this run downloaded
|
|
id: apt_keep
|
|
if: steps.apt_cache.outputs.cache-hit != 'true'
|
|
run: |
|
|
mkdir -p ~/.cache/gstack-apt-debs
|
|
if compgen -G '/var/cache/apt/archives/*.deb' > /dev/null; then
|
|
cp /var/cache/apt/archives/*.deb ~/.cache/gstack-apt-debs/
|
|
echo "save=true" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
- name: Save the system packages for the next run on this image
|
|
if: steps.apt_keep.outputs.save == 'true'
|
|
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
|
|
with:
|
|
path: ~/.cache/gstack-apt-debs
|
|
key: ${{ steps.apt_cache.outputs.cache-primary-key }}
|
|
- name: Configure git identity (tests init temp repos)
|
|
run: |
|
|
git config --global user.email "free-tests-ci@gstack.test"
|
|
git config --global user.name "Free Tests CI"
|
|
git config --global init.defaultBranch main
|
|
git config --global --add safe.directory '*'
|
|
- name: Generate host SKILL.md outputs (.agents, .factory)
|
|
run: bun run gen:skill-docs --host all
|
|
- name: Vendor xterm assets into the extension
|
|
run: bun run vendor:xterm
|
|
- name: Build server-node bundle (loaded by browse cli imports)
|
|
run: bash browse/scripts/build-node-server.sh
|
|
- name: Build gate binaries (make-pdf e2e gates)
|
|
run: bun run build:gates
|
|
- name: Build trusted CSO helper used by free contract tests
|
|
run: bun run build:cso
|
|
- name: Run the quick free tier on the install-default Bun
|
|
env:
|
|
GSTACK_FREE_RETRY_FLAKY: "1"
|
|
GSTACK_FLAKE_LEDGER: ${{ runner.temp }}/flake-ledger.jsonl
|
|
run: xvfb-run -a bun run test:quick --junit-dir "$RUNNER_TEMP/quick-junit"
|
|
|
|
# Kept for trunk-flaky-tests.yml, which uploads them to Trunk as the
|
|
# bun-default variant after the run, so a flaky pass here reaches Trunk
|
|
# as well as the flake ledger (GST-3303).
|
|
- name: Upload the quick tier's JUnit reports
|
|
if: always()
|
|
timeout-minutes: 3
|
|
continue-on-error: true
|
|
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
|
|
with:
|
|
name: quick-junit
|
|
path: ${{ runner.temp }}/quick-junit/*.xml
|
|
if-no-files-found: ignore
|
|
retention-days: 7
|
|
|
|
# The quick tier retries a failing file once too, so its flaky passes go
|
|
# in the same flake-ledger-* series the aggregate summarizes and
|
|
# test:health counts. Before GST-3303 this ledger was written and lost.
|
|
- name: Upload the quick tier's flake ledger
|
|
if: always()
|
|
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
|
|
with:
|
|
name: flake-ledger-quick
|
|
path: ${{ runner.temp }}/flake-ledger.jsonl
|
|
if-no-files-found: ignore
|
|
retention-days: 90
|
|
|
|
free-suite:
|
|
name: free-suite (${{ matrix.shard }})
|
|
needs: [free-plan, reuse, docs-scope]
|
|
if: ${{ !cancelled() && needs.free-plan.result == 'success' && (needs.reuse.result != 'success' || needs.reuse.outputs.reused != 'true') && !(needs.docs-scope.result == 'success' && needs.docs-scope.outputs.docs_only == 'true') }}
|
|
runs-on: ${{ needs.free-plan.outputs.runner }}
|
|
# Per shard, from the plan: runner wall + flaky retry + setup (#3850).
|
|
timeout-minutes: ${{ matrix.timeout_minutes }}
|
|
strategy:
|
|
fail-fast: false
|
|
max-parallel: 20
|
|
matrix: ${{ fromJSON(needs.free-plan.outputs.matrix) }}
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
|
with:
|
|
persist-credentials: false
|
|
|
|
# Push runs check out main with `checkout -B main`, so the clone holds a
|
|
# local main; PR runs are a detached merge ref and train dispatches sit on
|
|
# train/<nonce>. A fixture that made its own main passed its PR and then
|
|
# failed every push to main (#3237, run 38999168852). Give every run the
|
|
# push layout so a PR run catches what the main push would.
|
|
- name: Match main's local branch layout on PR and dispatch runs
|
|
if: github.ref != 'refs/heads/main'
|
|
run: git checkout -q -B main
|
|
|
|
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
|
|
with:
|
|
bun-version: 1.4.2
|
|
|
|
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8
|
|
with:
|
|
name: free-plan
|
|
path: ${{ runner.temp }}
|
|
|
|
- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
|
|
with:
|
|
path: ~/.bun/install/cache
|
|
key: linux-bun-${{ hashFiles('bun.lock') }}
|
|
# A lockfile bump starts from the previous cache instead of cold.
|
|
restore-keys: |
|
|
linux-bun-
|
|
|
|
- name: Install dependencies
|
|
run: bun install --frozen-lockfile
|
|
|
|
- name: Read the Playwright version for the browser cache key
|
|
id: playwright
|
|
run: echo "version=$(node -p 'require("playwright-core/package.json").version')" >> "$GITHUB_OUTPUT"
|
|
|
|
# Keyed on the Playwright version, which fixes the Chromium revision: a
|
|
# lockfile bump that keeps Playwright reuses the browser, and a Playwright
|
|
# bump never restores a stale revision.
|
|
- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
|
|
with:
|
|
path: ~/.cache/ms-playwright
|
|
key: linux-playwright-chromium-${{ steps.playwright.outputs.version }}
|
|
|
|
# --with-deps fetches about 38 MB of system packages from archive.ubuntu.com
|
|
# on every run. On 2026-11-19 that mirror served some runners at 85 to
|
|
# 280 kB/s: 17 of 456 first attempts hit the 5-minute limit, and each
|
|
# retry then died in seconds on the dpkg lock that the killed attempt's
|
|
# apt-get still held (run 44485949701). apt now waits for that lock, and
|
|
# the packages one run downloads are cached under a key made from the
|
|
# runner's installed package list and the Playwright version, so a later
|
|
# run on the same image installs them with dpkg and never touches the mirror.
|
|
- name: Make apt wait for its lock and keep the packages it downloads
|
|
run: printf 'DPkg::Lock::Timeout "240";\nAPT::Keep-Downloaded-Packages "true";\nBinary::apt::APT::Keep-Downloaded-Packages "true";\n' | sudo tee /etc/apt/apt.conf.d/90gstack-ci > /dev/null
|
|
- name: Fingerprint the runner's installed system packages
|
|
id: apt_base
|
|
env:
|
|
PLAYWRIGHT_VERSION: ${{ steps.playwright.outputs.version }}
|
|
run: echo "cache_key=linux-apt-debs-$(dpkg-query -W -f='${binary:Package}=${Version}\n' | sha256sum | cut -c1-16)-playwright-$PLAYWRIGHT_VERSION" >> "$GITHUB_OUTPUT"
|
|
- name: Restore the system packages an earlier run downloaded
|
|
id: apt_cache
|
|
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
|
|
with:
|
|
path: ~/.cache/gstack-apt-debs
|
|
key: ${{ steps.apt_base.outputs.cache_key }}
|
|
- name: Install the cached system packages without the network
|
|
id: apt_offline
|
|
if: steps.apt_cache.outputs.cache-hit == 'true'
|
|
continue-on-error: true
|
|
run: sudo dpkg -i "$HOME"/.cache/gstack-apt-debs/*.deb
|
|
# The cache restores the browser; --with-deps still runs apt for system
|
|
# libraries. On 2026-10-21 apt stalled on an archive.ubuntu.com fetch and
|
|
# held free-suite (12) for the whole 20-minute job timeout (run
|
|
# 39641712129). Each attempt gets 5 minutes (a warm install takes about
|
|
# 15 s) and the install alone is retried once. This retries infrastructure,
|
|
# never a test.
|
|
- name: Install Playwright Chromium
|
|
id: playwright_install
|
|
timeout-minutes: 5
|
|
continue-on-error: true
|
|
env:
|
|
SYSTEM_PACKAGES: ${{ steps.apt_offline.outcome }}
|
|
run: |
|
|
if [ "$SYSTEM_PACKAGES" = success ]; then npx playwright install chromium; else npx playwright install --with-deps chromium; fi
|
|
|
|
- name: Retry the Playwright Chromium install once
|
|
if: steps.playwright_install.outcome == 'failure'
|
|
timeout-minutes: 5
|
|
env:
|
|
SYSTEM_PACKAGES: ${{ steps.apt_offline.outcome }}
|
|
run: |
|
|
if [ "$SYSTEM_PACKAGES" = success ]; then npx playwright install chromium; else npx playwright install --with-deps chromium; fi
|
|
|
|
- name: Configure the bundled Chromium sandbox helper
|
|
run: |
|
|
set -euo pipefail
|
|
chrome=$(bun -e 'import { chromium } from "playwright"; import { realpathSync } from "node:fs"; console.log(realpathSync(chromium.executablePath()))')
|
|
case "$chrome" in
|
|
"$HOME"/.cache/ms-playwright/chromium-*/chrome-linux*/chrome) ;;
|
|
*) echo "Unexpected Chromium installation path" >&2; exit 1 ;;
|
|
esac
|
|
helper="${chrome%/*}/chrome_sandbox"
|
|
installed="${chrome%/*}/chrome-sandbox"
|
|
test -f "$helper" && test ! -L "$helper"
|
|
sudo install -T -o root -g root -m 4755 "$helper" "$installed"
|
|
test "$(stat -c '%u:%a' "$installed")" = '0:4755'
|
|
cmp -s "$helper" "$installed"
|
|
# Runner image 20261026.1.0 keeps kernel.apparmor_restrict_unprivileged_userns=1
|
|
# but loads no AppArmor profiles, so Chromium's namespace sandbox aborts with
|
|
# "credentials.cc: Permission denied". Grant user namespaces to this one
|
|
# resolved binary, the way Ubuntu's own chrome profile does.
|
|
- name: Let the bundled Chromium create its sandbox namespaces
|
|
run: |
|
|
set -euo pipefail
|
|
chrome=$(bun -e 'import { chromium } from "playwright"; import { realpathSync } from "node:fs"; console.log(realpathSync(chromium.executablePath()))')
|
|
case "$chrome" in
|
|
"$HOME"/.cache/ms-playwright/chromium-*/chrome-linux*/chrome) ;;
|
|
*) echo "Unexpected Chromium installation path" >&2; exit 1 ;;
|
|
esac
|
|
profile=/etc/apparmor.d/gstack-playwright-chromium
|
|
printf 'abi <abi/4.0>,\ninclude <tunables/global>\nprofile gstack-playwright-chromium %s flags=(unconfined) {\n userns,\n}\n' "$chrome" | sudo tee "$profile" > /dev/null
|
|
sudo apparmor_parser -r "$profile"
|
|
|
|
# Headed-browser tests (handoff, extension sidepanel DOM) need a real
|
|
# DISPLAY — first Linux run failed with Playwright's "launched a headed
|
|
# browser without an XServer" banner. xvfb-run below provides it;
|
|
# x11-utils ships xdpyinfo for display probing. poppler-utils ships
|
|
# pdftotext/pdffonts/pdftoppm for the make-pdf e2e gates;
|
|
# fonts-noto-color-emoji is the emoji-gate's render font (playwright
|
|
# --with-deps usually installs it, but the gate must not depend on a
|
|
# transitive package list). Fonts must land BEFORE the first browse
|
|
# daemon launch — Chromium snapshots fontconfig at startup. zsh is not
|
|
# in the runner image; without it the bash+zsh portability arms (#2669)
|
|
# skip instead of running.
|
|
- name: Install Xvfb + X11 utilities + gate tools
|
|
run: sudo apt-get install -y --no-install-recommends xvfb x11-utils poppler-utils fonts-noto-color-emoji zsh
|
|
- name: Keep the system packages this run downloaded
|
|
id: apt_keep
|
|
if: steps.apt_cache.outputs.cache-hit != 'true'
|
|
run: |
|
|
mkdir -p ~/.cache/gstack-apt-debs
|
|
if compgen -G '/var/cache/apt/archives/*.deb' > /dev/null; then
|
|
cp /var/cache/apt/archives/*.deb ~/.cache/gstack-apt-debs/
|
|
echo "save=true" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
- name: Save the system packages for the next run on this image
|
|
if: steps.apt_keep.outputs.save == 'true'
|
|
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
|
|
with:
|
|
path: ~/.cache/gstack-apt-debs
|
|
key: ${{ steps.apt_cache.outputs.cache-primary-key }}
|
|
|
|
- name: Configure git identity (tests init temp repos)
|
|
run: |
|
|
git config --global user.email "free-tests-ci@gstack.test"
|
|
git config --global user.name "Free Tests CI"
|
|
git config --global init.defaultBranch main
|
|
# Some tests run git against the checkout itself; CI checkouts can be
|
|
# owned by a different uid than the runner user.
|
|
git config --global --add safe.directory '*'
|
|
|
|
- name: Generate host SKILL.md outputs (.agents, .factory)
|
|
# Golden-file tests read generated host outputs that are gitignored.
|
|
run: bun run gen:skill-docs --host all
|
|
|
|
- name: Vendor xterm assets into the extension
|
|
# extension/lib/xterm* are gitignored (vendored from npm at build
|
|
# time). Without them the sidepanel's terminal script bails and the
|
|
# sidepanel DOM tests time out waiting on init that never happens.
|
|
run: bun run vendor:xterm
|
|
|
|
- name: Build server-node bundle (loaded by browse cli imports)
|
|
run: bash browse/scripts/build-node-server.sh
|
|
|
|
# Narrowed gate build: the make-pdf e2e gates probe make-pdf/dist/pdf,
|
|
# browse/dist/browse, and the diagram-render bundle, then self-skip when
|
|
# absent — which made them silently skip on Linux for their whole life
|
|
# (this lane never built binaries). Full `bun run build` compiles five
|
|
# binaries and would add ~60-90s to the ONLY required check; the gates
|
|
# need exactly these three artifacts.
|
|
- name: Build gate binaries (make-pdf e2e gates)
|
|
run: bun run build:gates
|
|
|
|
- name: Build trusted CSO helper used by free contract tests
|
|
run: bun run build:cso
|
|
|
|
# Runner sizing: the suite runs one test at a time, so a shard needs RAM
|
|
# and disk more than cores. Sample both while it runs and report the peak.
|
|
- name: Start the memory and disk sampler
|
|
run: |
|
|
cat > "$RUNNER_TEMP/sample-resources.sh" <<'EOF'
|
|
while :; do
|
|
printf '%s %s %s\n' "$(date +%s)" "$(free -k | awk 'NR == 2 { print $3 }')" "$(df -Pk / | awk 'NR == 2 { print $4 }')"
|
|
sleep 2
|
|
done
|
|
EOF
|
|
nohup sh "$RUNNER_TEMP/sample-resources.sh" > "$RUNNER_TEMP/resources.log" 2>&1 &
|
|
|
|
# GSTACK_EXPECT_BINARIES=1 arms make-pdf/test/e2e/ci-prereqs.test.ts:
|
|
# if a future edit drops the gate build (or poppler), the lane FAILS
|
|
# instead of the gates silently self-skipping back to false green.
|
|
- name: Run free suite
|
|
run: xvfb-run -a bun run test:free --ci-run "$RUNNER_TEMP/free-plan.json" --shard ${{ matrix.shard }} --result "$RUNNER_TEMP/free-results/shard-${{ matrix.shard }}.json" --junit-dir "$RUNNER_TEMP/free-junit"
|
|
env:
|
|
GSTACK_EXPECT_BINARIES: "1"
|
|
# WS1 flake telemetry: a single timing flake must not red the only
|
|
# required lane — the runner's attribution-gated retry pass (cap 5,
|
|
# truncation veto) re-runs failing files once, serially, and a
|
|
# clean retry downgrades to a LOUD flaky-pass. Every flaky-pass is
|
|
# appended to the ledger (single writer: the parent runner) and
|
|
# uploaded below, so repeat offenders are an enumerable series —
|
|
# recorded and ranked, never masked. Pinned by
|
|
# test/free-tests-workflow-wiring.test.ts.
|
|
GSTACK_FREE_RETRY_FLAKY: "1"
|
|
GSTACK_FLAKE_LEDGER: ${{ runner.temp }}/flake-ledger.jsonl
|
|
|
|
- name: Report peak memory and minimum free disk
|
|
if: always()
|
|
run: |
|
|
if [ ! -s "$RUNNER_TEMP/resources.log" ]; then echo "RESOURCES: no samples"; exit 0; fi
|
|
awk '{ if ($2 > used) used = $2; if (free == "" || $3 < free) free = $3 } END { printf "RESOURCES: peak_used_mib=%d min_free_disk_mib=%d samples=%d\n", used / 1024, free / 1024, NR }' "$RUNNER_TEMP/resources.log" | tee -a "$GITHUB_STEP_SUMMARY"
|
|
|
|
- name: Upload strict shard result
|
|
if: always()
|
|
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
|
|
with:
|
|
name: free-result-${{ matrix.shard }}
|
|
path: ${{ runner.temp }}/free-results/*.json
|
|
if-no-files-found: error
|
|
|
|
# bun's JUnit report from every child of this shard, the flaky retry
|
|
# included. Only trunk-flaky-tests.yml reads it; no verdict does.
|
|
- name: Upload shard JUnit reports
|
|
if: always()
|
|
timeout-minutes: 3
|
|
continue-on-error: true
|
|
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
|
|
with:
|
|
name: free-junit-${{ matrix.shard }}
|
|
path: ${{ runner.temp }}/free-junit/*.xml
|
|
if-no-files-found: ignore
|
|
retention-days: 7
|
|
|
|
# Uploaded unconditionally (not just on failure): a flaky-pass run is
|
|
# GREEN — that's the point — so its evidence must survive green runs.
|
|
- name: Upload flake ledger
|
|
if: always()
|
|
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
|
|
with:
|
|
name: flake-ledger-${{ matrix.shard }}
|
|
path: ${{ runner.temp }}/flake-ledger.jsonl
|
|
if-no-files-found: ignore
|
|
retention-days: 90
|
|
|
|
- name: Detect recovered failures for log retention
|
|
id: flake_spool
|
|
if: always()
|
|
run: |
|
|
if [ -s "$RUNNER_TEMP/flake-ledger.jsonl" ]; then
|
|
echo 'present=true' >> "$GITHUB_OUTPUT"
|
|
fi
|
|
|
|
# The quiet console omits assertion details. Preserve the original spool
|
|
# after a recovered retry too, so a green job retains its first failure.
|
|
- name: Upload shard logs on failure or recovered retry
|
|
if: failure() || steps.flake_spool.outputs.present == 'true'
|
|
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
|
|
with:
|
|
name: free-test-shard-logs-${{ matrix.shard }}
|
|
path: .context/free-test-logs/gstack-free-test-*.log
|
|
include-hidden-files: true
|
|
if-no-files-found: ignore
|
|
|
|
# Branch protection already requires the `free-tests` context. Keep that
|
|
# stable name as an always-running aggregate so every platform-specific CSO
|
|
# gate is merge-blocking without a separate branch-protection migration.
|
|
# Its first step picks one of two exclusive paths before any download: a
|
|
# verified reuse (main pushes and pull requests) links the reused run and passes; anything
|
|
# else takes the strict path below unchanged, which alone uploads tested-tree.
|
|
free-tests:
|
|
if: always()
|
|
needs: [reuse, docs-scope, docs-lane, free-suite, typecheck, quick-bun-default, cso-macos-launcher, macos-named-regressions, cso-windows-launcher, cso-docker-integration]
|
|
runs-on: ubuntu-24.04
|
|
timeout-minutes: 5
|
|
steps:
|
|
- name: Take the docs-only path for a docs-only pull request, or the reuse path only for a verified main-push or pull request reuse
|
|
id: route
|
|
env:
|
|
DOCS_SCOPE_RESULT: ${{ needs.docs-scope.result }}
|
|
DOCS_ONLY: ${{ needs.docs-scope.outputs.docs_only }}
|
|
DOCS_LANE_RESULT: ${{ needs.docs-lane.result }}
|
|
REUSE_RESULT: ${{ needs.reuse.result }}
|
|
REUSED: ${{ needs.reuse.outputs.reused }}
|
|
REUSE_RUN_ID: ${{ needs.reuse.outputs.run_id }}
|
|
REUSE_RUN_URL: ${{ needs.reuse.outputs.run_url }}
|
|
REUSE_TREE: ${{ needs.reuse.outputs.tree }}
|
|
run: |
|
|
set -eu
|
|
if [ "$DOCS_SCOPE_RESULT" = success ] && [ "$DOCS_ONLY" = true ]; then
|
|
test "$GITHUB_EVENT_NAME" = pull_request || { echo "::error::docs-only claimed on a $GITHUB_EVENT_NAME run"; exit 1; }
|
|
test "$DOCS_LANE_RESULT" = success || { echo "::error::docs-lane concluded $DOCS_LANE_RESULT"; exit 1; }
|
|
echo 'Docs-only pull request: the docs lane passed and the suites were skipped; this run records no tested tree (docs/pregate.md#docs-only).' >> "$GITHUB_STEP_SUMMARY"
|
|
echo 'reused=false' >> "$GITHUB_OUTPUT"
|
|
echo 'skip=true' >> "$GITHUB_OUTPUT"
|
|
exit 0
|
|
fi
|
|
if [ "$REUSE_RESULT" != success ] || [ "$REUSED" != true ]; then
|
|
echo 'reused=false' >> "$GITHUB_OUTPUT"
|
|
echo 'skip=false' >> "$GITHUB_OUTPUT"
|
|
exit 0
|
|
fi
|
|
case "$GITHUB_EVENT_NAME:$GITHUB_REF" in
|
|
push:refs/heads/main|pull_request:refs/pull/*/merge) ;;
|
|
*) echo "::error::reuse claimed on a $GITHUB_EVENT_NAME run of $GITHUB_REF"; exit 1 ;;
|
|
esac
|
|
case "$REUSE_RUN_ID" in ''|*[!0-9]*) echo "::error::the reuse job named no run id"; exit 1 ;; esac
|
|
case "$REUSE_TREE" in ''|*[!0-9a-f]*) echo "::error::the reuse job named no tree"; exit 1 ;; esac
|
|
test "$REUSE_RUN_URL" = "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$REUSE_RUN_ID"
|
|
echo "Reused $REUSE_RUN_URL, which passed on tree $REUSE_TREE; this push ran no suite of its own." >> "$GITHUB_STEP_SUMMARY"
|
|
echo 'reused=true' >> "$GITHUB_OUTPUT"
|
|
echo 'skip=true' >> "$GITHUB_OUTPUT"
|
|
- name: Require the free suite, typecheck, the quick tier on the default Bun, macOS regressions, and every CSO platform gate
|
|
if: steps.route.outputs.skip != 'true'
|
|
env:
|
|
FREE_SUITE_RESULT: ${{ needs.free-suite.result }}
|
|
TYPECHECK_RESULT: ${{ needs.typecheck.result }}
|
|
QUICK_BUN_DEFAULT_RESULT: ${{ needs.quick-bun-default.result }}
|
|
CSO_MACOS_RESULT: ${{ needs.cso-macos-launcher.result }}
|
|
MACOS_REGRESSIONS_RESULT: ${{ needs.macos-named-regressions.result }}
|
|
CSO_WINDOWS_RESULT: ${{ needs.cso-windows-launcher.result }}
|
|
CSO_DOCKER_RESULT: ${{ needs.cso-docker-integration.result }}
|
|
run: |
|
|
set -eu
|
|
test "$FREE_SUITE_RESULT" = success
|
|
test "$TYPECHECK_RESULT" = success
|
|
test "$QUICK_BUN_DEFAULT_RESULT" = success
|
|
test "$CSO_MACOS_RESULT" = success
|
|
test "$MACOS_REGRESSIONS_RESULT" = success
|
|
test "$CSO_WINDOWS_RESULT" = success
|
|
test "$CSO_DOCKER_RESULT" = success
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
|
if: steps.route.outputs.skip != 'true'
|
|
with:
|
|
persist-credentials: false
|
|
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
|
|
if: steps.route.outputs.skip != 'true'
|
|
with:
|
|
bun-version: 1.4.2
|
|
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8
|
|
if: steps.route.outputs.skip != 'true'
|
|
with:
|
|
name: free-plan
|
|
path: ${{ runner.temp }}
|
|
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8
|
|
if: steps.route.outputs.skip != 'true'
|
|
with:
|
|
pattern: free-result-*
|
|
merge-multiple: true
|
|
path: ${{ runner.temp }}/free-results
|
|
# Per-shard ledgers land in their own subdirectories (all are named
|
|
# flake-ledger.jsonl). A green run is where a retried flake hides, so the
|
|
# summary runs before strict verification.
|
|
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8
|
|
if: steps.route.outputs.skip != 'true'
|
|
with:
|
|
pattern: flake-ledger-*
|
|
path: ${{ runner.temp }}/flake-ledgers
|
|
- name: Summarize flaky passes absorbed by the serial retry
|
|
if: steps.route.outputs.skip != 'true'
|
|
run: bun run scripts/test-health-report.ts flake-summary "$RUNNER_TEMP/flake-ledgers" >> "$GITHUB_STEP_SUMMARY"
|
|
- name: Require exact coverage and complete strict results
|
|
if: steps.route.outputs.skip != 'true'
|
|
run: bun run scripts/test-free-shards.ts --ci-verify "$RUNNER_TEMP/free-plan.json" --results "$RUNNER_TEMP/free-results"
|
|
# Only after strict verification passed, so a red or partial run never
|
|
# leaves a record; the reuse path never reaches here.
|
|
- name: Record the tested tree
|
|
if: steps.route.outputs.skip != 'true'
|
|
env:
|
|
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
|
|
SIZING_OVERRIDE: ${{ inputs.free_runner }}${{ inputs.free_shards }}${{ inputs.free_jobs }}
|
|
run: bun run scripts/ci-tree-reuse.ts record --plan "$RUNNER_TEMP/free-plan.json" --results "$RUNNER_TEMP/free-results" --os Linux,macOS,Windows --out "$RUNNER_TEMP/tested-tree/tree.json"
|
|
- name: Upload the tested tree
|
|
if: steps.route.outputs.skip != 'true'
|
|
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
|
|
with:
|
|
name: tested-tree
|
|
path: ${{ runner.temp }}/tested-tree/tree.json
|
|
if-no-files-found: error
|