From 3981fcdddc87abdf88c74dd65ea776b7a58dfefb Mon Sep 17 00:00:00 2001 From: Erik LaBianca Date: Sun, 8 Nov 2026 21:27:05 -0500 Subject: [PATCH 1/2] ci: slim PR checks, move heavy suites to release/ci:full, add evidence gate Co-Authored-By: Claude Sonnet 5.5 --- .github/workflows/checks.yml | 99 +++++++++++++++++++++++++++++++++-- .github/workflows/publish.yml | 1 + scripts/verify-full.sh | 43 +++++++++++++++ 3 files changed, 140 insertions(+), 3 deletions(-) create mode 100755 scripts/verify-full.sh diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 95dfff3..5c5954a 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -1,12 +1,33 @@ name: Checks -on: [pull_request] + +# PR tier: `check` (ruff, pyright, layers, ceilings, the five fast pytest modules) on one +# ubuntu runner and one python. Heavy tier (`web`, `full`): workflow_dispatch, weekly, and PRs +# labelled `ci:full`. Release checking stays in release-gate.yml. +# +# Evidence gate (alternative to running the heavy tier in CI): +# 1. commit your change, run `scripts/verify-full.sh` locally; +# 2. commit .ci/evidence/full-suite.json as the LAST commit (excluded from the content hash); +# 3. `evidence-gate` recomputes the hash on the PR head and passes on a match. +# It also passes for PRs that only touch docs/markdown/.github, or when the PR carries +# `ci:full` and the `web` and `full` jobs are green. Release workflows ignore evidence. +on: + pull_request: + types: [opened, synchronize, reopened, labeled] + paths-ignore: + - 'docs/**' + - '**/*.md' + workflow_dispatch: + schedule: + - cron: '31 5 * * 1' concurrency: - group: checks-pr-${{ github.event.pull_request.number }} - cancel-in-progress: true + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} permissions: contents: read jobs: check: + if: github.event_name != 'schedule' && github.event.action != 'labeled' + timeout-minutes: 20 strategy: fail-fast: false matrix: @@ -32,8 +53,45 @@ jobs: fi make pr-check CHECK_BASE="$BASE_SHA" + full: + # Heavy tier: the complete `make check` (what release-gate runs on a candidate). + if: >- + github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' || + (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'ci:full')) + runs-on: ubuntu-latest + timeout-minutes: 60 + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: astral-sh/setup-uv@v7 + with: + version: "0.13.3" + python-version: "3.11" + enable-cache: true + - run: uv sync --locked + - uses: actions/setup-node@v4 + with: + node-version: "22.22.2" + cache: npm + - run: npm ci --ignore-scripts + - name: Put native PostgreSQL tools on PATH + run: | + if ! ls -d /usr/lib/postgresql/*/bin >/dev/null 2>&1; then + sudo apt-get update + sudo apt-get install -y --no-install-recommends postgresql + fi + ls -d /usr/lib/postgresql/*/bin | sort -V | tail -n 1 >> "$GITHUB_PATH" + - run: npm run build + - run: make check + web: + # Heavy tier: browsers + PostgreSQL + the web suites. + if: >- + github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' || + (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'ci:full')) runs-on: ubuntu-latest + timeout-minutes: 45 steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 @@ -63,3 +121,38 @@ jobs: fi ls -d /usr/lib/postgresql/*/bin | sort -V | tail -n 1 >> "$GITHUB_PATH" - run: make web-check + + evidence-gate: + needs: [web, full] + if: >- + always() && github.event_name == 'pull_request' && + (github.event.action != 'labeled' || github.event.label.name == 'ci:full') + runs-on: ubuntu-latest + timeout-minutes: 5 + permissions: + contents: read + pull-requests: read + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + - name: Evidence gate + env: + GH_TOKEN: ${{ github.token }} + PR: ${{ github.event.pull_request.number }} + LABELS: ${{ toJSON(github.event.pull_request.labels.*.name) }} + RESULTS: ${{ join(needs.*.result, ' ') }} + run: | + light='^(docs/|\.github/|LICENSE|NOTICE)|\.md$' + if [ "$(gh api --paginate "repos/$GITHUB_REPOSITORY/pulls/$PR/files" --jq '.[].filename' | grep -Evc "$light" || true)" = 0 ]; then + echo "pass (c): no paths covered by the heavy tier"; exit 0 + fi + h=$(git ls-files -z -- . ':!.ci/evidence' | while IFS= read -r -d '' f; do [ -f "$f" ] || continue; printf '%s\0' "$f"; cat -- "$f"; done | sha256sum | cut -d' ' -f1) + if [ -f .ci/evidence/full-suite.json ] && [ "$(jq -r .content_hash .ci/evidence/full-suite.json)" = "$h" ]; then + echo "pass (a): evidence matches $h"; exit 0 + fi + if echo "$LABELS" | jq -e 'index("ci:full")' >/dev/null && [ "$RESULTS" = "success success" ]; then + echo "pass (b): ci:full label and heavy suite green"; exit 0 + fi + echo "::error::No valid evidence for $h. Run scripts/verify-full.sh locally and commit .ci/evidence/full-suite.json last, or add the ci:full label." + exit 1 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index d08b3b6..8b72dff 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -23,6 +23,7 @@ permissions: jobs: publish: runs-on: ubuntu-latest + timeout-minutes: 15 environment: pypi permissions: contents: read diff --git a/scripts/verify-full.sh b/scripts/verify-full.sh new file mode 100755 index 0000000..8810933 --- /dev/null +++ b/scripts/verify-full.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash +# Run the full (heavy) suite locally and record evidence that CI's `evidence-gate` job accepts +# instead of re-running the suite on the PR. +# +# Usage: commit your change, run scripts/verify-full.sh, then commit .ci/evidence/full-suite.json +# as the last commit. The evidence is bound to a hash of every tracked file except +# .ci/evidence/, so any later change to the PR invalidates it (re-run the script). +set -euo pipefail +cd "$(git rev-parse --show-toplevel)" + +SUITE='tether-full' +FULL_CMD='uv sync --locked && npm ci --ignore-scripts && npm run build && make check && make web-check' + +command -v jq >/dev/null || { echo "jq is required" >&2; exit 2; } +sha() { if command -v sha256sum >/dev/null; then sha256sum; else shasum -a 256; fi; } +content_hash() { + git ls-files -z -- . ':!.ci/evidence' | while IFS= read -r -d '' f; do + [ -f "$f" ] || continue + printf '%s\0' "$f"; cat -- "$f" + done | sha | cut -d' ' -f1 +} + +if [ -n "$(git status --porcelain --untracked-files=no -- . ':!.ci/evidence')" ]; then + echo "Working tree has uncommitted changes to tracked files; commit first so the hash matches the PR head." >&2 + exit 1 +fi + +before=$(content_hash) +echo "+ $FULL_CMD" +bash -c "$FULL_CMD" +after=$(content_hash) +if [ "$before" != "$after" ]; then + echo "The suite modified tracked files; restore or commit them and re-run." >&2 + exit 1 +fi + +tools=$( { uv --version; node --version; python3 --version; } 2>&1 | jq -R . | jq -s . ) +mkdir -p .ci/evidence +jq -n --arg suite "$SUITE" --arg hash "$after" --arg ts "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \ + --arg cmd "$FULL_CMD" --argjson tools "$tools" \ + '{suite: $suite, tool_versions: $tools, content_hash: $hash, timestamp: $ts, command: $cmd}' \ + > .ci/evidence/full-suite.json +echo "Wrote .ci/evidence/full-suite.json (hash $after). Commit it as the last commit." From 28541ed85463897fba0e4431c7ca3733b37d42a7 Mon Sep 17 00:00:00 2001 From: Erik LaBianca Date: Sun, 8 Nov 2026 21:47:07 -0500 Subject: [PATCH 2/2] ci: fix evidence-gate self-match and stale guide references Co-Authored-By: Claude Sonnet 5.5 --- .github/workflows/checks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 5c5954a..edd4cd7 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -143,7 +143,7 @@ jobs: LABELS: ${{ toJSON(github.event.pull_request.labels.*.name) }} RESULTS: ${{ join(needs.*.result, ' ') }} run: | - light='^(docs/|\.github/|LICENSE|NOTICE)|\.md$' + light='^(docs/|scripts/verify-full\.sh$|\.ci/evidence/|\.github/|LICENSE|NOTICE)|\.md$' if [ "$(gh api --paginate "repos/$GITHUB_REPOSITORY/pulls/$PR/files" --jq '.[].filename' | grep -Evc "$light" || true)" = 0 ]; then echo "pass (c): no paths covered by the heavy tier"; exit 0 fi