From 415ef3c17cfc8804b2a0550871e8fe9d23e4d4a2 Mon Sep 17 00:00:00 2001 From: Zach Lowden Date: Fri, 23 Oct 2026 19:50:39 -0500 Subject: [PATCH 1/3] ci: dispatch 'only' selector and ref-grouped concurrency (runner savings) Port the civitai/civitai#6718/#6728 pattern: - ci.yml: workflow_dispatch gets an 'only' choice input; every job but pins-vs-published (whose guard test forbids a job-level if:) gates on it. Concurrency groups push/PR by ref and dispatches by ref+only, cancel-in-progress. - flake.yml, schema-drift.yml: ref-grouped concurrency with cancel-in-progress. Docs-only skipping is deliberately not added: six ci.yml jobs are required checks and Go tests read README.md, AGENTS.md, CLAUDE.md and claudedocs/**. Co-Authored-By: Claude Opus 5.5 (1M context) --- .github/workflows/ci.yml | 76 +++++++++++++++++++++++++++++- .github/workflows/flake.yml | 9 ++++ .github/workflows/schema-drift.yml | 10 ++++ 3 files changed, 94 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a0196a64..cddf3e18 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,11 +18,66 @@ on: # It cannot be back-applied — a dispatchable workflow must already exist on # the default branch — so it is only useful if it lands BEFORE the next # incident. Do not remove it because it looks unused. + # + # `only` runs one job instead of the whole fan-out, for a dispatch that cares + # about a single check (the job queue is shared org-wide, so a full run to + # re-check one context costs everyone). Every job's `if` reads it; on push and + # pull_request `inputs.only` is empty and every job runs exactly as before. + # * `pins-vs-published` is the EXCEPTION: it has no `if:` and runs on every + # dispatch, whatever `only` says. workflow_pins_gate_test.go forbids any + # job-level `if:` on it (a skipped required job reports satisfied), and that + # guard is worth more than the one cheap job it would save. + # * `dogfood-browser` also runs its classifier, `dogfood-browser-changes`, + # which always answers run=true on a dispatch. workflow_dispatch: + inputs: + only: + description: >- + Run only this job. all = every job (default). pins-vs-published runs on + every dispatch regardless (see the comment in ci.yml). + type: choice + default: all + options: + - all + - build-test + - dogfood-browser + - lint + - pins-vs-published + - ready-ack-runtime + - template-page-vite + - template-page-elements + - template-page-money + - scaffold-currency permissions: contents: read +# One group per ref, for pull requests AND pushes; added for runner savings +# (same pattern as civitai/civitai#6718 and #6728). On a PR `github.ref` is +# `refs/pull/N/merge`, so a new push to the branch cancels the in-flight run. +# On a push to `main` it is `refs/heads/main`, so a newer commit on `main` +# cancels the older one's run. Nothing downstream consumes a per-commit `main` +# verdict (no workflow_run consumer, release.yml runs off tags), and the newest +# run checks a tree containing every older commit; what is given up is a verdict +# for intermediate commits, which show as `cancelled`. To pin a break to one, +# push a branch at it and dispatch this workflow there. One side effect: the Go +# cache save (build-test, push to main only) is skipped for a cancelled run and +# happens in the run that superseded it. +# +# A dispatch groups by ref AND `only`, so re-dispatching the same job on the same +# branch cancels the stale run while different jobs run side by side. The +# `dispatch-` prefix keeps those groups disjoint from the PR and push ones. +# +# ⚠ DOCS-ONLY CHANGES ARE NOT SKIPPED HERE, deliberately. Six of this file's +# jobs are required contexts, so a workflow-level `paths:` filter would leave a +# docs-only PR waiting forever on checks that never start; and there is no safe +# "docs" set to skip at job level either: Go tests read README.md, AGENTS.md, +# CLAUDE.md and claudedocs/** (grep the *_test.go files), and pins-vs-published +# may carry no `if:` at all. +concurrency: + group: ci-${{ github.event_name == 'workflow_dispatch' && format('dispatch-{0}-{1}', github.ref, inputs.only) || github.ref }} + cancel-in-progress: true + # ───────────────────────────────────────────────────────────────────────────── # VACUOUS GREEN — the shared rationale every positive control below points at. # @@ -71,6 +126,8 @@ permissions: jobs: build-test: runs-on: ubuntu-latest + # `only` selector (see `on.workflow_dispatch`); true on push and pull_request. + if: ${{ !inputs.only || inputs.only == 'all' || inputs.only == 'build-test' }} steps: - uses: actions/checkout@v4 @@ -232,6 +289,8 @@ jobs: # in the list. dogfood-browser-changes: runs-on: ubuntu-latest + # Runs for `only: dogfood-browser` too: its consumer needs its outputs. + if: ${{ !inputs.only || inputs.only == 'all' || inputs.only == 'dogfood-browser' }} outputs: run: ${{ steps.decide.outputs.run }} reason: ${{ steps.decide.outputs.reason }} @@ -283,7 +342,10 @@ jobs: dogfood-browser: runs-on: ubuntu-latest needs: [dogfood-browser-changes] - if: ${{ !cancelled() && (needs.dogfood-browser-changes.result != 'success' || needs.dogfood-browser-changes.outputs.run != 'false') }} + # The trailing `only` clause is the dispatch selector. It must be explicit + # here: with the classifier skipped by `only`, its result is not 'success', + # and the fail-open clause alone would run this job anyway. + if: ${{ !cancelled() && (needs.dogfood-browser-changes.result != 'success' || needs.dogfood-browser-changes.outputs.run != 'false') && (!inputs.only || inputs.only == 'all' || inputs.only == 'dogfood-browser') }} steps: - name: why this job is running env: @@ -316,6 +378,8 @@ jobs: # misspell + gofmt). Runs on every PR. `make lint` mirrors this locally. lint: runs-on: ubuntu-latest + # `only` selector (see `on.workflow_dispatch`); true on push and pull_request. + if: ${{ !inputs.only || inputs.only == 'all' || inputs.only == 'lint' }} steps: - uses: actions/checkout@v4 @@ -474,6 +538,8 @@ jobs: # exit code. ready-ack-runtime: runs-on: ubuntu-latest + # `only` selector (see `on.workflow_dispatch`); true on push and pull_request. + if: ${{ !inputs.only || inputs.only == 'all' || inputs.only == 'ready-ack-runtime' }} steps: - uses: actions/checkout@v4 @@ -546,6 +612,8 @@ jobs: # both cases, proving the grep reads the bundle either way. template-page-vite: runs-on: ubuntu-latest + # `only` selector (see `on.workflow_dispatch`); true on push and pull_request. + if: ${{ !inputs.only || inputs.only == 'all' || inputs.only == 'template-page-vite' }} steps: - uses: actions/checkout@v4 @@ -647,6 +715,8 @@ jobs: # protection (AGENTS.md item 11: measure, never infer, which jobs gate). template-page-elements: runs-on: ubuntu-latest + # `only` selector (see `on.workflow_dispatch`); true on push and pull_request. + if: ${{ !inputs.only || inputs.only == 'all' || inputs.only == 'template-page-elements' }} steps: - uses: actions/checkout@v4 @@ -723,6 +793,8 @@ jobs: # out-of-the-box contract the template promises. template-page-money: runs-on: ubuntu-latest + # `only` selector (see `on.workflow_dispatch`); true on push and pull_request. + if: ${{ !inputs.only || inputs.only == 'all' || inputs.only == 'template-page-money' }} steps: - uses: actions/checkout@v4 @@ -801,6 +873,8 @@ jobs: # offline anti-pattern scan is hermetic and always runs. scaffold-currency: runs-on: ubuntu-latest + # `only` selector (see `on.workflow_dispatch`); true on push and pull_request. + if: ${{ !inputs.only || inputs.only == 'all' || inputs.only == 'scaffold-currency' }} steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/flake.yml b/.github/workflows/flake.yml index d75a3a9e..447896e5 100644 --- a/.github/workflows/flake.yml +++ b/.github/workflows/flake.yml @@ -22,6 +22,15 @@ on: - flake.lock workflow_dispatch: +# One group per ref (same pattern as civitai/civitai#6718 / #6728, for runner +# savings): a newer push to a PR, or to `main`, cancels the in-flight run for +# the older commit; a `nix build` per superseded commit is pure queue time. +# A dispatch gets its own `dispatch-` group so it neither cancels nor is cancelled by a push run. +# Not a required status check, and nothing consumes its per-commit verdict. +concurrency: + group: flake-${{ github.event_name == 'workflow_dispatch' && format('dispatch-{0}', github.ref) || github.ref }} + cancel-in-progress: true + jobs: build: runs-on: ubuntu-latest diff --git a/.github/workflows/schema-drift.yml b/.github/workflows/schema-drift.yml index 6b3ba72b..00b276dd 100644 --- a/.github/workflows/schema-drift.yml +++ b/.github/workflows/schema-drift.yml @@ -48,6 +48,16 @@ on: - '.github/workflows/schema-drift.yml' workflow_dispatch: +# One group per ref (same pattern as civitai/civitai#6718 / #6728, for runner +# savings): a newer push to a PR, or to `main`, cancels the in-flight run for +# the older commit. The question is about the published canonical, not the +# commit, so only the newest run's answer matters. A dispatch gets its own +# `dispatch-` group so it neither cancels nor is cancelled by a push run. +# Not a required status check, and nothing consumes its per-commit verdict. +concurrency: + group: schema-drift-${{ github.event_name == 'workflow_dispatch' && format('dispatch-{0}', github.ref) || github.ref }} + cancel-in-progress: true + jobs: schema-drift: runs-on: ubuntu-latest From 1a2159b545f65e69ffc3e64dbe59497d1ce6a833 Mon Sep 17 00:00:00 2001 From: Zach Lowden Date: Fri, 23 Oct 2026 20:30:01 -0500 Subject: [PATCH 2/3] ci(flake): drop the concurrency block flake.yml ran once in the last 30 days, so a cancel-superseded group saves nothing there. ci.yml and schema-drift.yml keep theirs. Co-Authored-By: Claude Opus 5.5 (1M context) --- .github/workflows/flake.yml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.github/workflows/flake.yml b/.github/workflows/flake.yml index 447896e5..d75a3a9e 100644 --- a/.github/workflows/flake.yml +++ b/.github/workflows/flake.yml @@ -22,15 +22,6 @@ on: - flake.lock workflow_dispatch: -# One group per ref (same pattern as civitai/civitai#6718 / #6728, for runner -# savings): a newer push to a PR, or to `main`, cancels the in-flight run for -# the older commit; a `nix build` per superseded commit is pure queue time. -# A dispatch gets its own `dispatch-` group so it neither cancels nor is cancelled by a push run. -# Not a required status check, and nothing consumes its per-commit verdict. -concurrency: - group: flake-${{ github.event_name == 'workflow_dispatch' && format('dispatch-{0}', github.ref) || github.ref }} - cancel-in-progress: true - jobs: build: runs-on: ubuntu-latest From 8b543b30aceea39a2c9c970c8ab047e9be32509a Mon Sep 17 00:00:00 2001 From: Zach Lowden Date: Fri, 23 Oct 2026 22:13:59 -0500 Subject: [PATCH 3/3] ci: drop the dispatch `only` input, keep ref-grouped concurrency Removes the workflow_dispatch `only` input and every job's `only` clause, restoring each job's `if:` to main's. A narrowed dispatch writes skipped check runs under the normal job names, and a skipped job satisfies a required check, so a narrowed run at a pull request's head (or in the webhook-outage recovery case) could pass required checks that never ran. ci.yml keeps only the ref-grouped cancel-in-progress concurrency; a dispatch gets its own `dispatch-` group per ref. schema-drift.yml keeps its concurrency; flake.yml stays main's. Co-Authored-By: Claude Opus 5.5 (1M context) --- .github/workflows/ci.yml | 58 ++++------------------------------------ 1 file changed, 5 insertions(+), 53 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cddf3e18..fb14576d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,36 +18,7 @@ on: # It cannot be back-applied — a dispatchable workflow must already exist on # the default branch — so it is only useful if it lands BEFORE the next # incident. Do not remove it because it looks unused. - # - # `only` runs one job instead of the whole fan-out, for a dispatch that cares - # about a single check (the job queue is shared org-wide, so a full run to - # re-check one context costs everyone). Every job's `if` reads it; on push and - # pull_request `inputs.only` is empty and every job runs exactly as before. - # * `pins-vs-published` is the EXCEPTION: it has no `if:` and runs on every - # dispatch, whatever `only` says. workflow_pins_gate_test.go forbids any - # job-level `if:` on it (a skipped required job reports satisfied), and that - # guard is worth more than the one cheap job it would save. - # * `dogfood-browser` also runs its classifier, `dogfood-browser-changes`, - # which always answers run=true on a dispatch. workflow_dispatch: - inputs: - only: - description: >- - Run only this job. all = every job (default). pins-vs-published runs on - every dispatch regardless (see the comment in ci.yml). - type: choice - default: all - options: - - all - - build-test - - dogfood-browser - - lint - - pins-vs-published - - ready-ack-runtime - - template-page-vite - - template-page-elements - - template-page-money - - scaffold-currency permissions: contents: read @@ -64,9 +35,9 @@ permissions: # cache save (build-test, push to main only) is skipped for a cancelled run and # happens in the run that superseded it. # -# A dispatch groups by ref AND `only`, so re-dispatching the same job on the same -# branch cancels the stale run while different jobs run side by side. The -# `dispatch-` prefix keeps those groups disjoint from the PR and push ones. +# A dispatch gets its own `dispatch-` group per ref, so it neither cancels nor +# is cancelled by a push or pull_request run (a re-dispatch on the same ref +# cancels the older dispatch). # # ⚠ DOCS-ONLY CHANGES ARE NOT SKIPPED HERE, deliberately. Six of this file's # jobs are required contexts, so a workflow-level `paths:` filter would leave a @@ -75,7 +46,7 @@ permissions: # CLAUDE.md and claudedocs/** (grep the *_test.go files), and pins-vs-published # may carry no `if:` at all. concurrency: - group: ci-${{ github.event_name == 'workflow_dispatch' && format('dispatch-{0}-{1}', github.ref, inputs.only) || github.ref }} + group: ci-${{ github.event_name == 'workflow_dispatch' && format('dispatch-{0}', github.ref) || github.ref }} cancel-in-progress: true # ───────────────────────────────────────────────────────────────────────────── @@ -126,8 +97,6 @@ concurrency: jobs: build-test: runs-on: ubuntu-latest - # `only` selector (see `on.workflow_dispatch`); true on push and pull_request. - if: ${{ !inputs.only || inputs.only == 'all' || inputs.only == 'build-test' }} steps: - uses: actions/checkout@v4 @@ -289,8 +258,6 @@ jobs: # in the list. dogfood-browser-changes: runs-on: ubuntu-latest - # Runs for `only: dogfood-browser` too: its consumer needs its outputs. - if: ${{ !inputs.only || inputs.only == 'all' || inputs.only == 'dogfood-browser' }} outputs: run: ${{ steps.decide.outputs.run }} reason: ${{ steps.decide.outputs.reason }} @@ -342,10 +309,7 @@ jobs: dogfood-browser: runs-on: ubuntu-latest needs: [dogfood-browser-changes] - # The trailing `only` clause is the dispatch selector. It must be explicit - # here: with the classifier skipped by `only`, its result is not 'success', - # and the fail-open clause alone would run this job anyway. - if: ${{ !cancelled() && (needs.dogfood-browser-changes.result != 'success' || needs.dogfood-browser-changes.outputs.run != 'false') && (!inputs.only || inputs.only == 'all' || inputs.only == 'dogfood-browser') }} + if: ${{ !cancelled() && (needs.dogfood-browser-changes.result != 'success' || needs.dogfood-browser-changes.outputs.run != 'false') }} steps: - name: why this job is running env: @@ -378,8 +342,6 @@ jobs: # misspell + gofmt). Runs on every PR. `make lint` mirrors this locally. lint: runs-on: ubuntu-latest - # `only` selector (see `on.workflow_dispatch`); true on push and pull_request. - if: ${{ !inputs.only || inputs.only == 'all' || inputs.only == 'lint' }} steps: - uses: actions/checkout@v4 @@ -538,8 +500,6 @@ jobs: # exit code. ready-ack-runtime: runs-on: ubuntu-latest - # `only` selector (see `on.workflow_dispatch`); true on push and pull_request. - if: ${{ !inputs.only || inputs.only == 'all' || inputs.only == 'ready-ack-runtime' }} steps: - uses: actions/checkout@v4 @@ -612,8 +572,6 @@ jobs: # both cases, proving the grep reads the bundle either way. template-page-vite: runs-on: ubuntu-latest - # `only` selector (see `on.workflow_dispatch`); true on push and pull_request. - if: ${{ !inputs.only || inputs.only == 'all' || inputs.only == 'template-page-vite' }} steps: - uses: actions/checkout@v4 @@ -715,8 +673,6 @@ jobs: # protection (AGENTS.md item 11: measure, never infer, which jobs gate). template-page-elements: runs-on: ubuntu-latest - # `only` selector (see `on.workflow_dispatch`); true on push and pull_request. - if: ${{ !inputs.only || inputs.only == 'all' || inputs.only == 'template-page-elements' }} steps: - uses: actions/checkout@v4 @@ -793,8 +749,6 @@ jobs: # out-of-the-box contract the template promises. template-page-money: runs-on: ubuntu-latest - # `only` selector (see `on.workflow_dispatch`); true on push and pull_request. - if: ${{ !inputs.only || inputs.only == 'all' || inputs.only == 'template-page-money' }} steps: - uses: actions/checkout@v4 @@ -873,8 +827,6 @@ jobs: # offline anti-pattern scan is hermetic and always runs. scaffold-currency: runs-on: ubuntu-latest - # `only` selector (see `on.workflow_dispatch`); true on push and pull_request. - if: ${{ !inputs.only || inputs.only == 'all' || inputs.only == 'scaffold-currency' }} steps: - uses: actions/checkout@v4