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
127 changes: 105 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ jobs:

# Every step below runs a justfile recipe, named after it. Reproduce any
# failure locally with the command in the step name — nothing about the gate
# lives only in this file.
gate:
name: Gate
# lives only in this file. `just check` is check-static plus the Go and UI
# unit suites; CI runs those three in parallel and adds the race suite.
static:
name: Static checks
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
Expand Down Expand Up @@ -72,8 +73,8 @@ jobs:
cache: npm
cache-dependency-path: site/package-lock.json

# `--help` installs the pinned binary without linting; `just check` runs
# the real thing, so local and CI share one invocation.
# `--help` installs the pinned binary without linting; `just check-static`
# runs the real thing, so local and CI share one invocation.
- uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0
with:
version: v2.14.0
Expand All @@ -82,22 +83,93 @@ jobs:
- name: just ui-deps
run: just ui-deps

# `just check` ends with site-build, which cannot run without these.
# Without it the gate fails as exit 127 — `astro: not found` — which reads
# check-static ends with site-build, which cannot run without these.
# Without it the job fails as exit 127 — `astro: not found` — which reads
# like a broken runner rather than a missing install.
- name: just site-deps
run: just site-deps

# fmt-check, lint, dependency audit, UI asset freshness, and
# backend/frontend tests.
# lefthook runs on push.
- name: just check
run: just check
# fmt-check, lint, dependency audit, UI asset freshness, docs and site.
- name: just check-static
run: just check-static

- name: just ui-test
run: just ui-test

# The plain suite keeps the allocation and memory ceilings that only build
# without the race detector (`//go:build !race`).
go-test:
name: Go tests
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
cache: true
cache-dependency-path: go.sum
- uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4
- name: just test
run: just test

race-shards:
name: Race shards
runs-on: ubuntu-24.04
outputs:
shards: ${{ steps.shards.outputs.shards }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- id: shards
run: echo "shards=$(bash scripts/go-race-shards.sh json)" >> "$GITHUB_OUTPUT"

# The slowest packages each get a runner; scripts/go-race-shards.sh owns the
# split, and its "rest" shard takes every other package.
go-race:
name: Go race (${{ matrix.shard }})
needs: race-shards
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
shard: ${{ fromJSON(needs.race-shards.outputs.shards) }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
cache: true
cache-dependency-path: go.sum
- uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4
- name: just test-race $(scripts/go-race-shards.sh ${{ matrix.shard }})
env:
SHARD: ${{ matrix.shard }}
run: |
set -euo pipefail
packages=$(bash scripts/go-race-shards.sh "$SHARD")
# shellcheck disable=SC2086 # one argument per package
just test-race $packages

# Re-runs the suite under the race detector. Kept out of `check` so the
# local pre-push hook stays fast.
- name: just test-race
run: just test-race
# The required check. A required job that is skipped counts as passed, so
# this one always runs and fails unless every part succeeded.
gate:
name: Gate
needs: [static, go-test, race-shards, go-race]
if: always()
runs-on: ubuntu-24.04
steps:
- env:
RESULTS: ${{ join(needs.*.result, ' ') }}
run: |
echo "results: ${RESULTS}"
for result in ${RESULTS}; do
[ "${result}" = success ] || exit 1
done

# The performance spec runs in its own job so neither group nears Playwright's
# 12-minute global timeout; one worker keeps its timings uncontended.
Expand All @@ -109,10 +181,21 @@ jobs:
fail-fast: false
matrix:
include:
- group: smoke and accessibility
slug: smoke
# The suite runs on one worker, and most of its time is the 1100
# viewport's accessibility and smoke specs, so each 1100 scheme gets a
# runner and the 1440 viewport shares one with the short MCP specs.
- group: smoke and accessibility (1100 light)
slug: smoke-1100-light
skip_performance: "1"
args: --project=app-1100-light
- group: smoke and accessibility (1100 dark)
slug: smoke-1100-dark
skip_performance: "1"
args: --project=app-1100-light --project=app-1100-dark --project=app-1440-light --project=app-1440-dark --project=mcp
args: --project=app-1100-dark
- group: smoke and accessibility (1440, MCP)
slug: smoke-1440-mcp
skip_performance: "1"
args: --project=app-1440-light --project=app-1440-dark --project=mcp
- group: performance
slug: performance
skip_performance: ""
Expand Down Expand Up @@ -140,7 +223,7 @@ jobs:
- name: just ui-deps
run: just ui-deps
- name: just e2e-browsers
if: matrix.slug == 'smoke' || matrix.slug == 'catalog'
if: startsWith(matrix.slug, 'smoke') || matrix.slug == 'catalog'
run: just e2e-browsers
- name: just design-check
if: matrix.slug == 'catalog'
Expand Down Expand Up @@ -192,11 +275,11 @@ jobs:
retention-days: 7

# Build the exact runtime image on pull requests and reject high/critical OS,
# Go-binary, or embedded-secret findings before merge.
# Go-binary, or embedded-secret findings before merge. It runs beside Gate
# rather than after it; both are required.
container-scan:
name: Container scan
if: github.event_name == 'pull_request'
needs: gate
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
Expand Down
28 changes: 26 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ jobs:
verify:
name: verify release source
runs-on: ubuntu-24.04
permissions:
contents: read
# Reads the CI run for the tagged commit.
actions: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
Expand Down Expand Up @@ -79,6 +83,20 @@ jobs:
name: upgrade-notes
path: ${{ runner.temp }}/upgrade-notes.md
if-no-files-found: error
# The tag is on main (checked above), and CI's push run on main already
# ran every check and the race suite on this exact commit. Reuse that
# result; run the suites here only when no such run passed, for example
# when a newer push cancelled it.
- name: Find CI's result for this commit
id: ci
env:
GH_TOKEN: ${{ github.token }}
run: |
if bash scripts/ci-passed.sh "${GITHUB_SHA}"; then
echo "passed=true" >> "${GITHUB_OUTPUT}"
else
echo "passed=false" >> "${GITHUB_OUTPUT}"
fi
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
Expand All @@ -89,12 +107,18 @@ jobs:
with:
bun-version: 1.4.2
- uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0
if: steps.ci.outputs.passed != 'true'
with:
version: v2.14.0
args: --help
- run: just ui-deps
- run: just check
- run: just test-race
# The advisory database changes over time, so the audit runs at release
# even when CI's result is reused.
- run: just ui-audit
- if: steps.ci.outputs.passed != 'true'
run: just check
- if: steps.ci.outputs.passed != 'true'
run: just test-race

# DuckDB needs CGO and this repository carries no cross toolchain, so every
# binary is built on a runner of its own architecture.
Expand Down
3 changes: 2 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ suite. See [browser smoke testing](docs/testing.md) for coverage and failure art
`just install` also installs [Lefthook](https://lefthook.dev)'s Git hooks, which run
formatting and linting on commit and the full gate on push. The pre-push hook
may be skipped when Lefthook detects no changed files;
CI runs the same `just check` unconditionally and enforces the gate.
CI runs the same checks unconditionally, split into parallel jobs plus the race
suite, and enforces the gate.

The browser workspace uses `package.json` overrides for transitive security
fixes that their direct dependencies have not locked yet. Keep those overrides
Expand Down
9 changes: 6 additions & 3 deletions docs/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,14 @@ steps in its description, so they can be copied into the notes.
Run `just release` from a clean, current `main`. The script:

1. verifies that no other release is running;
2. runs `just check` and the race-enabled Go suite;
3. confirms that neither local `HEAD` nor `origin/main` moved during testing;
2. waits for CI's push run on `main` for that commit, which runs every check and
the race-enabled Go suite, and stops unless it passed;
3. confirms that neither local `HEAD` nor `origin/main` moved meanwhile;
4. calculates and pushes the next CalVer tag.

The tag workflow then independently validates tag syntax, ancestry, and ordering;
The tag workflow then independently validates tag syntax, ancestry, and ordering.
It reuses that CI result for the tagged commit, re-running only the dependency
audit, and runs the full suites itself when no successful run exists. It then
builds every target on its native runner; publishes the multi-architecture image;
copies that accepted manifest to Docker Hub; requires the registry digests to
match; and creates the GitHub release only after anonymous pulls from both GHCR
Expand Down
14 changes: 9 additions & 5 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ test *ARGS='./...':
# that alignment check — the -race data-race detector stays on.

# Run the Go tests under the race detector.
test-race:
bash scripts/with-duckdb.sh go test -race -gcflags=all=-d=checkptr=0 ./...
test-race *ARGS='./...':
bash scripts/with-duckdb.sh go test -race -gcflags=all=-d=checkptr=0 {{ARGS}}

# Opt-in wall-clock acceptance; deterministic work bounds remain in test.
fanql-perf:
Expand Down Expand Up @@ -359,14 +359,18 @@ social-card:

# ── Gate ─────────────────────────────────────────────────────────────────────

# lefthook's pre-push hook and CI both run this.
# lefthook's pre-push hook runs this; CI runs the same three parts in parallel
# jobs and adds the race suite.
check: check-static test ui-test
@echo "All checks passed"

# Everything in `check` except the Go and UI unit suites.
#
# docs-generate-check comes before the site build for the same reason it exists:
# a settings page that no longer matches the type the loader binds is a
# documented setting the binary would reject, and it should fail here rather
# than be published.
check: script-tests dashboard-eval-generate-check test-names-check go-deadcode ui-deadcode fmt-check ui-boundaries-check lint release-test duckdb-wrapper-test ui-audit ui-check notices-check test ui-test docs-generate-check site-build
@echo "All checks passed"
check-static: script-tests dashboard-eval-generate-check test-names-check go-deadcode ui-deadcode fmt-check ui-boundaries-check lint release-test duckdb-wrapper-test ui-audit ui-check notices-check docs-generate-check site-build

clean:
rm -rf bin
Expand Down
4 changes: 2 additions & 2 deletions lefthook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ pre-push:
# filters pre-push jobs by its own changed-file detection and skips when
# that set is empty, which is deliberate (`lefthook run --force` overrides
# it). Treat this hook as a fast local convenience, not a guarantee — CI
# runs the same `just check` unconditionally, and that is the gate that
# actually enforces it.
# runs the same checks unconditionally in parallel jobs, and that is the
# gate that actually enforces it.
run: just check
63 changes: 63 additions & 0 deletions scripts/ci-passed.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/usr/bin/env bash
# Exits 0 when CI's push run on main for exactly this commit succeeded,
# including its Gate job; exits 1 otherwise.
#
# A release tag can only point at a main commit, and main only advances
# through pull requests whose Gate passed, so a successful push run on the
# same commit verified the same tree the release builds. The release reuses
# that result instead of running the suites again.
#
# ci-passed.sh [--wait] <sha>
#
# --wait follows a run that is still in progress instead of failing.
set -euo pipefail

wait=0
if [ "${1:-}" = --wait ]; then
wait=1
shift
fi
sha=${1:?usage: ci-passed.sh [--wait] <sha>}
[[ "$sha" =~ ^[0-9a-f]{40}$ ]] || {
echo "ci-passed: ${sha} is not a full commit SHA" >&2
exit 1
}
repo=${GITHUB_REPOSITORY:-$(gh repo view --json nameWithOwner --jq .nameWithOwner)}

# Seconds to wait for CI to register the push run before giving up.
registration=300

while :; do
runs=$(gh api "repos/${repo}/actions/workflows/ci.yml/runs?head_sha=${sha}&event=push&branch=main&per_page=20" \
--jq ".workflow_runs[] | select(.head_sha == \"${sha}\" and .head_branch == \"main\" and .event == \"push\") | \"\(.id) \(.status) \(.conclusion)\"")

passed=$(awk '$2 == "completed" && $3 == "success" { print $1; exit }' <<<"$runs")
if [ -n "$passed" ]; then
gate=$(gh api "repos/${repo}/actions/runs/${passed}/jobs?per_page=100" \
--jq '[.jobs[] | select(.name == "Gate") | .conclusion] | join(" ")')
if [ "$gate" = success ]; then
echo "ci-passed: CI run ${passed} passed for ${sha}" >&2
exit 0
fi
echo "ci-passed: CI run ${passed} succeeded but its Gate reads '${gate}'" >&2
exit 1
fi

pending=$(awk '$2 != "completed" { print $1; exit }' <<<"$runs")
if [ "$wait" = 1 ] && [ -n "$pending" ]; then
echo "ci-passed: waiting for CI run ${pending} on ${sha}" >&2
# A watch that fails at once (an API error) must not turn into a busy loop.
gh run watch "$pending" --repo "$repo" --interval 30 >/dev/null || sleep 30
continue
fi
# Just after a push, CI may not have registered the run yet.
if [ "$wait" = 1 ] && [ -z "$runs" ] && ((registration > 0)); then
echo "ci-passed: waiting for CI to start on ${sha}" >&2
sleep 15
registration=$((registration - 15))
continue
fi

echo "ci-passed: no successful CI push run on main for ${sha}" >&2
exit 1
done
Loading
Loading