From 396f5e6badec42aa1977f06c65007bd0b25751d7 Mon Sep 17 00:00:00 2001 From: Lindsay Holmwood Date: Wed, 28 Oct 2026 23:21:09 +1100 Subject: [PATCH 01/23] test(ci): read the image of a RunsOn runner label The mise cache guard keys each cached mise step by the Ubuntu image its job runs on. Jobs built on one image fail with "GLIBC_2.38 not found" when they restore tools built on another. The guard found the image by looking for `ubuntu-NNNN` in the `runs-on` label. A RunsOn label names its image differently, as `image=ubuntu22-full-x64`. The heavy jobs are about to move to RunsOn. The guard would then report every one of them as having no image. So the guard now reads the `image=` segment of a RunsOn label. A RunsOn label without that segment uses the RunsOn stack's default image. The label does not show that image, so the mise cache must stay off for such a job. --- .../workflow-mise-cache-image.test.mjs | 30 +++++++++++++++++-- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/scripts/__tests__/workflow-mise-cache-image.test.mjs b/scripts/__tests__/workflow-mise-cache-image.test.mjs index 4007ba9d3c..1250b9cd6f 100644 --- a/scripts/__tests__/workflow-mise-cache-image.test.mjs +++ b/scripts/__tests__/workflow-mise-cache-image.test.mjs @@ -24,8 +24,9 @@ import { readWorkflow, workflowFiles } from './lib/workflows.mjs' * * So each cached step sets `cache_key_prefix: mise-v1-`, where `` * is the `ubuntu-NNNN` its job's `runs-on` names (`ubuntu-24.04` counts as - * `ubuntu-2404`). A job whose `runs-on` names no image (a matrix, - * `ubuntu-latest`) must turn the cache off. No step sets `cache_key`, which + * `ubuntu-2404`, and so does a RunsOn label's `image=ubuntu24-full-x64`). A job + * whose `runs-on` names no image (a matrix, `ubuntu-latest`, a RunsOn label with + * no `image=`) must turn the cache off. No step sets `cache_key`, which * mise-action prefers over the prefix and so would bring the shared key back. * A step with the cache off sets no prefix: it would read as a cache in use, * on paths `scripts/lint-no-workflow-caching.mjs` keeps cache-free. @@ -63,7 +64,14 @@ const IMAGE_INDEPENDENT_TOOLS = new Set(['aqua:wasm-bindgen/wasm-pack']) /** The `ubuntu-NNNN` a runs-on label names, or undefined. */ function imageOf(runsOn) { - const m = /ubuntu-(\d{2})\.?(\d{2})/.exec(String(runsOn)) + const label = String(runsOn) + // RunsOn takes its image from an `image=` segment, and ships only LTS ones. + // With no segment it uses the stack's default, which the label cannot show. + if (label.startsWith('runs-on=')) { + const m = /\/image=ubuntu(\d{2})-/.exec(label) + return m ? `ubuntu-${m[1]}04` : undefined + } + const m = /ubuntu-(\d{2})\.?(\d{2})/.exec(label) return m ? `ubuntu-${m[1]}${m[2]}` : undefined } @@ -149,6 +157,22 @@ describe('mise-action cache keys', () => { expect(imageOf(undefined)).toBeUndefined() }) + it('reads the image of a RunsOn label', () => { + expect( + imageOf( + // biome-ignore lint/suspicious/noTemplateCurlyInString: a GitHub Actions expression, the literal `runs-on` value under test. + 'runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache', + ), + ).toBe('ubuntu-2204') + expect(imageOf('runs-on=1/family=c8a/cpu=4/image=ubuntu24-full-x64')).toBe( + 'ubuntu-2404', + ) + // No `image=`: RunsOn uses the stack's default image, which the label + // does not name, so the cache must be off. + expect(imageOf('runs-on=1/family=c8a+m8a/cpu=8')).toBeUndefined() + expect(imageOf('runs-on=1/runner=4cpu-linux-x64')).toBeUndefined() + }) + it('lets a composite action cache only image-independent tools', () => { const checked = [] const wrong = [] From 863f8d14f66c081dc9f35a21849c7b10b8027b09 Mon Sep 17 00:00:00 2001 From: Lindsay Holmwood Date: Wed, 28 Oct 2026 23:21:32 +1100 Subject: [PATCH 02/23] ci(runners): run the heavy 16 vCPU jobs on RunsOn CI on Blacksmith cost about $3,865 a month at October's pace. The budget for this repository and the others that share it is $1,000 a month. RunsOn starts a machine in our own AWS account for each job. In the runner trial in #1297, a week of these jobs cost $194 on RunsOn c8a with 8 vCPUs. The same jobs cost $843 on Blacksmith. They took 0.93 times as long on RunsOn. This moves every heavy job that ran on `blacksmith-16vcpu-ubuntu-2204`. A heavy job compiles Rust, builds a Docker image or runs a Postgres suite. Each one now runs on c8a with 8 vCPUs. Mutants runs on c8a with 16 vCPUs. It tests one mutant at a time, and in the trial 16 vCPUs ran it about 25% faster than 8. Every label also carries these settings: - `family=c8a+m8a`: m8a has the same CPU as c8a. RunsOn can use it when AWS has no spare c8a spot machines, before paying the on-demand price. - `image=ubuntu22-full-x64`: Ubuntu 22.04, as on the Blacksmith label. The mise cache prefixes stay `mise-v1-ubuntu-2204`. - `volume=80gb`: the default disk fills during a Rust build. - `extras=s3-cache`: the job cache comes from RunsOn's S3 bucket in our account. Fetching GitHub's cache from AWS is slow. The light jobs on that label stay on Blacksmith for now. They are change detection, the matrix setup, two bash-only checks, the summary job, and an image re-tag. They move to GitHub-hosted runners in a later change. actionlint does not check a label that contains an expression. So the RunsOn labels need no entry in `.github/actionlint.yaml`. --- .github/actionlint.yaml | 12 +++++----- .github/workflows/_build-eql-docs.yml | 2 +- .github/workflows/_build-eql-sql.yml | 2 +- .github/workflows/_test-auth-refresh-soak.yml | 2 +- .github/workflows/bench-eql.yml | 2 +- .github/workflows/crap-crates.yml | 4 ++-- .github/workflows/macro-expand-eql.yml | 2 +- .github/workflows/mutants.yml | 2 +- .github/workflows/release-golang.yml | 2 +- .../workflows/release-postgres-eql-image.yml | 4 ++-- .github/workflows/test-eql.yml | 22 +++++++++---------- .github/workflows/tests-crates.yml | 4 ++-- .github/workflows/tests-golang.yml | 2 +- 13 files changed, 32 insertions(+), 30 deletions(-) diff --git a/.github/actionlint.yaml b/.github/actionlint.yaml index 633dcb4066..3fb7fe7da7 100644 --- a/.github/actionlint.yaml +++ b/.github/actionlint.yaml @@ -7,12 +7,14 @@ # # Nothing complained before because actionlint has never run in this repository; # lint-release.yml is what introduces it. +# +# RunsOn labels need no entry here. Each one starts with +# `runs-on=${{ github.run_id }}`, and actionlint does not check a label that +# contains an expression. self-hosted-runner: labels: - blacksmith-4vcpu-ubuntu-2404 - # Every job in the imported EQL suite. Sixteen of them, and the size is - # deliberate upstream: the sharded SQLx matrix compiles the full Rust - # dependency tree, so the runner is chosen for the compile rather than for - # the tests. Kept as its own label rather than renamed to the 4vcpu one — - # rehoming those jobs is a cost decision, not a lint fix. + # Only light jobs still use this label: they run bash, compute a matrix or + # summarise results. The heavy jobs that used it, such as the Rust compiles + # and the Postgres suites, run on RunsOn instead. - blacksmith-16vcpu-ubuntu-2204 diff --git a/.github/workflows/_build-eql-docs.yml b/.github/workflows/_build-eql-docs.yml index 63e6fb4ca4..d009a6fd7d 100644 --- a/.github/workflows/_build-eql-docs.yml +++ b/.github/workflows/_build-eql-docs.yml @@ -37,7 +37,7 @@ permissions: jobs: publish-docs: name: Build and publish documentation - runs-on: blacksmith-16vcpu-ubuntu-2204 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 20 steps: diff --git a/.github/workflows/_build-eql-sql.yml b/.github/workflows/_build-eql-sql.yml index f27115dd1c..8915a53fdd 100644 --- a/.github/workflows/_build-eql-sql.yml +++ b/.github/workflows/_build-eql-sql.yml @@ -57,7 +57,7 @@ permissions: jobs: build: name: Build EQL - runs-on: blacksmith-16vcpu-ubuntu-2204 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 20 steps: diff --git a/.github/workflows/_test-auth-refresh-soak.yml b/.github/workflows/_test-auth-refresh-soak.yml index b129d8d78a..56cb24e4d2 100644 --- a/.github/workflows/_test-auth-refresh-soak.yml +++ b/.github/workflows/_test-auth-refresh-soak.yml @@ -12,7 +12,7 @@ permissions: jobs: soak: - runs-on: blacksmith-16vcpu-ubuntu-2204 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 30 env: MISE_ENV: test diff --git a/.github/workflows/bench-eql.yml b/.github/workflows/bench-eql.yml index 8d46945ae7..57e0be52f9 100644 --- a/.github/workflows/bench-eql.yml +++ b/.github/workflows/bench-eql.yml @@ -93,7 +93,7 @@ defaults: jobs: bench: name: "Bench EQL (Postgres 17)" - runs-on: blacksmith-16vcpu-ubuntu-2204 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 60 env: diff --git a/.github/workflows/crap-crates.yml b/.github/workflows/crap-crates.yml index 8a325ab1ad..68f56520b7 100644 --- a/.github/workflows/crap-crates.yml +++ b/.github/workflows/crap-crates.yml @@ -59,7 +59,7 @@ env: jobs: crap-stack-auth: name: CRAP (stack-auth) - runs-on: blacksmith-16vcpu-ubuntu-2204 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 45 steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 @@ -83,7 +83,7 @@ jobs: crap-stack-encrypt: name: CRAP (stack-encrypt) - runs-on: blacksmith-16vcpu-ubuntu-2204 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 45 steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 diff --git a/.github/workflows/macro-expand-eql.yml b/.github/workflows/macro-expand-eql.yml index f0949d16b9..868e404495 100644 --- a/.github/workflows/macro-expand-eql.yml +++ b/.github/workflows/macro-expand-eql.yml @@ -51,7 +51,7 @@ permissions: jobs: macro-expand: name: "Macro expand drift (nightly)" - runs-on: blacksmith-16vcpu-ubuntu-2204 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 30 steps: diff --git a/.github/workflows/mutants.yml b/.github/workflows/mutants.yml index 65cabc4c0b..26ef909fbc 100644 --- a/.github/workflows/mutants.yml +++ b/.github/workflows/mutants.yml @@ -64,7 +64,7 @@ env: jobs: mutants: name: Mutants gate - runs-on: blacksmith-16vcpu-ubuntu-2204 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=16/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 120 permissions: contents: read diff --git a/.github/workflows/release-golang.yml b/.github/workflows/release-golang.yml index 0db79e34ad..8c08bdcfa5 100644 --- a/.github/workflows/release-golang.yml +++ b/.github/workflows/release-golang.yml @@ -71,7 +71,7 @@ concurrency: jobs: build: name: Build and test the release - runs-on: blacksmith-16vcpu-ubuntu-2204 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 90 env: VERSION: ${{ inputs.version }} diff --git a/.github/workflows/release-postgres-eql-image.yml b/.github/workflows/release-postgres-eql-image.yml index c4006fd274..9615ecacf2 100644 --- a/.github/workflows/release-postgres-eql-image.yml +++ b/.github/workflows/release-postgres-eql-image.yml @@ -58,7 +58,7 @@ jobs: name: Build EQL SQL needs: [eql-armed] if: needs.eql-armed.outputs.armed == 'true' - runs-on: blacksmith-16vcpu-ubuntu-2204 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 20 defaults: run: @@ -110,7 +110,7 @@ jobs: name: Build postgres-eql image (PG ${{ matrix.pg_version }}) needs: [eql-armed, build-sql] if: needs.eql-armed.outputs.armed == 'true' - runs-on: blacksmith-16vcpu-ubuntu-2204 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 30 permissions: contents: read diff --git a/.github/workflows/test-eql.yml b/.github/workflows/test-eql.yml index 776ac20eae..8d905b05ec 100644 --- a/.github/workflows/test-eql.yml +++ b/.github/workflows/test-eql.yml @@ -315,7 +315,7 @@ jobs: || needs.changes.outputs.relevant == 'true') && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) - runs-on: blacksmith-16vcpu-ubuntu-2204 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 45 env: # test:sqlx:archive depends on test:sqlx:prep, which copies the built EQL @@ -400,7 +400,7 @@ jobs: if: >- github.event_name != 'pull_request' || needs.changes.outputs.relevant == 'true' - runs-on: blacksmith-16vcpu-ubuntu-2204 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 75 strategy: fail-fast: false @@ -463,7 +463,7 @@ jobs: if: >- github.event_name != 'pull_request' || needs.changes.outputs.relevant == 'true' - runs-on: blacksmith-16vcpu-ubuntu-2204 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 10 strategy: fail-fast: false @@ -523,7 +523,7 @@ jobs: if: >- github.event_name != 'pull_request' || needs.changes.outputs.relevant == 'true' - runs-on: blacksmith-16vcpu-ubuntu-2204 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 10 steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 @@ -553,7 +553,7 @@ jobs: if: >- github.event_name != 'pull_request' || needs.changes.outputs.relevant == 'true' - runs-on: blacksmith-16vcpu-ubuntu-2204 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 15 services: encryption-postgres: @@ -682,7 +682,7 @@ jobs: if: >- github.event_name != 'pull_request' || needs.changes.outputs.relevant == 'true' - runs-on: blacksmith-16vcpu-ubuntu-2204 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 10 steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 @@ -715,7 +715,7 @@ jobs: if: >- github.event_name != 'pull_request' || needs.changes.outputs.relevant == 'true' - runs-on: blacksmith-16vcpu-ubuntu-2204 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 10 steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 @@ -752,7 +752,7 @@ jobs: if: >- github.event_name != 'pull_request' || needs.changes.outputs.relevant == 'true' - runs-on: blacksmith-16vcpu-ubuntu-2204 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 20 steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 @@ -795,7 +795,7 @@ jobs: if: >- github.event_name != 'pull_request' || needs.changes.outputs.relevant == 'true' - runs-on: blacksmith-16vcpu-ubuntu-2204 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 10 env: POSTGRES_VERSION: "17" @@ -856,7 +856,7 @@ jobs: # per-version `validate` job). docs-static: name: "SQL doc validation" - runs-on: blacksmith-16vcpu-ubuntu-2204 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 10 steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 @@ -969,7 +969,7 @@ jobs: || needs.changes.outputs.relevant == 'true') && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) - runs-on: blacksmith-16vcpu-ubuntu-2204 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 40 env: POSTGRES_VERSION: "17" diff --git a/.github/workflows/tests-crates.yml b/.github/workflows/tests-crates.yml index 40cc572cce..9f421b4e40 100644 --- a/.github/workflows/tests-crates.yml +++ b/.github/workflows/tests-crates.yml @@ -79,7 +79,7 @@ env: jobs: rust: name: fmt, clippy, nextest, doctests, rustdoc - runs-on: blacksmith-16vcpu-ubuntu-2204 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 60 env: # Job-level, not workflow-level: RUSTFLAGS replaces the @@ -158,7 +158,7 @@ jobs: node-bindings: name: node bindings, napi typings, stack-auth-wasm - runs-on: blacksmith-16vcpu-ubuntu-2204 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 45 steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 diff --git a/.github/workflows/tests-golang.yml b/.github/workflows/tests-golang.yml index 9bfff334ab..6c4b82987d 100644 --- a/.github/workflows/tests-golang.yml +++ b/.github/workflows/tests-golang.yml @@ -95,7 +95,7 @@ env: jobs: wasi-check: name: WASI check, guests and Go (Linux) - runs-on: blacksmith-16vcpu-ubuntu-2204 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 60 env: # wasm:guest:test and wasm:auth-guest:test run nextest, which is pinned From 05cd73fb020ed1f08551b3baeabb27022061c93c Mon Sep 17 00:00:00 2001 From: Lindsay Holmwood Date: Thu, 29 Oct 2026 00:26:19 +1100 Subject: [PATCH 03/23] ci(runners): run the four integration suites on RunsOn A heavy job is one that runs too slowly on a GitHub-hosted standard runner. For the 4 vCPU jobs, the rule comes from the runner trial in as Blacksmith. All four integration suites pass that rule. In the trial's warm run, GitHub's runner took these multiples of Blacksmith 4 vCPU's time: - Drizzle: 3.42 (db=postgres) and 3.68 (db=supabase) - prisma-next: 3.00 (db=postgres) and 2.68 (db=supabase) - Supabase: 2.96 - protect-ffi: 4.78 The warm run is the trial's like-for-like comparison, because every runner had a warm cache. On the trial's first run some caches were cold. They move to RunsOn with 8 vCPUs, like the other heavy jobs. In the trial's warm run, c8a with 8 vCPUs took 0.84 to 1.05 times Blacksmith 4 vCPU's time on these jobs. They keep Ubuntu 24.04 through `image=ubuntu24-full-x64`, so protect-ffi's `mise-v1-ubuntu-2404` cache prefix stays valid. udeps stays on Blacksmith. GitHub's runner took 1.17 times as long in the warm run. --- .github/workflows/integration-drizzle.yml | 2 +- .github/workflows/integration-prisma-next.yml | 2 +- .github/workflows/integration-protect-ffi.yml | 2 +- .github/workflows/integration-supabase.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/integration-drizzle.yml b/.github/workflows/integration-drizzle.yml index 041feebf10..f5c1f7d0df 100644 --- a/.github/workflows/integration-drizzle.yml +++ b/.github/workflows/integration-drizzle.yml @@ -204,7 +204,7 @@ on: jobs: integration: name: Drizzle v3 integration (db=${{ matrix.db }}) - runs-on: blacksmith-4vcpu-ubuntu-2404 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu24-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 35 # No concurrency group: `integration-db` gives each job its own compose # project and ephemeral host ports, so live-DB jobs no longer contend and do diff --git a/.github/workflows/integration-prisma-next.yml b/.github/workflows/integration-prisma-next.yml index c64663c36f..afb6fe2ed2 100644 --- a/.github/workflows/integration-prisma-next.yml +++ b/.github/workflows/integration-prisma-next.yml @@ -114,7 +114,7 @@ on: jobs: integration: name: prisma-next v3 integration (db=${{ matrix.db }}) - runs-on: blacksmith-4vcpu-ubuntu-2404 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu24-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 15 # No concurrency group: `integration-db` gives each job its own compose # project and ephemeral host ports, so live-DB jobs no longer contend and do diff --git a/.github/workflows/integration-protect-ffi.yml b/.github/workflows/integration-protect-ffi.yml index 8b8f4ff037..ef7b59c75a 100644 --- a/.github/workflows/integration-protect-ffi.yml +++ b/.github/workflows/integration-protect-ffi.yml @@ -160,7 +160,7 @@ concurrency: jobs: integration: name: protect-ffi integration suite - runs-on: blacksmith-4vcpu-ubuntu-2404 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu24-full-x64/volume=80gb/extras=s3-cache # Generous, because a cold `build-ffi-binding` compiles the cipherstash # client graph from scratch. It is also the backstop for `mise run # start-db`, whose readiness loop retries `pg_isready` forever rather than diff --git a/.github/workflows/integration-supabase.yml b/.github/workflows/integration-supabase.yml index 80e55dae22..f4ea9d2723 100644 --- a/.github/workflows/integration-supabase.yml +++ b/.github/workflows/integration-supabase.yml @@ -173,7 +173,7 @@ on: jobs: integration: name: Supabase v3 integration (db=${{ matrix.db }}) - runs-on: blacksmith-4vcpu-ubuntu-2404 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu24-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 15 # No concurrency group: `integration-db` gives each job its own compose # project and ephemeral host ports, so live-DB jobs no longer contend and do From 19e394e2ea79cd59aea997f6ea0397618a2b28d5 Mon Sep 17 00:00:00 2001 From: Lindsay Holmwood Date: Thu, 29 Oct 2026 20:50:33 +1100 Subject: [PATCH 04/23] ci(runners): log in to Docker Hub before RunsOn jobs pull images Docker Hub refuses pulls without a login after too many from one address. RunsOn machines reach that limit. On this branch, Test EQL shards failed with `toomanyrequests` before any test ran, and failed again on a re-run. The protect-ffi suite failed the same way once. Every RunsOn job that starts or builds a container now logs in first, with the DOCKER_HUB_USERNAME and DOCKER_HUB_PASSWORD secrets: - A `run:` step pipes the password to `docker login --password-stdin`. It comes before Postgres starts in Test EQL, Bench EQL, and the four integration suites. In the postgres-eql image release, it comes before QEMU and Buildx, because both pull their own images from Docker Hub. - The Postgres service container in Test EQL's `rust-crates` job sets `credentials` from the same secrets. Both forms do nothing when either secret is empty. That is the case on a fork's pull request, and until the secrets exist. The step exits early, and the runner skips the service login when either value is empty. Pulls then stay anonymous, as before. `workflow-docker-hub-login.test.mjs` fails when a RunsOn job may pull an image without logging in first. Any step that starts or builds a container counts as a pull, whatever the registry. So the test cannot miss a Docker Hub image it does not recognise. It follows `mise run` into task bodies, `depends`, and nested `mise run` calls, and into local composite actions. --- .github/workflows/bench-eql.yml | 18 + .github/workflows/integration-drizzle.yml | 18 + .github/workflows/integration-prisma-next.yml | 18 + .github/workflows/integration-protect-ffi.yml | 18 + .github/workflows/integration-supabase.yml | 18 + .../workflows/release-postgres-eql-image.yml | 18 + .github/workflows/test-eql.yml | 97 +++++ .../workflow-docker-hub-login.test.mjs | 411 ++++++++++++++++++ 8 files changed, 616 insertions(+) create mode 100644 scripts/__tests__/workflow-docker-hub-login.test.mjs diff --git a/.github/workflows/bench-eql.yml b/.github/workflows/bench-eql.yml index 57e0be52f9..7e0c023b05 100644 --- a/.github/workflows/bench-eql.yml +++ b/.github/workflows/bench-eql.yml @@ -146,6 +146,24 @@ jobs: # slow. Asserted by scripts/__tests__/eql-suite-ci.test.mjs. save-if: false + # Docker Hub refuses pulls without a login after too many from one + # address, and RunsOn machines reach that limit. With either secret empty, + # as on a fork's pull request, this step does nothing and pulls stay + # anonymous. scripts/__tests__/workflow-docker-hub-login.test.mjs + # requires it. + - name: Log in to Docker Hub + env: + DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }} + DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }} + run: | + set -euo pipefail + if [ -z "$DOCKER_HUB_USERNAME" ] || [ -z "$DOCKER_HUB_PASSWORD" ]; then + echo "No Docker Hub credentials, so image pulls stay anonymous." + exit 0 + fi + printf '%s' "$DOCKER_HUB_PASSWORD" | + docker login --username "$DOCKER_HUB_USERNAME" --password-stdin + - name: Setup database run: | mise run postgres:up "postgres-${POSTGRES_VERSION}" --extra-args "--detach --wait" diff --git a/.github/workflows/integration-drizzle.yml b/.github/workflows/integration-drizzle.yml index f5c1f7d0df..dceaef7f7a 100644 --- a/.github/workflows/integration-drizzle.yml +++ b/.github/workflows/integration-drizzle.yml @@ -300,6 +300,24 @@ jobs: with: wasm: 'true' + # Docker Hub refuses pulls without a login after too many from one + # address, and RunsOn machines reach that limit. With either secret empty, + # as on a fork's pull request, this step does nothing and pulls stay + # anonymous. scripts/__tests__/workflow-docker-hub-login.test.mjs + # requires it. + - name: Log in to Docker Hub + env: + DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }} + DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }} + run: | + set -euo pipefail + if [ -z "$DOCKER_HUB_USERNAME" ] || [ -z "$DOCKER_HUB_PASSWORD" ]; then + echo "No Docker Hub credentials, so image pulls stay anonymous." + exit 0 + fi + printf '%s' "$DOCKER_HUB_PASSWORD" | + docker login --username "$DOCKER_HUB_USERNAME" --password-stdin + # No pre-`up` cleanup step any more: the project name is unique per job, so # a container leaked by a hard-killed prior run cannot hold this job's # name or its (ephemeral) port. Blanket-pruning would now be actively diff --git a/.github/workflows/integration-prisma-next.yml b/.github/workflows/integration-prisma-next.yml index afb6fe2ed2..158cf20d6f 100644 --- a/.github/workflows/integration-prisma-next.yml +++ b/.github/workflows/integration-prisma-next.yml @@ -172,6 +172,24 @@ jobs: - name: Build the @cipherstash/auth binding uses: ./.github/actions/build-auth-binding + # Docker Hub refuses pulls without a login after too many from one + # address, and RunsOn machines reach that limit. With either secret empty, + # as on a fork's pull request, this step does nothing and pulls stay + # anonymous. scripts/__tests__/workflow-docker-hub-login.test.mjs + # requires it. + - name: Log in to Docker Hub + env: + DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }} + DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }} + run: | + set -euo pipefail + if [ -z "$DOCKER_HUB_USERNAME" ] || [ -z "$DOCKER_HUB_PASSWORD" ]; then + echo "No Docker Hub credentials, so image pulls stay anonymous." + exit 0 + fi + printf '%s' "$DOCKER_HUB_PASSWORD" | + docker login --username "$DOCKER_HUB_USERNAME" --password-stdin + # No pre-`up` cleanup step any more: the project name is unique per job, so # a container leaked by a hard-killed prior run cannot hold this job's # name or its (ephemeral) port. Blanket-pruning would now be actively diff --git a/.github/workflows/integration-protect-ffi.yml b/.github/workflows/integration-protect-ffi.yml index ef7b59c75a..dc481976bf 100644 --- a/.github/workflows/integration-protect-ffi.yml +++ b/.github/workflows/integration-protect-ffi.yml @@ -341,6 +341,24 @@ jobs: # Must name runs-on's image; see scripts/__tests__/workflow-mise-cache-image.test.mjs cache_key_prefix: mise-v1-ubuntu-2404 + # Docker Hub refuses pulls without a login after too many from one + # address, and RunsOn machines reach that limit. With either secret empty, + # as on a fork's pull request, this step does nothing and pulls stay + # anonymous. scripts/__tests__/workflow-docker-hub-login.test.mjs + # requires it. + - name: Log in to Docker Hub + env: + DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }} + DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }} + run: | + set -euo pipefail + if [ -z "$DOCKER_HUB_USERNAME" ] || [ -z "$DOCKER_HUB_PASSWORD" ]; then + echo "No Docker Hub credentials, so image pulls stay anonymous." + exit 0 + fi + printf '%s' "$DOCKER_HUB_PASSWORD" | + docker login --username "$DOCKER_HUB_USERNAME" --password-stdin + # One task, four things the suite cannot run without (see # integration-tests/tasks.toml): `pnpm install --frozen-lockfile` (a # no-op here — the step above already ran it), `docker compose up` for diff --git a/.github/workflows/integration-supabase.yml b/.github/workflows/integration-supabase.yml index f4ea9d2723..b0146d6585 100644 --- a/.github/workflows/integration-supabase.yml +++ b/.github/workflows/integration-supabase.yml @@ -251,6 +251,24 @@ jobs: - name: Build the @cipherstash/auth binding uses: ./.github/actions/build-auth-binding + # Docker Hub refuses pulls without a login after too many from one + # address, and RunsOn machines reach that limit. With either secret empty, + # as on a fork's pull request, this step does nothing and pulls stay + # anonymous. scripts/__tests__/workflow-docker-hub-login.test.mjs + # requires it. + - name: Log in to Docker Hub + env: + DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }} + DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }} + run: | + set -euo pipefail + if [ -z "$DOCKER_HUB_USERNAME" ] || [ -z "$DOCKER_HUB_PASSWORD" ]; then + echo "No Docker Hub credentials, so image pulls stay anonymous." + exit 0 + fi + printf '%s' "$DOCKER_HUB_PASSWORD" | + docker login --username "$DOCKER_HUB_USERNAME" --password-stdin + # No pre-`up` cleanup step any more: the project name is unique per job, so # a container leaked by a hard-killed prior run cannot hold this job's # name or its (ephemeral) port. Blanket-pruning would now be actively diff --git a/.github/workflows/release-postgres-eql-image.yml b/.github/workflows/release-postgres-eql-image.yml index 9615ecacf2..eec9dbfdae 100644 --- a/.github/workflows/release-postgres-eql-image.yml +++ b/.github/workflows/release-postgres-eql-image.yml @@ -135,6 +135,24 @@ jobs: # The Dockerfile COPYs it from its own build context. path: packages/eql/docker/ + # Docker Hub refuses pulls without a login after too many from one + # address, and RunsOn machines reach that limit. With either secret empty, + # as on a fork's pull request, this step does nothing and pulls stay + # anonymous. scripts/__tests__/workflow-docker-hub-login.test.mjs + # requires it. + - name: Log in to Docker Hub + env: + DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }} + DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }} + run: | + set -euo pipefail + if [ -z "$DOCKER_HUB_USERNAME" ] || [ -z "$DOCKER_HUB_PASSWORD" ]; then + echo "No Docker Hub credentials, so image pulls stay anonymous." + exit 0 + fi + printf '%s' "$DOCKER_HUB_PASSWORD" | + docker login --username "$DOCKER_HUB_USERNAME" --password-stdin + - name: Set up QEMU uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3 with: diff --git a/.github/workflows/test-eql.yml b/.github/workflows/test-eql.yml index 8d905b05ec..f47c598904 100644 --- a/.github/workflows/test-eql.yml +++ b/.github/workflows/test-eql.yml @@ -363,6 +363,24 @@ jobs: # `save-if: false` so a fast-finishing light job can't win the save race # and overwrite the key with a deps-less target/. + # Docker Hub refuses pulls without a login after too many from one + # address, and RunsOn machines reach that limit. With either secret empty, + # as on a fork's pull request, this step does nothing and pulls stay + # anonymous. scripts/__tests__/workflow-docker-hub-login.test.mjs + # requires it. + - name: Log in to Docker Hub + env: + DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }} + DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }} + run: | + set -euo pipefail + if [ -z "$DOCKER_HUB_USERNAME" ] || [ -z "$DOCKER_HUB_PASSWORD" ]; then + echo "No Docker Hub credentials, so image pulls stay anonymous." + exit 0 + fi + printf '%s' "$DOCKER_HUB_PASSWORD" | + docker login --username "$DOCKER_HUB_USERNAME" --password-stdin + - name: Setup database (Postgres 17) run: | mise run postgres:up "postgres-${POSTGRES_VERSION}" --extra-args "--detach --wait" @@ -445,6 +463,24 @@ jobs: name: nextest-archive path: packages/eql + # Docker Hub refuses pulls without a login after too many from one + # address, and RunsOn machines reach that limit. With either secret empty, + # as on a fork's pull request, this step does nothing and pulls stay + # anonymous. scripts/__tests__/workflow-docker-hub-login.test.mjs + # requires it. + - name: Log in to Docker Hub + env: + DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }} + DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }} + run: | + set -euo pipefail + if [ -z "$DOCKER_HUB_USERNAME" ] || [ -z "$DOCKER_HUB_PASSWORD" ]; then + echo "No Docker Hub credentials, so image pulls stay anonymous." + exit 0 + fi + printf '%s' "$DOCKER_HUB_PASSWORD" | + docker login --username "$DOCKER_HUB_USERNAME" --password-stdin + - name: Setup database (Postgres ${{ matrix.postgres-version }}) run: | mise run postgres:up "postgres-${POSTGRES_VERSION}" --extra-args "--detach --wait" @@ -491,6 +527,24 @@ jobs: shared-key: sqlx-tests save-if: false + # Docker Hub refuses pulls without a login after too many from one + # address, and RunsOn machines reach that limit. With either secret empty, + # as on a fork's pull request, this step does nothing and pulls stay + # anonymous. scripts/__tests__/workflow-docker-hub-login.test.mjs + # requires it. + - name: Log in to Docker Hub + env: + DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }} + DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }} + run: | + set -euo pipefail + if [ -z "$DOCKER_HUB_USERNAME" ] || [ -z "$DOCKER_HUB_PASSWORD" ]; then + echo "No Docker Hub credentials, so image pulls stay anonymous." + exit 0 + fi + printf '%s' "$DOCKER_HUB_PASSWORD" | + docker login --username "$DOCKER_HUB_USERNAME" --password-stdin + - name: Setup database (Postgres ${{ matrix.postgres-version }}) run: | mise run postgres:up "postgres-${POSTGRES_VERSION}" --extra-args "--detach --wait" @@ -558,6 +612,13 @@ jobs: services: encryption-postgres: image: postgres:17 + # Docker Hub refuses pulls without a login after too many from one + # address, and RunsOn machines reach that limit. The runner skips the + # login when either value is empty, as on a fork's pull request, and + # then pulls anonymously. + credentials: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_PASSWORD }} env: POSTGRES_PASSWORD: postgres # Container port only: Docker picks the host port, and the test step @@ -828,6 +889,24 @@ jobs: workspaces: packages/eql shared-key: sqlx-tests save-if: false + # Docker Hub refuses pulls without a login after too many from one + # address, and RunsOn machines reach that limit. With either secret empty, + # as on a fork's pull request, this step does nothing and pulls stay + # anonymous. scripts/__tests__/workflow-docker-hub-login.test.mjs + # requires it. + - name: Log in to Docker Hub + env: + DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }} + DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }} + run: | + set -euo pipefail + if [ -z "$DOCKER_HUB_USERNAME" ] || [ -z "$DOCKER_HUB_PASSWORD" ]; then + echo "No Docker Hub credentials, so image pulls stay anonymous." + exit 0 + fi + printf '%s' "$DOCKER_HUB_PASSWORD" | + docker login --username "$DOCKER_HUB_USERNAME" --password-stdin + - name: Setup database run: | mise run postgres:up "postgres-${POSTGRES_VERSION}" --extra-args "--detach --wait" @@ -1002,6 +1081,24 @@ jobs: workspaces: packages/eql shared-key: sqlx-tests save-if: false + # Docker Hub refuses pulls without a login after too many from one + # address, and RunsOn machines reach that limit. With either secret empty, + # as on a fork's pull request, this step does nothing and pulls stay + # anonymous. scripts/__tests__/workflow-docker-hub-login.test.mjs + # requires it. + - name: Log in to Docker Hub + env: + DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }} + DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }} + run: | + set -euo pipefail + if [ -z "$DOCKER_HUB_USERNAME" ] || [ -z "$DOCKER_HUB_PASSWORD" ]; then + echo "No Docker Hub credentials, so image pulls stay anonymous." + exit 0 + fi + printf '%s' "$DOCKER_HUB_PASSWORD" | + docker login --username "$DOCKER_HUB_USERNAME" --password-stdin + - name: Setup database (Postgres 17) run: | mise run postgres:up "postgres-${POSTGRES_VERSION}" --extra-args "--detach --wait" diff --git a/scripts/__tests__/workflow-docker-hub-login.test.mjs b/scripts/__tests__/workflow-docker-hub-login.test.mjs new file mode 100644 index 0000000000..96e4c09551 --- /dev/null +++ b/scripts/__tests__/workflow-docker-hub-login.test.mjs @@ -0,0 +1,411 @@ +import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs' +import { dirname, join, relative } from 'node:path' +import { describe, expect, it } from 'vitest' +import { expr } from './lib/expressions.mjs' +import { REPO_ROOT } from './lib/repo-root.mjs' +import { readWorkflow, workflowFiles } from './lib/workflows.mjs' + +/** + * Every RunsOn job logs in to Docker Hub before it pulls an image. + * + * Docker Hub refuses pulls without a login after too many from one address. + * RunsOn machines reach that limit: on #1419, Postgres shards failed with + * `toomanyrequests` before a single test ran, and failed again on a re-run. + * So a RunsOn job that may pull an image logs in first, with the + * `DOCKER_HUB_USERNAME` and `DOCKER_HUB_PASSWORD` secrets. + * + * The login must do nothing when either secret is empty. That is the case on a + * fork's pull request, and on Dependabot's, and the job must still run there. + * + * - A service or job container from Docker Hub sets `credentials` from the + * two secrets. The runner skips that login when either value is empty + * (`ContainerRegistryLogin` in actions/runner). + * - Any other pull needs a `run:` step before it that pipes the password to + * `docker login --password-stdin`, and exits early when either secret is + * empty. + * + * "May pull" is decided without knowing the registry, so it fails closed. A + * step that starts or builds a container counts, whichever registry its image + * comes from. That covers a `docker` command in the step, a `docker/` action + * that pulls, a local composite action that does either, and a `mise run` of a + * task that reaches either through its body, its `depends`, or a nested + * `mise run`. A login a job did not need costs one step and nothing else. + * + * Only a literal `runs-on=` label counts as RunsOn. GitHub-hosted runners are + * not limited this way, and Blacksmith jobs are leaving. + */ + +// --------------------------------------------------------------------------- +// What pulls an image +// --------------------------------------------------------------------------- + +/** A command that starts or builds a container, so may pull an image. */ +const PULLS = + /\bdocker(?:-compose\s+up\b|\s+(?:compose\b[^\n]*\bup\b|run\b|pull\b|create\b|build\b|buildx\s+build\b))/ + +/** + * `docker/` actions that pull: QEMU's binfmt image, the BuildKit image, and + * the base images of a build. Logging in and computing tags pull nothing. + */ +const PULLING_ACTION = /^docker\/(?!login-action@|metadata-action@)[\w-]+@/ + +const DOCKER_HUB_HOSTS = new Set([ + 'docker.io', + 'index.docker.io', + 'registry-1.docker.io', +]) + +/** Whether an image reference names Docker Hub, where a bare name resolves. */ +export function onDockerHub(image) { + const first = String(image).split('/')[0] + const isHost = + String(image).includes('/') && + (first.includes('.') || first.includes(':') || first === 'localhost') + return !isHost || DOCKER_HUB_HOSTS.has(first) +} + +// --------------------------------------------------------------------------- +// mise tasks +// --------------------------------------------------------------------------- + +const SKIP_DIRS = new Set(['node_modules', '.git', 'target', 'dist']) + +/** Every tracked-looking `mise.toml` / `mise..toml`, repo-relative. */ +function miseConfigs(dir = REPO_ROOT, found = []) { + for (const name of readdirSync(dir)) { + if (SKIP_DIRS.has(name)) continue + const path = join(dir, name) + if (statSync(path).isDirectory()) miseConfigs(path, found) + else if (/^\.?mise(\.[\w-]+)?\.toml$/.test(name)) + found.push(relative(REPO_ROOT, path)) + } + return found +} + +const parseStringArray = (inner) => + [...inner.matchAll(/"([^"]+)"|'([^']+)'/g)].map((m) => m[1] ?? m[2]) + +function parseIncludes(text) { + const section = /^\[task_config\][^\n]*\n([\s\S]*?)(?=^\[|$(?![\s\S]))/m.exec( + text, + ) + const array = /^includes\s*=\s*\[([^\]]*)\]/m.exec(section?.[1] ?? '') + return array ? parseStringArray(array[1]) : [] +} + +/** + * Task blocks. A mise config writes `[tasks."name"]`; an included file makes + * every top-level table a task, `["name"]`. + */ +function parseTomlTasks(text, { bareTables }) { + const header = bareTables + ? /^\[(?:"([^"]+)"|([\w:.-]+))\]/ + : /^\[tasks\.(?:"([^"]+)"|([\w:.-]+))\]/ + return text + .split(/^(?=\[)/m) + .map((block) => ({ match: header.exec(block), block })) + .filter(({ match }) => match) + .map(({ match, block }) => ({ name: match[1] ?? match[2], body: block })) +} + +/** File tasks: `tasks/test/splinter.sh` is the task `test:splinter`. */ +function fileTasks(dir, base = dir, found = []) { + for (const name of readdirSync(dir)) { + const path = join(dir, name) + if (statSync(path).isDirectory()) fileTasks(path, base, found) + else if (!name.endsWith('.toml')) + found.push({ + name: relative(base, path) + .replace(/\.[^./]+$/, '') + .split('/') + .join(':'), + body: readFileSync(path, 'utf8'), + }) + } + return found +} + +/** + * Task name -> bodies. Names repeat across configs (two packages can each + * have a `setup`), so a name keeps every body, and pulls if any of them does. + * That is the fail-closed direction. + */ +function taskIndex() { + const index = new Map() + const add = ({ name, body }) => { + if (!index.has(name)) index.set(name, []) + index.get(name).push(body) + } + for (const config of miseConfigs()) { + const text = readFileSync(join(REPO_ROOT, config), 'utf8') + for (const task of parseTomlTasks(text, { bareTables: false })) add(task) + for (const include of parseIncludes(text)) { + const path = join(REPO_ROOT, dirname(config), include) + if (!existsSync(path)) continue + if (statSync(path).isDirectory()) fileTasks(path).forEach(add) + else + parseTomlTasks(readFileSync(path, 'utf8'), { + bareTables: true, + }).forEach(add) + } + } + return index +} + +const stripCommentLines = (text) => text.replace(/^[ \t]*#(?!MISE).*$/gm, '') + +// A quote starts a command only at the start of a line, as in a TOML +// `run = [ "mise run …" ]` entry. Mid-line it is a message to the reader. +const COMMAND_START = String.raw`(?:^[ \t]*["']?|(?:&&|\|\||[;|(){}])[ \t]*)` + +function invokes(text, taskName) { + const escaped = taskName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + return new RegExp( + `${COMMAND_START}mise\\s+run\\s+[^\\n'"]*?(? + [...body.matchAll(/depends\s*=\s*\[([^\]]*)\]/g)].flatMap((m) => + parseStringArray(m[1]), + ) + +/** The names of every task that may pull an image, directly or through others. */ +function pullingTasks(index) { + const pulling = new Set( + [...index] + .filter(([, bodies]) => + bodies.some((body) => PULLS.test(stripCommentLines(body))), + ) + .map(([name]) => name), + ) + // Grow the set until nothing new reaches a member: a fixpoint, so a cycle + // between tasks cannot loop. + let grew = true + while (grew) { + grew = false + for (const [name, bodies] of index) { + if (pulling.has(name)) continue + const reaches = bodies.some( + (body) => + dependsOf(body).some((dep) => pulling.has(dep)) || + [...pulling].some((target) => invokes(body, target)), + ) + if (reaches) { + pulling.add(name) + grew = true + } + } + } + return pulling +} + +const PULLING_TASKS = pullingTasks(taskIndex()) + +// --------------------------------------------------------------------------- +// Steps and jobs +// --------------------------------------------------------------------------- + +/** Whether one step may pull an image. `seen` guards composite-action cycles. */ +export function stepPulls(step, seen = new Set()) { + const uses = typeof step?.uses === 'string' ? step.uses.trim() : '' + if (PULLING_ACTION.test(uses)) return true + if (uses.startsWith('./')) { + const dir = uses.replace(/^\.\//, '').replace(/\/$/, '') + if (seen.has(dir)) return false + seen.add(dir) + for (const file of ['action.yml', 'action.yaml']) { + const rel = `${dir}/${file}` + if (!existsSync(join(REPO_ROOT, rel))) continue + const steps = readWorkflow(rel)?.runs?.steps ?? [] + return steps.some((inner) => stepPulls(inner, seen)) + } + return false + } + const run = typeof step?.run === 'string' ? stripCommentLines(step.run) : '' + return ( + PULLS.test(run) || [...PULLING_TASKS].some((task) => invokes(run, task)) + ) +} + +const USERNAME = expr('secrets.DOCKER_HUB_USERNAME') +const PASSWORD = expr('secrets.DOCKER_HUB_PASSWORD') + +/** Whether a step logs in to Docker Hub, and does nothing without the secrets. */ +export function loginFinding(step) { + const run = typeof step?.run === 'string' ? step.run : '' + if (!/\bdocker\s+login\b/.test(run)) return 'not a login' + if ( + step.env?.DOCKER_HUB_USERNAME !== USERNAME || + step.env?.DOCKER_HUB_PASSWORD !== PASSWORD + ) + return `does not read ${USERNAME} and ${PASSWORD} into DOCKER_HUB_USERNAME and DOCKER_HUB_PASSWORD` + if (!/--password-stdin/.test(run)) + return 'does not pass the password on stdin' + if ( + !/-z\s+"\$DOCKER_HUB_USERNAME"/.test(run) || + !/-z\s+"\$DOCKER_HUB_PASSWORD"/.test(run) + ) + return 'does not skip the login when a secret is empty, so a fork pull request would fail' + return null +} + +const isRunsOn = (job) => String(job?.['runs-on'] ?? '').startsWith('runs-on=') + +/** Every finding for one job, or [] when it is correct. */ +export function jobFindings(where, job) { + if (!isRunsOn(job)) return [] + const findings = [] + const containers = [ + ...Object.entries(job.services ?? {}).map(([name, svc]) => [ + `service ${name}`, + svc, + ]), + ...(job.container ? [['container', job.container]] : []), + ] + for (const [what, def] of containers) { + const image = typeof def === 'string' ? def : def?.image + if (!image || !onDockerHub(image)) continue + if ( + def?.credentials?.username !== USERNAME || + def?.credentials?.password !== PASSWORD + ) + findings.push( + `${where}: ${what} pulls ${image} from Docker Hub without credentials: { username: ${USERNAME}, password: ${PASSWORD} }`, + ) + } + const steps = job.steps ?? [] + const firstPull = steps.findIndex((step) => stepPulls(step)) + if (firstPull === -1) return findings + const logins = steps + .map((step, i) => ({ i, finding: loginFinding(step) })) + .filter(({ finding }) => finding !== 'not a login') + for (const { i, finding } of logins) + if (finding) findings.push(`${where}: step ${i + 1} ${finding}`) + const pullName = steps[firstPull].name ?? steps[firstPull].uses ?? 'run' + if (!logins.some(({ i }) => i < firstPull)) + findings.push( + `${where}: step ${firstPull + 1} (${pullName}) may pull an image, and no Docker Hub login comes before it`, + ) + return findings +} + +function runsOnJobs() { + return workflowFiles().flatMap((file) => + Object.entries(readWorkflow(file)?.jobs ?? {}) + .filter(([, job]) => isRunsOn(job)) + .map(([name, job]) => ({ where: `${file} ${name}`, job })), + ) +} + +// --------------------------------------------------------------------------- + +describe('Docker Hub login on RunsOn', () => { + const jobs = runsOnJobs() + + it('finds the jobs it checks', () => { + // A discovery test that finds nothing passes having checked nothing. + expect(jobs.length).toBeGreaterThan(20) + expect( + jobs.filter(({ job }) => (job.steps ?? []).some((s) => stepPulls(s))) + .length, + ).toBeGreaterThan(8) + expect(PULLING_TASKS).toContain('postgres:up') + expect(PULLING_TASKS).toContain('setup') + }) + + it('logs in before every pull', () => { + expect(jobs.flatMap(({ where, job }) => jobFindings(where, job))).toEqual( + [], + ) + }) + + // Every job in the tree is correct, so the test above runs none of the + // branches that report a wrong one. These do. + const runsOn = 'runs-on=1/family=c8a+m8a/cpu=8' + const login = { + name: 'Log in to Docker Hub', + env: { DOCKER_HUB_USERNAME: USERNAME, DOCKER_HUB_PASSWORD: PASSWORD }, + run: [ + 'if [ -z "$DOCKER_HUB_USERNAME" ] || [ -z "$DOCKER_HUB_PASSWORD" ]; then', + ' exit 0', + 'fi', + 'printf \'%s\' "$DOCKER_HUB_PASSWORD" |', + ' docker login --username "$DOCKER_HUB_USERNAME" --password-stdin', + ].join('\n'), + } + const up = { name: 'Start Postgres', run: 'mise run postgres:up' } + + it('reports a pull with no login before it', () => { + expect(jobFindings('w j', { 'runs-on': runsOn, steps: [up] })).toEqual([ + expect.stringMatching(/no Docker Hub login comes before it/), + ]) + expect( + jobFindings('w j', { 'runs-on': runsOn, steps: [up, login] }), + ).toEqual([expect.stringMatching(/no Docker Hub login comes before it/)]) + expect( + jobFindings('w j', { 'runs-on': runsOn, steps: [login, up] }), + ).toEqual([]) + // Not RunsOn: out of scope. + expect( + jobFindings('w j', { 'runs-on': 'ubuntu-latest', steps: [up] }), + ).toEqual([]) + }) + + it('reports a login that would fail on a fork pull request', () => { + const noSkip = { + ...login, + run: 'printf \'%s\' "$DOCKER_HUB_PASSWORD" | docker login --username "$DOCKER_HUB_USERNAME" --password-stdin', + } + expect(loginFinding(noSkip)).toMatch(/fork pull request/) + expect(loginFinding({ ...login, env: {} })).toMatch(/does not read/) + expect(loginFinding(login)).toBeNull() + }) + + it('reports a Docker Hub service with no credentials', () => { + const job = (credentials) => ({ + 'runs-on': runsOn, + services: { pg: { image: 'postgres:17', credentials } }, + steps: [], + }) + expect(jobFindings('w j', job(undefined))).toEqual([ + expect.stringMatching(/service pg pulls postgres:17/), + ]) + expect( + jobFindings('w j', job({ username: USERNAME, password: PASSWORD })), + ).toEqual([]) + expect( + jobFindings('w j', { + 'runs-on': runsOn, + services: { pg: { image: 'ghcr.io/cipherstash/postgres-eql:17' } }, + steps: [], + }), + ).toEqual([]) + }) + + it('recognises what may pull an image', () => { + expect( + stepPulls({ run: 'docker compose -p x -f y.yml up -d --wait' }), + ).toBe(true) + expect(stepPulls({ run: 'docker run --rm alpine true' })).toBe(true) + expect( + stepPulls({ run: 'mise run --output prefix postgres:up pg-17' }), + ).toBe(true) + expect(stepPulls({ uses: './.github/actions/integration-db' })).toBe(true) + expect(stepPulls({ uses: 'docker/setup-qemu-action@abc' })).toBe(true) + expect(stepPulls({ uses: 'docker/login-action@abc' })).toBe(false) + expect(stepPulls({ run: 'docker exec -i pg psql -f-' })).toBe(false) + expect(stepPulls({ run: 'docker compose down' })).toBe(false) + expect(stepPulls({ run: '# docker run in a comment' })).toBe(false) + }) + + it('reads which registry an image names', () => { + expect(onDockerHub('postgres:17')).toBe(true) + expect(onDockerHub('supabase/postgres:17.4.1.048')).toBe(true) + expect(onDockerHub('docker.io/library/postgres:17')).toBe(true) + expect(onDockerHub('ghcr.io/cipherstash/postgres-eql:17')).toBe(false) + expect(onDockerHub('public.ecr.aws/docker/library/postgres:17')).toBe(false) + expect(onDockerHub('localhost:5000/pg')).toBe(false) + }) +}) From 4818bb065b4d073aca08ef83fafa1dc952152828 Mon Sep 17 00:00:00 2001 From: Lindsay Holmwood Date: Thu, 29 Oct 2026 21:08:46 +1100 Subject: [PATCH 05/23] ci(runners): keep the service login working without the secrets The previous commit gave Test EQL's Postgres service `username:` and `password:` keys from the two Docker Hub secrets. The secrets do not exist yet, so both values were empty. GitHub rejects an empty value for either key before the runner starts: "The template is not valid ... Unexpected value ''". The `rust-crates` job failed at "Set up job". A fork's pull request would fail the same way. `credentials` now takes one expression. With both secrets set, it builds the username and password from them, through `toJSON`, so any character is escaped. With either secret empty, it gives `{}`. The workflow schema allows that, because neither key is required. The runner then skips the login and pulls without one. The test now rejects the key form and requires the `fromJSON('{}')` fallback. --- .github/workflows/test-eql.yml | 16 ++++--- .../workflow-docker-hub-login.test.mjs | 46 +++++++++++++++---- 2 files changed, 46 insertions(+), 16 deletions(-) diff --git a/.github/workflows/test-eql.yml b/.github/workflows/test-eql.yml index f47c598904..7e10336d9f 100644 --- a/.github/workflows/test-eql.yml +++ b/.github/workflows/test-eql.yml @@ -613,12 +613,16 @@ jobs: encryption-postgres: image: postgres:17 # Docker Hub refuses pulls without a login after too many from one - # address, and RunsOn machines reach that limit. The runner skips the - # login when either value is empty, as on a fork's pull request, and - # then pulls anonymously. - credentials: - username: ${{ secrets.DOCKER_HUB_USERNAME }} - password: ${{ secrets.DOCKER_HUB_PASSWORD }} + # address, and RunsOn machines reach that limit. One expression, not + # `username:` and `password:` keys: GitHub rejects an empty value for + # either key ("Unexpected value ''"), which fails the job on a fork's + # pull request. With either secret empty this gives `{}`, and the + # runner then pulls without a login. + credentials: >- + ${{ secrets.DOCKER_HUB_USERNAME != '' && secrets.DOCKER_HUB_PASSWORD != '' + && fromJSON(format('{{"username":{0},"password":{1}}}', + toJSON(secrets.DOCKER_HUB_USERNAME), toJSON(secrets.DOCKER_HUB_PASSWORD))) + || fromJSON('{}') }} env: POSTGRES_PASSWORD: postgres # Container port only: Docker picks the host port, and the test step diff --git a/scripts/__tests__/workflow-docker-hub-login.test.mjs b/scripts/__tests__/workflow-docker-hub-login.test.mjs index 96e4c09551..710da4ca19 100644 --- a/scripts/__tests__/workflow-docker-hub-login.test.mjs +++ b/scripts/__tests__/workflow-docker-hub-login.test.mjs @@ -17,9 +17,11 @@ import { readWorkflow, workflowFiles } from './lib/workflows.mjs' * The login must do nothing when either secret is empty. That is the case on a * fork's pull request, and on Dependabot's, and the job must still run there. * - * - A service or job container from Docker Hub sets `credentials` from the - * two secrets. The runner skips that login when either value is empty - * (`ContainerRegistryLogin` in actions/runner). + * - A service or job container from Docker Hub sets `credentials` to one + * expression that reads both secrets and falls back to `fromJSON('{}')`. + * `username:` and `password:` keys do not work: GitHub rejects an empty + * value for either ("Unexpected value ''"), so the job fails at "Set up + * job". With `{}`, the runner pulls without a login. * - Any other pull needs a `run:` step before it that pipes the password to * `docker login --password-stdin`, and exits early when either secret is * empty. @@ -251,6 +253,22 @@ export function loginFinding(step) { return null } +/** Whether a container's `credentials` log in, and still work without the secrets. */ +export function credentialsFinding(credentials) { + if (credentials === undefined) return 'sets no credentials' + if (typeof credentials !== 'string') + return "sets username and password keys, which fail at 'Set up job' when a secret is empty; use one expression with a fromJSON('{}') fallback" + const flat = credentials.replace(/\s+/g, ' ') + if ( + !flat.includes('secrets.DOCKER_HUB_USERNAME') || + !flat.includes('secrets.DOCKER_HUB_PASSWORD') + ) + return 'does not read secrets.DOCKER_HUB_USERNAME and secrets.DOCKER_HUB_PASSWORD' + if (!flat.includes("|| fromJSON('{}')")) + return "has no || fromJSON('{}') fallback for when a secret is empty" + return null +} + const isRunsOn = (job) => String(job?.['runs-on'] ?? '').startsWith('runs-on=') /** Every finding for one job, or [] when it is correct. */ @@ -267,12 +285,10 @@ export function jobFindings(where, job) { for (const [what, def] of containers) { const image = typeof def === 'string' ? def : def?.image if (!image || !onDockerHub(image)) continue - if ( - def?.credentials?.username !== USERNAME || - def?.credentials?.password !== PASSWORD - ) + const finding = credentialsFinding(def?.credentials) + if (finding) findings.push( - `${where}: ${what} pulls ${image} from Docker Hub without credentials: { username: ${USERNAME}, password: ${PASSWORD} }`, + `${where}: ${what} pulls ${image} from Docker Hub, and ${finding}`, ) } const steps = job.steps ?? [] @@ -370,11 +386,21 @@ describe('Docker Hub login on RunsOn', () => { steps: [], }) expect(jobFindings('w j', job(undefined))).toEqual([ - expect.stringMatching(/service pg pulls postgres:17/), + expect.stringMatching( + /service pg pulls postgres:17.*sets no credentials/, + ), ]) + // The form GitHub rejects when a secret is empty. expect( jobFindings('w j', job({ username: USERNAME, password: PASSWORD })), - ).toEqual([]) + ).toEqual([expect.stringMatching(/fail at 'Set up job'/)]) + const flat = `secrets.DOCKER_HUB_USERNAME != '' && secrets.DOCKER_HUB_PASSWORD != '' && fromJSON(format('{{"username":{0},"password":{1}}}', toJSON(secrets.DOCKER_HUB_USERNAME), toJSON(secrets.DOCKER_HUB_PASSWORD)))` + expect(jobFindings('w j', job(expr(flat)))).toEqual([ + expect.stringMatching(/no \|\| fromJSON\('\{\}'\) fallback/), + ]) + expect(jobFindings('w j', job(expr(`${flat} || fromJSON('{}')`)))).toEqual( + [], + ) expect( jobFindings('w j', { 'runs-on': runsOn, From b770e5334dcb3a5a43d0e902784ae5347146e262 Mon Sep 17 00:00:00 2001 From: Lindsay Holmwood Date: Thu, 29 Oct 2026 21:27:43 +1100 Subject: [PATCH 06/23] ci(runners): build the gnu FFI binaries on RunsOn A 4 vCPU job counts as heavy when GitHub's standard runner takes more than twice as long as Blacksmith. The runner trial in #1297 did not time the FFI builds. So they ran on `ubuntu-24.04` three times, through `ffi-preflight.yml`. That workflow cannot publish. These are the medians: - linux-x64-gnu: 258 s on GitHub's runner, 125 s on Blacksmith (2.06). - linux-arm64-gnu: 288 s on GitHub's runner, 143 s on Blacksmith (2.01). Both are only just over the line. They move to RunsOn with 8 vCPUs and Ubuntu 24.04, as Blacksmith used. The runner comes from `runnerFor` in the matrix script, not from the workflow. A matrix value cannot read `${{ github.run_id }}`, so the script puts `GITHUB_RUN_ID` into the label. It throws when the run ID is missing, because a label without it would be shared by every run. Three Linux jobs stay as they are: - The musl build could not be timed. Its image pins `musl-dev=1.2.6-r2`. Alpine no longer serves that version, so the build fails on any runner. That also breaks the next FFI release. - The WASM and wrapper build needs every binary, so it never ran. - Miri and tests-rust took 1.35 and 1.36 times as long on GitHub's runner, so they are light. --- scripts/__tests__/ffi-release-matrix.test.mjs | 18 ++++++++++---- scripts/ffi-release-matrix.mjs | 24 +++++++++++++------ 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/scripts/__tests__/ffi-release-matrix.test.mjs b/scripts/__tests__/ffi-release-matrix.test.mjs index 3a71919ac4..014ee1f71c 100644 --- a/scripts/__tests__/ffi-release-matrix.test.mjs +++ b/scripts/__tests__/ffi-release-matrix.test.mjs @@ -56,7 +56,9 @@ function logFileOf(scriptName) { return redirect ? redirect[1] : null } -const MATRIX = releaseMatrix(TRIPLES) +const RUN_ID = '1234' +const MATRIX = releaseMatrix(TRIPLES, RUN_ID) +const RUNS_ON = `runs-on=${RUN_ID}/family=c8a+m8a/cpu=8/image=ubuntu24-full-x64/volume=80gb/extras=s3-cache` describe('the platform fixture matches the package', () => { it('covers exactly the platforms this package publishes', () => { @@ -157,14 +159,14 @@ describe('release matrix', () => { { platform: 'linux-x64-gnu', target: 'x86_64-unknown-linux-gnu', - os: 'blacksmith-4vcpu-ubuntu-2404', + os: RUNS_ON, script: 'zigbuild', log: 'zig.log', }, { platform: 'linux-arm64-gnu', target: 'aarch64-unknown-linux-gnu', - os: 'blacksmith-4vcpu-ubuntu-2404', + os: RUNS_ON, script: 'zigbuild', log: 'zig.log', }, @@ -181,7 +183,15 @@ describe('release matrix', () => { it('sends a platform the table does not name to a Linux runner', () => { // The fallback arm, which the table above cannot reach. A seventh platform // added tomorrow gets Blacksmith unless `runnerFor` is taught otherwise. - expect(runnerFor('linux-arm64-musl')).toBe('blacksmith-4vcpu-ubuntu-2404') + expect(runnerFor('linux-arm64-musl', RUN_ID)).toBe( + 'blacksmith-4vcpu-ubuntu-2404', + ) + }) + + it('refuses a RunsOn label with no run ID in it', () => { + // `runs-on=undefined/…` would be one label shared by every run, so one + // run's machine could take another run's job. + expect(() => runnerFor('linux-x64-gnu', '')).toThrow(/GITHUB_RUN_ID/) }) it('is empty for an empty mapping, rather than inventing platforms', () => { diff --git a/scripts/ffi-release-matrix.mjs b/scripts/ffi-release-matrix.mjs index c4475fbf7e..f39688e7c3 100644 --- a/scripts/ffi-release-matrix.mjs +++ b/scripts/ffi-release-matrix.mjs @@ -44,14 +44,24 @@ const PLATFORMS_DIR = join( /** * Where each platform builds. * - * Linux goes to Blacksmith (the repo's standard Linux runner); the Darwin and - * Windows builds need GitHub-hosted images for their SDKs. Both Darwin - * platforms share `macos-latest` and cross-compile — which is exactly why - * `target` is explicit. + * Darwin and Windows need GitHub-hosted images for their SDKs; both Darwin + * platforms share `macos-latest` and cross-compile, which is why `target` is + * explicit. The gnu builds took just over twice as long on GitHub's standard + * runner as on Blacksmith 4 vCPU, so they run on RunsOn. A matrix value cannot + * read `${{ github.run_id }}`, so the run ID that makes the RunsOn label unique + * is passed in. musl stays on Blacksmith: it could not be timed, because its + * image pins a `musl-dev` that Alpine no longer serves. */ -export function runnerFor(platform) { +export function runnerFor(platform, runId = process.env.GITHUB_RUN_ID) { if (platform.startsWith('win32')) return 'windows-latest' if (platform.startsWith('darwin')) return 'macos-latest' + if (platform.startsWith('linux-') && platform.endsWith('-gnu')) { + if (!runId) + throw new Error( + `${platform} builds on RunsOn, whose label needs the run ID; set GITHUB_RUN_ID`, + ) + return `runs-on=${runId}/family=c8a+m8a/cpu=8/image=ubuntu24-full-x64/volume=80gb/extras=s3-cache` + } return 'blacksmith-4vcpu-ubuntu-2404' } @@ -97,11 +107,11 @@ export function triplesFromPlatformManifests(dir = PLATFORMS_DIR) { * `triples` is a platform name -> Rust target triple mapping, as * `triplesFromPlatformManifests()` (or `neon list-platforms`) produces. */ -export function releaseMatrix(triples) { +export function releaseMatrix(triples, runId = process.env.GITHUB_RUN_ID) { return Object.entries(triples).map(([platform, target]) => ({ platform, target, - os: runnerFor(platform), + os: runnerFor(platform, runId), ...buildFor(platform), })) } From 3ebcf55d163f0bb6f0508d19a17d321103382577 Mon Sep 17 00:00:00 2001 From: Lindsay Holmwood Date: Thu, 29 Oct 2026 21:43:08 +1100 Subject: [PATCH 07/23] ci(runners): wait for the apt lock on a fresh RunsOn machine On its first RunsOn run, the linux-arm64-gnu FFI build failed in its `apt-get install`: "Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 1720 (apt)". A RunsOn machine boots for each job, and apt was still running from boot. GitHub's and Blacksmith's images do not run apt at boot, so the step never met a held lock there. apt-get fails at once on a held lock unless told to wait. Both RunsOn jobs that install packages now pass `-o DPkg::Lock::Timeout=300`: the gnu FFI build's cross toolchain and the EQL docs build's Doxygen. --- .github/workflows/_build-eql-docs.yml | 6 ++++-- .github/workflows/_build-ffi-artifacts.yml | 7 +++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/_build-eql-docs.yml b/.github/workflows/_build-eql-docs.yml index d009a6fd7d..13f2962628 100644 --- a/.github/workflows/_build-eql-docs.yml +++ b/.github/workflows/_build-eql-docs.yml @@ -53,10 +53,12 @@ jobs: cache: false # publish path; see _build-eql-sql.yml working_directory: packages/eql + # A fresh RunsOn machine can still be running apt from boot, and apt-get + # fails at once on a held lock unless told to wait for it. - name: Install Doxygen run: | - sudo apt-get update - sudo apt-get install -y doxygen + sudo apt-get -o DPkg::Lock::Timeout=300 update + sudo apt-get -o DPkg::Lock::Timeout=300 install -y doxygen - name: Generate documentation env: diff --git a/.github/workflows/_build-ffi-artifacts.yml b/.github/workflows/_build-ffi-artifacts.yml index 14b4541410..069c629864 100644 --- a/.github/workflows/_build-ffi-artifacts.yml +++ b/.github/workflows/_build-ffi-artifacts.yml @@ -114,12 +114,15 @@ jobs: # a native x86_64 build — so the other two legs were paying an # `apt-get update` (full package indexes) plus a ~200MB toolchain they do # not link against. + # + # A fresh RunsOn machine can still be running apt from boot, and apt-get + # fails at once on a held lock unless told to wait for it. - name: Install cross-compile toolchain (linux-arm64-gnu) if: ${{ matrix.cfg.platform == 'linux-arm64-gnu' }} run: | set -euo pipefail - sudo apt-get update - sudo apt-get install -y gcc-13-aarch64-linux-gnu + sudo apt-get -o DPkg::Lock::Timeout=300 update + sudo apt-get -o DPkg::Lock::Timeout=300 install -y gcc-13-aarch64-linux-gnu sudo ln -sf /usr/bin/aarch64-linux-gnu-gcc-13 /usr/bin/aarch64-linux-gnu-gcc # Rust comes from the runner image; only the TARGET has to be added. This From baa44716b7efecc9c39dd2fce20ad6a8f42613ec Mon Sep 17 00:00:00 2001 From: Lindsay Holmwood Date: Thu, 19 Nov 2026 22:31:14 +1100 Subject: [PATCH 08/23] ci(runners): move every Blacksmith job to a RunsOn machine of the same size Each job keeps its Blacksmith vCPU count and Ubuntu version. A 16 vCPU job gets the 16 vCPU RunsOn label with Ubuntu 22.04. A 4 vCPU job gets the 4 vCPU label with Ubuntu 24.04. The jobs this branch had moved to 8 vCPUs go back to their Blacksmith size. The three Linux platforms of the FFI release matrix move too. workflow-runs-on.test.mjs fails when a job names a Blacksmith label, or a RunsOn label that ADR 0004 does not name. It also fails when a job whose runner comes from a matrix is missing from MATRIX_RUNNERS. actionlint now lists no self-hosted labels, so it reports any Blacksmith label. It does not check a label that contains an expression, which every RunsOn label does. --- .github/actionlint.yaml | 25 ++--- .github/workflows/_build-eql-docs.yml | 2 +- .github/workflows/_build-eql-sql.yml | 2 +- .github/workflows/_build-ffi-artifacts.yml | 2 +- .github/workflows/_test-auth-refresh-soak.yml | 2 +- .github/workflows/bench-eql.yml | 2 +- .github/workflows/codeql.yml | 2 +- .github/workflows/crap-crates.yml | 4 +- .github/workflows/fta-v3.yml | 2 +- .github/workflows/fuzz.yml | 4 +- .github/workflows/integration-drizzle.yml | 2 +- .github/workflows/integration-prisma-next.yml | 2 +- .github/workflows/integration-protect-ffi.yml | 2 +- .github/workflows/integration-supabase.yml | 2 +- .github/workflows/lint-release.yml | 4 +- .github/workflows/macro-expand-eql.yml | 2 +- .github/workflows/miri.yml | 2 +- .../workflows/prisma-example-readme-e2e.yml | 2 +- .github/workflows/prisma-next-e2e.yml | 2 +- .github/workflows/release-golang.yml | 6 +- .../workflows/release-postgres-eql-image.yml | 6 +- .github/workflows/test-eql.yml | 32 +++--- .github/workflows/tests-bench.yml | 2 +- .github/workflows/tests-crates.yml | 4 +- .github/workflows/tests-golang.yml | 6 +- .github/workflows/tests-rust.yml | 2 +- .github/workflows/tests.yml | 10 +- .github/workflows/udeps.yml | 2 +- scripts/__tests__/ffi-release-matrix.test.mjs | 17 +-- scripts/__tests__/lib/runs-on.mjs | 52 +++++++++ scripts/__tests__/workflow-runs-on.test.mjs | 101 ++++++++++++++++++ scripts/ffi-release-matrix.mjs | 22 ++-- 32 files changed, 234 insertions(+), 95 deletions(-) create mode 100644 scripts/__tests__/lib/runs-on.mjs create mode 100644 scripts/__tests__/workflow-runs-on.test.mjs diff --git a/.github/actionlint.yaml b/.github/actionlint.yaml index 3fb7fe7da7..a5d35a8920 100644 --- a/.github/actionlint.yaml +++ b/.github/actionlint.yaml @@ -1,20 +1,9 @@ -# actionlint validates every `runs-on:` against the list of GitHub-hosted runner -# labels it ships with. Blacksmith runners are self-hosted from its perspective, -# so without this file each of the fourteen jobs using one is reported as an -# unknown label — and the release lint gate (.github/workflows/lint-release.yml) -# would be red on the day it lands, for reasons that have nothing to do with the -# release machinery it exists to check. +# actionlint checks every `runs-on:` label against the GitHub-hosted labels it +# knows, and against the self-hosted labels listed here. # -# Nothing complained before because actionlint has never run in this repository; -# lint-release.yml is what introduces it. -# -# RunsOn labels need no entry here. Each one starts with -# `runs-on=${{ github.run_id }}`, and actionlint does not check a label that -# contains an expression. +# The list is empty. Every self-hosted job runs on RunsOn, and each RunsOn +# label starts with `runs-on=${{ github.run_id }}`. actionlint does not check +# a label that contains an expression. So a Blacksmith label is now unknown, +# and actionlint reports it. self-hosted-runner: - labels: - - blacksmith-4vcpu-ubuntu-2404 - # Only light jobs still use this label: they run bash, compute a matrix or - # summarise results. The heavy jobs that used it, such as the Rust compiles - # and the Postgres suites, run on RunsOn instead. - - blacksmith-16vcpu-ubuntu-2204 + labels: [] diff --git a/.github/workflows/_build-eql-docs.yml b/.github/workflows/_build-eql-docs.yml index 13f2962628..6878893b4b 100644 --- a/.github/workflows/_build-eql-docs.yml +++ b/.github/workflows/_build-eql-docs.yml @@ -37,7 +37,7 @@ permissions: jobs: publish-docs: name: Build and publish documentation - runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=16/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 20 steps: diff --git a/.github/workflows/_build-eql-sql.yml b/.github/workflows/_build-eql-sql.yml index 8915a53fdd..2daf41fc07 100644 --- a/.github/workflows/_build-eql-sql.yml +++ b/.github/workflows/_build-eql-sql.yml @@ -57,7 +57,7 @@ permissions: jobs: build: name: Build EQL - runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=16/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 20 steps: diff --git a/.github/workflows/_build-ffi-artifacts.yml b/.github/workflows/_build-ffi-artifacts.yml index 069c629864..e354153eb3 100644 --- a/.github/workflows/_build-ffi-artifacts.yml +++ b/.github/workflows/_build-ffi-artifacts.yml @@ -361,7 +361,7 @@ jobs: # this job collects the six platform artifacts and uploads the complete set # as one artifact, so a caller downloads `ffi-tarballs` and has everything. needs: [binaries] - runs-on: blacksmith-4vcpu-ubuntu-2404 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=4/image=ubuntu24-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 45 steps: - uses: actions/checkout@v6 diff --git a/.github/workflows/_test-auth-refresh-soak.yml b/.github/workflows/_test-auth-refresh-soak.yml index 56cb24e4d2..5d28d82b88 100644 --- a/.github/workflows/_test-auth-refresh-soak.yml +++ b/.github/workflows/_test-auth-refresh-soak.yml @@ -12,7 +12,7 @@ permissions: jobs: soak: - runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=16/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 30 env: MISE_ENV: test diff --git a/.github/workflows/bench-eql.yml b/.github/workflows/bench-eql.yml index 7e0c023b05..6912f5130a 100644 --- a/.github/workflows/bench-eql.yml +++ b/.github/workflows/bench-eql.yml @@ -93,7 +93,7 @@ defaults: jobs: bench: name: "Bench EQL (Postgres 17)" - runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=16/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 60 env: diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 9a5b5072cf..2b6464ee4b 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -18,7 +18,7 @@ permissions: jobs: analyze: name: Analyze - runs-on: blacksmith-4vcpu-ubuntu-2404 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=4/image=ubuntu24-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 10 strategy: diff --git a/.github/workflows/crap-crates.yml b/.github/workflows/crap-crates.yml index 68f56520b7..6ce34e7aff 100644 --- a/.github/workflows/crap-crates.yml +++ b/.github/workflows/crap-crates.yml @@ -59,7 +59,7 @@ env: jobs: crap-stack-auth: name: CRAP (stack-auth) - runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=16/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 45 steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 @@ -83,7 +83,7 @@ jobs: crap-stack-encrypt: name: CRAP (stack-encrypt) - runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=16/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 45 steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 diff --git a/.github/workflows/fta-v3.yml b/.github/workflows/fta-v3.yml index df59df0651..7e03f8deb1 100644 --- a/.github/workflows/fta-v3.yml +++ b/.github/workflows/fta-v3.yml @@ -38,7 +38,7 @@ permissions: jobs: fta: name: Analyze v3 complexity - runs-on: blacksmith-4vcpu-ubuntu-2404 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=4/image=ubuntu24-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 10 steps: diff --git a/.github/workflows/fuzz.yml b/.github/workflows/fuzz.yml index baa8e8cd8f..04dd89c40e 100644 --- a/.github/workflows/fuzz.yml +++ b/.github/workflows/fuzz.yml @@ -65,7 +65,7 @@ jobs: # Not on the nightly schedule, which is the campaign's. A manual dispatch # runs both jobs. if: github.event_name != 'schedule' - runs-on: blacksmith-4vcpu-ubuntu-2404 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=4/image=ubuntu24-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 30 strategy: fail-fast: false @@ -112,7 +112,7 @@ jobs: fuzz-campaign: name: fuzz campaign (${{ matrix.slug }}) if: github.event_name != 'pull_request' - runs-on: blacksmith-4vcpu-ubuntu-2404 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=4/image=ubuntu24-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 30 strategy: fail-fast: false diff --git a/.github/workflows/integration-drizzle.yml b/.github/workflows/integration-drizzle.yml index dceaef7f7a..7ca4f75b36 100644 --- a/.github/workflows/integration-drizzle.yml +++ b/.github/workflows/integration-drizzle.yml @@ -204,7 +204,7 @@ on: jobs: integration: name: Drizzle v3 integration (db=${{ matrix.db }}) - runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu24-full-x64/volume=80gb/extras=s3-cache + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=4/image=ubuntu24-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 35 # No concurrency group: `integration-db` gives each job its own compose # project and ephemeral host ports, so live-DB jobs no longer contend and do diff --git a/.github/workflows/integration-prisma-next.yml b/.github/workflows/integration-prisma-next.yml index 158cf20d6f..85d4ae3420 100644 --- a/.github/workflows/integration-prisma-next.yml +++ b/.github/workflows/integration-prisma-next.yml @@ -114,7 +114,7 @@ on: jobs: integration: name: prisma-next v3 integration (db=${{ matrix.db }}) - runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu24-full-x64/volume=80gb/extras=s3-cache + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=4/image=ubuntu24-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 15 # No concurrency group: `integration-db` gives each job its own compose # project and ephemeral host ports, so live-DB jobs no longer contend and do diff --git a/.github/workflows/integration-protect-ffi.yml b/.github/workflows/integration-protect-ffi.yml index dc481976bf..aced4eeab0 100644 --- a/.github/workflows/integration-protect-ffi.yml +++ b/.github/workflows/integration-protect-ffi.yml @@ -160,7 +160,7 @@ concurrency: jobs: integration: name: protect-ffi integration suite - runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu24-full-x64/volume=80gb/extras=s3-cache + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=4/image=ubuntu24-full-x64/volume=80gb/extras=s3-cache # Generous, because a cold `build-ffi-binding` compiles the cipherstash # client graph from scratch. It is also the backstop for `mise run # start-db`, whose readiness loop retries `pg_isready` forever rather than diff --git a/.github/workflows/integration-supabase.yml b/.github/workflows/integration-supabase.yml index b0146d6585..ca257509d6 100644 --- a/.github/workflows/integration-supabase.yml +++ b/.github/workflows/integration-supabase.yml @@ -173,7 +173,7 @@ on: jobs: integration: name: Supabase v3 integration (db=${{ matrix.db }}) - runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu24-full-x64/volume=80gb/extras=s3-cache + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=4/image=ubuntu24-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 15 # No concurrency group: `integration-db` gives each job its own compose # project and ephemeral host ports, so live-DB jobs no longer contend and do diff --git a/.github/workflows/lint-release.yml b/.github/workflows/lint-release.yml index adde4c9332..0ea5dac8d1 100644 --- a/.github/workflows/lint-release.yml +++ b/.github/workflows/lint-release.yml @@ -6,7 +6,7 @@ name: Lint release tooling # pull request that touches any of it. # # actionlint is introduced here and nowhere else in the repo. It reads -# `.github/actionlint.yaml` for the Blacksmith runner label, and it runs +# `.github/actionlint.yaml` for its self-hosted runner labels, and it runs # shellcheck over every `run:` block — which is why the workflows it gates # avoid `sed`-into-`export` (SC2001, SC2155), `ls | wc -l` (SC2012), and # dollar-braces or backticks inside single-quoted `node -e` arguments (SC2016). @@ -19,7 +19,7 @@ name: Lint release tooling on: pull_request: # Exactly what the job reads: the workflows actionlint is pointed at, the - # config it resolves the Blacksmith label from, and the shell scripts the + # config it reads runner labels from, and the shell scripts the # later steps check and run. The filter also named scripts/release-gate.mjs, # scripts/ffi-release-matrix.mjs, scripts/lint-no-workflow-caching.mjs and # package.json — none of which this job looks at, since it deliberately does diff --git a/.github/workflows/macro-expand-eql.yml b/.github/workflows/macro-expand-eql.yml index 868e404495..7478b79cd4 100644 --- a/.github/workflows/macro-expand-eql.yml +++ b/.github/workflows/macro-expand-eql.yml @@ -51,7 +51,7 @@ permissions: jobs: macro-expand: name: "Macro expand drift (nightly)" - runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=16/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 30 steps: diff --git a/.github/workflows/miri.yml b/.github/workflows/miri.yml index 75711f5fda..5342767b0b 100644 --- a/.github/workflows/miri.yml +++ b/.github/workflows/miri.yml @@ -40,7 +40,7 @@ env: jobs: miri-stack-guest-abi: name: Miri (stack-guest-abi) - runs-on: blacksmith-4vcpu-ubuntu-2404 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=4/image=ubuntu24-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 30 steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 diff --git a/.github/workflows/prisma-example-readme-e2e.yml b/.github/workflows/prisma-example-readme-e2e.yml index 1a9b95c8d8..310e03ce63 100644 --- a/.github/workflows/prisma-example-readme-e2e.yml +++ b/.github/workflows/prisma-example-readme-e2e.yml @@ -82,7 +82,7 @@ on: jobs: walkthrough: name: Run README walkthrough - runs-on: blacksmith-4vcpu-ubuntu-2404 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=4/image=ubuntu24-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 15 # Skip cleanly on fork PRs where secrets aren't available. The diff --git a/.github/workflows/prisma-next-e2e.yml b/.github/workflows/prisma-next-e2e.yml index e917abe346..c62335630e 100644 --- a/.github/workflows/prisma-next-e2e.yml +++ b/.github/workflows/prisma-next-e2e.yml @@ -82,7 +82,7 @@ on: jobs: e2e: name: Run Prisma Next E2E - runs-on: blacksmith-4vcpu-ubuntu-2404 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=4/image=ubuntu24-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 15 # Skip cleanly on fork PRs where secrets aren't available. The diff --git a/.github/workflows/release-golang.yml b/.github/workflows/release-golang.yml index 8c08bdcfa5..f59494a61e 100644 --- a/.github/workflows/release-golang.yml +++ b/.github/workflows/release-golang.yml @@ -71,7 +71,7 @@ concurrency: jobs: build: name: Build and test the release - runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=16/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 90 env: VERSION: ${{ inputs.version }} @@ -242,7 +242,7 @@ jobs: publish: name: Tag and release needs: build - runs-on: blacksmith-4vcpu-ubuntu-2404 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=4/image=ubuntu24-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 15 # Required reviewers set on this environment in the repository settings # gate every release; with none set, it gates nothing. @@ -370,7 +370,7 @@ jobs: verify: name: Check that Go resolves the version needs: publish - runs-on: blacksmith-4vcpu-ubuntu-2404 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=4/image=ubuntu24-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 15 env: VERSION: ${{ inputs.version }} diff --git a/.github/workflows/release-postgres-eql-image.yml b/.github/workflows/release-postgres-eql-image.yml index eec9dbfdae..31adea560f 100644 --- a/.github/workflows/release-postgres-eql-image.yml +++ b/.github/workflows/release-postgres-eql-image.yml @@ -58,7 +58,7 @@ jobs: name: Build EQL SQL needs: [eql-armed] if: needs.eql-armed.outputs.armed == 'true' - runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=16/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 20 defaults: run: @@ -110,7 +110,7 @@ jobs: name: Build postgres-eql image (PG ${{ matrix.pg_version }}) needs: [eql-armed, build-sql] if: needs.eql-armed.outputs.armed == 'true' - runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=16/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 30 permissions: contents: read @@ -208,7 +208,7 @@ jobs: # skips this job. needs: [eql-armed, build-sql, build-images] if: needs.build-sql.outputs.update_floating_tags == 'true' - runs-on: blacksmith-16vcpu-ubuntu-2204 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=16/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 10 permissions: contents: read diff --git a/.github/workflows/test-eql.yml b/.github/workflows/test-eql.yml index 7e10336d9f..1057b60e78 100644 --- a/.github/workflows/test-eql.yml +++ b/.github/workflows/test-eql.yml @@ -153,7 +153,7 @@ jobs: # would either skip the merge-queue matrix or deadlock `ci-required`. changes: name: "Detect relevant changes" - runs-on: blacksmith-16vcpu-ubuntu-2204 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=16/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 10 outputs: relevant: ${{ steps.r.outputs.relevant }} @@ -243,7 +243,7 @@ jobs: # everything else -> PG 14-17 x 2 shards (coverage lane). setup: name: "Compute matrix" - runs-on: blacksmith-16vcpu-ubuntu-2204 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=16/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 10 # Opts out of the workflow-level `working-directory: packages/eql`. This job # deliberately does not check out — it is pure bash deriving a matrix — so @@ -315,7 +315,7 @@ jobs: || needs.changes.outputs.relevant == 'true') && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) - runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=16/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 45 env: # test:sqlx:archive depends on test:sqlx:prep, which copies the built EQL @@ -418,7 +418,7 @@ jobs: if: >- github.event_name != 'pull_request' || needs.changes.outputs.relevant == 'true' - runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=16/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 75 strategy: fail-fast: false @@ -499,7 +499,7 @@ jobs: if: >- github.event_name != 'pull_request' || needs.changes.outputs.relevant == 'true' - runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=16/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 10 strategy: fail-fast: false @@ -577,7 +577,7 @@ jobs: if: >- github.event_name != 'pull_request' || needs.changes.outputs.relevant == 'true' - runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=16/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 10 steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 @@ -607,7 +607,7 @@ jobs: if: >- github.event_name != 'pull_request' || needs.changes.outputs.relevant == 'true' - runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=16/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 15 services: encryption-postgres: @@ -747,7 +747,7 @@ jobs: if: >- github.event_name != 'pull_request' || needs.changes.outputs.relevant == 'true' - runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=16/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 10 steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 @@ -780,7 +780,7 @@ jobs: if: >- github.event_name != 'pull_request' || needs.changes.outputs.relevant == 'true' - runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=16/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 10 steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 @@ -817,7 +817,7 @@ jobs: if: >- github.event_name != 'pull_request' || needs.changes.outputs.relevant == 'true' - runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=16/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 20 steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 @@ -860,7 +860,7 @@ jobs: if: >- github.event_name != 'pull_request' || needs.changes.outputs.relevant == 'true' - runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=16/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 10 env: POSTGRES_VERSION: "17" @@ -939,7 +939,7 @@ jobs: # per-version `validate` job). docs-static: name: "SQL doc validation" - runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=16/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 10 steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 @@ -979,7 +979,7 @@ jobs: # issue state, so it runs on every PR rather than hiding behind the e2e job. known-failures: name: "known-failure markers" - runs-on: blacksmith-16vcpu-ubuntu-2204 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=16/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 10 permissions: contents: read @@ -1018,7 +1018,7 @@ jobs: # PRs it exists to check. doc-anchors: name: "doc anchor links" - runs-on: blacksmith-16vcpu-ubuntu-2204 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=16/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 10 steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 @@ -1052,7 +1052,7 @@ jobs: || needs.changes.outputs.relevant == 'true') && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) - runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=16/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 40 env: POSTGRES_VERSION: "17" @@ -1122,7 +1122,7 @@ jobs: codegen, self-contained-v3, matrix-coverage, splinter, docs-static, known-failures, doc-anchors, e2e] if: always() - runs-on: blacksmith-16vcpu-ubuntu-2204 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=16/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 10 # Same opt-out as `setup`, and this is the worse of the two to get wrong: # this job is the required check. It reads `needs.*.result` and checks out diff --git a/.github/workflows/tests-bench.yml b/.github/workflows/tests-bench.yml index 0df32e9847..51afbf8b97 100644 --- a/.github/workflows/tests-bench.yml +++ b/.github/workflows/tests-bench.yml @@ -46,7 +46,7 @@ on: jobs: tests-bench: name: Run Bench Smoke Tests - runs-on: blacksmith-4vcpu-ubuntu-2404 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=4/image=ubuntu24-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 10 steps: diff --git a/.github/workflows/tests-crates.yml b/.github/workflows/tests-crates.yml index 9f421b4e40..c36ba2c75b 100644 --- a/.github/workflows/tests-crates.yml +++ b/.github/workflows/tests-crates.yml @@ -79,7 +79,7 @@ env: jobs: rust: name: fmt, clippy, nextest, doctests, rustdoc - runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=16/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 60 env: # Job-level, not workflow-level: RUSTFLAGS replaces the @@ -158,7 +158,7 @@ jobs: node-bindings: name: node bindings, napi typings, stack-auth-wasm - runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=16/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 45 steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 diff --git a/.github/workflows/tests-golang.yml b/.github/workflows/tests-golang.yml index 6c4b82987d..727015047d 100644 --- a/.github/workflows/tests-golang.yml +++ b/.github/workflows/tests-golang.yml @@ -95,7 +95,7 @@ env: jobs: wasi-check: name: WASI check, guests and Go (Linux) - runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=8/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=16/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 60 env: # wasm:guest:test and wasm:auth-guest:test run nextest, which is pinned @@ -242,7 +242,7 @@ jobs: # guests: the packages embed a directory and compile without them. go-lint: name: Go lint - runs-on: blacksmith-4vcpu-ubuntu-2404 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=4/image=ubuntu24-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 15 steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 @@ -334,7 +334,7 @@ jobs: live: name: Go live tests and stack-encrypt examples needs: wasi-check - runs-on: blacksmith-4vcpu-ubuntu-2404 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=4/image=ubuntu24-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 30 env: CS_WORKSPACE_CRN: ${{ vars.CS_WORKSPACE_CRN }} diff --git a/.github/workflows/tests-rust.yml b/.github/workflows/tests-rust.yml index 1a1bdc3885..3d05d70ecc 100644 --- a/.github/workflows/tests-rust.yml +++ b/.github/workflows/tests-rust.yml @@ -58,7 +58,7 @@ concurrency: jobs: rust: name: cargo test + clippy + rustfmt - runs-on: blacksmith-4vcpu-ubuntu-2404 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=4/image=ubuntu24-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 45 steps: - uses: actions/checkout@v6 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7369eebfbb..6a1f55adb7 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -21,7 +21,7 @@ jobs: # Tightening to fail on warnings is tracked in #625. lint: name: Lint (Biome) - runs-on: blacksmith-4vcpu-ubuntu-2404 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=4/image=ubuntu24-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 10 steps: - name: Checkout Repo @@ -54,7 +54,7 @@ jobs: run-tests: name: Run Tests (Node ${{ matrix.node-version }}) - runs-on: blacksmith-4vcpu-ubuntu-2404 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=4/image=ubuntu24-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 25 strategy: matrix: @@ -399,7 +399,7 @@ jobs: e2e-tests: name: Run E2E Tests - runs-on: blacksmith-4vcpu-ubuntu-2404 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=4/image=ubuntu24-full-x64/volume=80gb/extras=s3-cache # The migration harness's live Runs take most of this job's time; the # limit covers them plus the job's other suites, with headroom. timeout-minutes: 30 @@ -564,7 +564,7 @@ jobs: # a silent fallback to the NAPI module is impossible. wasm-e2e-tests: name: Run WASM E2E Tests (Deno) - runs-on: blacksmith-4vcpu-ubuntu-2404 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=4/image=ubuntu24-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 35 permissions: @@ -708,7 +708,7 @@ jobs: run-tests-bun: name: Run Tests (Bun) - runs-on: blacksmith-4vcpu-ubuntu-2404 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=4/image=ubuntu24-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 15 continue-on-error: true diff --git a/.github/workflows/udeps.yml b/.github/workflows/udeps.yml index db3d33b98c..ed05f96d0b 100644 --- a/.github/workflows/udeps.yml +++ b/.github/workflows/udeps.yml @@ -68,7 +68,7 @@ env: jobs: udeps: name: Check unused Rust dependencies - runs-on: blacksmith-4vcpu-ubuntu-2404 + runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=4/image=ubuntu24-full-x64/volume=80gb/extras=s3-cache timeout-minutes: 45 steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 diff --git a/scripts/__tests__/ffi-release-matrix.test.mjs b/scripts/__tests__/ffi-release-matrix.test.mjs index 014ee1f71c..fd5f095e73 100644 --- a/scripts/__tests__/ffi-release-matrix.test.mjs +++ b/scripts/__tests__/ffi-release-matrix.test.mjs @@ -8,6 +8,7 @@ import { triplesFromPlatformManifests, } from '../ffi-release-matrix.mjs' import { REPO_ROOT } from './lib/repo-root.mjs' +import { runsOnLabel } from './lib/runs-on.mjs' /** * The release matrix decides what each of the six platform jobs compiles and @@ -58,7 +59,7 @@ function logFileOf(scriptName) { const RUN_ID = '1234' const MATRIX = releaseMatrix(TRIPLES, RUN_ID) -const RUNS_ON = `runs-on=${RUN_ID}/family=c8a+m8a/cpu=8/image=ubuntu24-full-x64/volume=80gb/extras=s3-cache` +const RUNS_ON_4 = runsOnLabel(4, { runId: RUN_ID }) describe('the platform fixture matches the package', () => { it('covers exactly the platforms this package publishes', () => { @@ -159,21 +160,21 @@ describe('release matrix', () => { { platform: 'linux-x64-gnu', target: 'x86_64-unknown-linux-gnu', - os: RUNS_ON, + os: RUNS_ON_4, script: 'zigbuild', log: 'zig.log', }, { platform: 'linux-arm64-gnu', target: 'aarch64-unknown-linux-gnu', - os: RUNS_ON, + os: RUNS_ON_4, script: 'zigbuild', log: 'zig.log', }, { platform: 'linux-x64-musl', target: 'x86_64-unknown-linux-musl', - os: 'blacksmith-4vcpu-ubuntu-2404', + os: RUNS_ON_4, script: 'build:native', log: 'cargo.log', }, @@ -182,16 +183,16 @@ describe('release matrix', () => { it('sends a platform the table does not name to a Linux runner', () => { // The fallback arm, which the table above cannot reach. A seventh platform - // added tomorrow gets Blacksmith unless `runnerFor` is taught otherwise. - expect(runnerFor('linux-arm64-musl', RUN_ID)).toBe( - 'blacksmith-4vcpu-ubuntu-2404', - ) + // added tomorrow builds on RunsOn unless `runnerFor` is taught otherwise. + expect(runnerFor('linux-arm64-musl', RUN_ID)).toBe(RUNS_ON_4) }) it('refuses a RunsOn label with no run ID in it', () => { // `runs-on=undefined/…` would be one label shared by every run, so one // run's machine could take another run's job. expect(() => runnerFor('linux-x64-gnu', '')).toThrow(/GITHUB_RUN_ID/) + // Only a RunsOn label needs the run ID. + expect(runnerFor('darwin-x64', '')).toBe('macos-latest') }) it('is empty for an empty mapping, rather than inventing platforms', () => { diff --git a/scripts/__tests__/lib/runs-on.mjs b/scripts/__tests__/lib/runs-on.mjs new file mode 100644 index 0000000000..1b7855dc99 --- /dev/null +++ b/scripts/__tests__/lib/runs-on.mjs @@ -0,0 +1,52 @@ +/** + * The RunsOn labels ADR 0004 names, and which jobs run on RunsOn. Shared by + * the guards that hold RunsOn jobs to their rules. + */ + +// biome-ignore lint/suspicious/noTemplateCurlyInString: a GitHub Actions expression, written into the label verbatim. +const RUN_ID_EXPRESSION = '${{ github.run_id }}' + +// Each Blacksmith size keeps its Ubuntu version on RunsOn. +const IMAGE_FOR_CPU = { 16: 'ubuntu22-full-x64', 4: 'ubuntu24-full-x64' } + +/** `family: 'm8a'` is for a job that ran out of memory on c8a's 2 GB per vCPU. */ +export function runsOnLabel( + cpu, + { family = 'c8a+m8a', runId = RUN_ID_EXPRESSION } = {}, +) { + const image = IMAGE_FOR_CPU[cpu] + if (!image) + throw new Error(`ADR 0004 names no RunsOn label with ${cpu} vCPUs`) + return `runs-on=${runId}/family=${family}/cpu=${cpu}/image=${image}/volume=80gb/extras=s3-cache` +} + +export const RUNS_ON_LABELS = new Set([ + runsOnLabel(16), + runsOnLabel(4), + runsOnLabel(16, { family: 'm8a' }), + runsOnLabel(4, { family: 'm8a' }), +]) + +// A guard cannot read which runner a matrix picks, so each such job is +// classified here. workflow-runs-on.test.mjs keeps this list complete. +export const MATRIX_RUNNERS = { + '.github/workflows/_build-ffi-artifacts.yml#binaries': { + runsOn: true, + reason: + 'scripts/ffi-release-matrix.mjs gives every Linux platform a RunsOn label.', + }, + '.github/workflows/_build-auth-artifacts.yml#binaries': { + runsOn: false, + reason: 'Its matrix names GitHub-hosted runners only.', + }, + '.github/workflows/tests-golang.yml#go-binding-cross': { + runsOn: false, + reason: 'Its matrix is macos-latest and windows-latest.', + }, +} + +export function isRunsOnJob(job, ref) { + const label = job?.['runs-on'] + if (typeof label === 'string' && label.startsWith('runs-on=')) return true + return MATRIX_RUNNERS[ref]?.runsOn === true +} diff --git a/scripts/__tests__/workflow-runs-on.test.mjs b/scripts/__tests__/workflow-runs-on.test.mjs new file mode 100644 index 0000000000..3fc2981ed6 --- /dev/null +++ b/scripts/__tests__/workflow-runs-on.test.mjs @@ -0,0 +1,101 @@ +import { describe, expect, it } from 'vitest' +import { + isRunsOnJob, + MATRIX_RUNNERS, + RUNS_ON_LABELS, + runsOnLabel, +} from './lib/runs-on.mjs' +import { readWorkflow, workflowFiles } from './lib/workflows.mjs' + +/** + * Every self-hosted job runs on a RunsOn machine of the size its Blacksmith + * job had. ADR 0004 records the decision and the two labels. + * + * - No job names a Blacksmith label. + * - Every RunsOn label is one of the labels ADR 0004 names. A job that ran out + * of memory may use the same label with `family=m8a`. Any other label, such + * as `cpu=8`, gives the job a machine of the wrong size. + * - A job whose runner comes from an expression is listed in + * `MATRIX_RUNNERS`, with whether its matrix gives it RunsOn machines. The + * other guards read that list, because they cannot see which runner a matrix + * picks. + */ + +const jobs = workflowFiles().flatMap((file) => + Object.entries(readWorkflow(file)?.jobs ?? {}).map(([id, job]) => ({ + ref: `${file}#${id}`, + job, + })), +) + +const refsWhere = (predicate) => + jobs.filter(predicate).map(({ ref }) => ref) + +/** A runner chosen when the job starts, so a guard cannot read it. */ +function isExpressionRunner(job) { + const label = job?.['runs-on'] + if (label === undefined) return false + if (typeof label !== 'string') return true + return label.includes('${{') && !label.startsWith('runs-on=') +} + +const expressionRunnerRefs = () => + refsWhere(({ job }) => isExpressionRunner(job)) + +describe('RunsOn runner labels', () => { + it('builds the labels ADR 0004 names', () => { + expect(runsOnLabel(16)).toBe( + // biome-ignore lint/suspicious/noTemplateCurlyInString: a GitHub Actions expression, the literal `runs-on` value under test. + 'runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=16/image=ubuntu22-full-x64/volume=80gb/extras=s3-cache', + ) + expect(runsOnLabel(4)).toBe( + // biome-ignore lint/suspicious/noTemplateCurlyInString: a GitHub Actions expression, the literal `runs-on` value under test. + 'runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=4/image=ubuntu24-full-x64/volume=80gb/extras=s3-cache', + ) + expect(runsOnLabel(4, { family: 'm8a' })).toBe( + // biome-ignore lint/suspicious/noTemplateCurlyInString: a GitHub Actions expression, the literal `runs-on` value under test. + 'runs-on=${{ github.run_id }}/family=m8a/cpu=4/image=ubuntu24-full-x64/volume=80gb/extras=s3-cache', + ) + expect(() => runsOnLabel(8)).toThrow() + }) + + it('finds the jobs it checks', () => { + // A scan that finds nothing passes every check below. + expect( + jobs.filter(({ job, ref }) => isRunsOnJob(job, ref)).length, + ).toBeGreaterThan(50) + }) + + it('names no Blacksmith label', () => { + // JSON.stringify also covers a runs-on that is a list or an object. + expect( + refsWhere(({ job }) => + /blacksmith-/.test(JSON.stringify(job?.['runs-on'] ?? '')), + ), + ).toEqual([]) + }) + + it('uses only the labels ADR 0004 names', () => { + expect( + refsWhere(({ job }) => { + const label = job?.['runs-on'] + return ( + typeof label === 'string' && + label.startsWith('runs-on=') && + !RUNS_ON_LABELS.has(label) + ) + }), + ).toEqual([]) + }) + + it('lists every job whose runner comes from an expression', () => { + // Both directions: a new matrix job must be listed, and an entry whose + // job is gone must be removed. + expect(expressionRunnerRefs().sort()).toEqual( + Object.keys(MATRIX_RUNNERS).sort(), + ) + expect( + Object.values(MATRIX_RUNNERS).every(({ reason }) => reason.trim()), + ).toBe(true) + }) +}) diff --git a/scripts/ffi-release-matrix.mjs b/scripts/ffi-release-matrix.mjs index f39688e7c3..d66dcca42a 100644 --- a/scripts/ffi-release-matrix.mjs +++ b/scripts/ffi-release-matrix.mjs @@ -46,23 +46,19 @@ const PLATFORMS_DIR = join( * * Darwin and Windows need GitHub-hosted images for their SDKs; both Darwin * platforms share `macos-latest` and cross-compile, which is why `target` is - * explicit. The gnu builds took just over twice as long on GitHub's standard - * runner as on Blacksmith 4 vCPU, so they run on RunsOn. A matrix value cannot - * read `${{ github.run_id }}`, so the run ID that makes the RunsOn label unique - * is passed in. musl stays on Blacksmith: it could not be timed, because its - * image pins a `musl-dev` that Alpine no longer serves. + * explicit. Every Linux platform builds on a RunsOn machine with 4 vCPUs, its + * size on Blacksmith (docs/adr/0004). A matrix value cannot read + * `${{ github.run_id }}`, so the run ID that makes the RunsOn label unique is + * passed in. */ export function runnerFor(platform, runId = process.env.GITHUB_RUN_ID) { if (platform.startsWith('win32')) return 'windows-latest' if (platform.startsWith('darwin')) return 'macos-latest' - if (platform.startsWith('linux-') && platform.endsWith('-gnu')) { - if (!runId) - throw new Error( - `${platform} builds on RunsOn, whose label needs the run ID; set GITHUB_RUN_ID`, - ) - return `runs-on=${runId}/family=c8a+m8a/cpu=8/image=ubuntu24-full-x64/volume=80gb/extras=s3-cache` - } - return 'blacksmith-4vcpu-ubuntu-2404' + if (!runId) + throw new Error( + `${platform} builds on RunsOn, whose label needs the run ID; set GITHUB_RUN_ID`, + ) + return `runs-on=${runId}/family=c8a+m8a/cpu=4/image=ubuntu24-full-x64/volume=80gb/extras=s3-cache` } /** From a4b9eadabb7fc7b418762274d9bfbb47700bf1ca Mon Sep 17 00:00:00 2001 From: Lindsay Holmwood Date: Thu, 19 Nov 2026 22:35:07 +1100 Subject: [PATCH 09/23] ci(runners): log in to Docker Hub before every RunsOn job pulls an image Five jobs that moved to RunsOn pull images with no login before the pull: the Prisma Next E2E, bench and e2e Postgres containers, the image promotion's Buildx setup, and the musl FFI build in Alpine. Each now logs in first. The login does nothing when either secret is empty. The FFI build is a reusable workflow, where secrets are empty unless the caller passes them. release.yml and ffi-preflight.yml now pass the two Docker Hub secrets by name. Only the RunsOn legs log in, because the macOS leg has no Docker. The login test now also checks a job whose runner comes from a matrix, when MATRIX_RUNNERS marks it as RunsOn. It also fails when a caller of a workflow whose RunsOn jobs log in does not pass both secrets. --- .github/workflows/_build-ffi-artifacts.yml | 27 ++++++ .github/workflows/ffi-preflight.yml | 3 + .github/workflows/prisma-next-e2e.yml | 18 ++++ .../workflows/release-postgres-eql-image.yml | 18 ++++ .github/workflows/release.yml | 5 ++ .github/workflows/tests-bench.yml | 18 ++++ .github/workflows/tests.yml | 18 ++++ .../workflow-docker-hub-login.test.mjs | 90 ++++++++++++++++--- 8 files changed, 185 insertions(+), 12 deletions(-) diff --git a/.github/workflows/_build-ffi-artifacts.yml b/.github/workflows/_build-ffi-artifacts.yml index e354153eb3..dab6503e72 100644 --- a/.github/workflows/_build-ffi-artifacts.yml +++ b/.github/workflows/_build-ffi-artifacts.yml @@ -35,6 +35,13 @@ on: description: Commit to build from required: true type: string + # For the musl leg's Docker Hub login. Optional, because the login does + # nothing without them and the build still runs. + secrets: + DOCKER_HUB_USERNAME: + required: false + DOCKER_HUB_PASSWORD: + required: false permissions: contents: read @@ -219,6 +226,26 @@ jobs: pnpm run "$BUILD_SCRIPT" fi + # Docker Hub refuses pulls without a login after too many from one + # address, and RunsOn machines reach that limit. With either secret empty, + # as on a fork's pull request, this step does nothing and pulls stay + # anonymous. scripts/__tests__/workflow-docker-hub-login.test.mjs + # requires it. Only the RunsOn legs log in. The macOS leg has no Docker, + # so `docker login` would fail there once the secrets exist. + - name: Log in to Docker Hub + if: ${{ startsWith(matrix.cfg.os, 'runs-on=') }} + env: + DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }} + DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }} + run: | + set -euo pipefail + if [ -z "$DOCKER_HUB_USERNAME" ] || [ -z "$DOCKER_HUB_PASSWORD" ]; then + echo "No Docker Hub credentials, so image pulls stay anonymous." + exit 0 + fi + printf '%s' "$DOCKER_HUB_PASSWORD" | + docker login --username "$DOCKER_HUB_USERNAME" --password-stdin + # The musl binary is built inside Alpine Linux, a musl system, so the # compiler and its runtime libraries are musl's own. The toolchain this # leg used to download from musl.cc timed out from GitHub's runners on diff --git a/.github/workflows/ffi-preflight.yml b/.github/workflows/ffi-preflight.yml index 5372ea2fe7..5aaabc063f 100644 --- a/.github/workflows/ffi-preflight.yml +++ b/.github/workflows/ffi-preflight.yml @@ -35,6 +35,9 @@ jobs: uses: ./.github/workflows/_build-ffi-artifacts.yml with: ref: ${{ inputs.ref }} + secrets: + DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }} + DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }} smoke: name: Install and smoke-test diff --git a/.github/workflows/prisma-next-e2e.yml b/.github/workflows/prisma-next-e2e.yml index c62335630e..bdf78807ad 100644 --- a/.github/workflows/prisma-next-e2e.yml +++ b/.github/workflows/prisma-next-e2e.yml @@ -181,6 +181,24 @@ jobs: - name: Emit example contract run: pnpm exec turbo run emit --filter @cipherstash/prisma-example + # Docker Hub refuses pulls without a login after too many from one + # address, and RunsOn machines reach that limit. With either secret empty, + # as on a fork's pull request, this step does nothing and pulls stay + # anonymous. scripts/__tests__/workflow-docker-hub-login.test.mjs + # requires it. + - name: Log in to Docker Hub + env: + DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }} + DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }} + run: | + set -euo pipefail + if [ -z "$DOCKER_HUB_USERNAME" ] || [ -z "$DOCKER_HUB_PASSWORD" ]; then + echo "No Docker Hub credentials, so image pulls stay anonymous." + exit 0 + fi + printf '%s' "$DOCKER_HUB_PASSWORD" | + docker login --username "$DOCKER_HUB_USERNAME" --password-stdin + - name: Start E2E Postgres container working-directory: languages/typescript/examples/prisma run: | diff --git a/.github/workflows/release-postgres-eql-image.yml b/.github/workflows/release-postgres-eql-image.yml index 31adea560f..d6344ed098 100644 --- a/.github/workflows/release-postgres-eql-image.yml +++ b/.github/workflows/release-postgres-eql-image.yml @@ -217,6 +217,24 @@ jobs: EQL_VERSION: ${{ needs.build-sql.outputs.eql_version }} steps: + # Docker Hub refuses pulls without a login after too many from one + # address, and RunsOn machines reach that limit. With either secret empty, + # as on a fork's pull request, this step does nothing and pulls stay + # anonymous. scripts/__tests__/workflow-docker-hub-login.test.mjs + # requires it. + - name: Log in to Docker Hub + env: + DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }} + DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }} + run: | + set -euo pipefail + if [ -z "$DOCKER_HUB_USERNAME" ] || [ -z "$DOCKER_HUB_PASSWORD" ]; then + echo "No Docker Hub credentials, so image pulls stay anonymous." + exit 0 + fi + printf '%s' "$DOCKER_HUB_PASSWORD" | + docker login --username "$DOCKER_HUB_USERNAME" --password-stdin + - name: Set up Buildx uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 32d93b00bf..0a22b72006 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -207,6 +207,11 @@ jobs: uses: ./.github/workflows/_build-ffi-artifacts.yml with: ref: ${{ github.sha }} + # By name, not `secrets: inherit`, so the called workflow gets no other + # secret of this workflow. + secrets: + DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }} + DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }} publish-ffi: name: Publish FFI packages diff --git a/.github/workflows/tests-bench.yml b/.github/workflows/tests-bench.yml index 51afbf8b97..16233967a1 100644 --- a/.github/workflows/tests-bench.yml +++ b/.github/workflows/tests-bench.yml @@ -89,6 +89,24 @@ jobs: working-directory: languages/typescript/packages/bench run: pnpm test:unit + # Docker Hub refuses pulls without a login after too many from one + # address, and RunsOn machines reach that limit. With either secret empty, + # as on a fork's pull request, this step does nothing and pulls stay + # anonymous. scripts/__tests__/workflow-docker-hub-login.test.mjs + # requires it. + - name: Log in to Docker Hub + env: + DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }} + DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }} + run: | + set -euo pipefail + if [ -z "$DOCKER_HUB_USERNAME" ] || [ -z "$DOCKER_HUB_PASSWORD" ]; then + echo "No Docker Hub credentials, so image pulls stay anonymous." + exit 0 + fi + printf '%s' "$DOCKER_HUB_PASSWORD" | + docker login --username "$DOCKER_HUB_USERNAME" --password-stdin + # Service-scoped `postgres`: local/docker-compose.yml also defines a # PostgREST that bench never talks to. # diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6a1f55adb7..c17cf58250 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -487,6 +487,24 @@ jobs: - name: Run the protect-dynamodb compatibility suite run: pnpm exec turbo run test:protect-compat --filter @cipherstash/e2e --env-mode=loose + # Docker Hub refuses pulls without a login after too many from one + # address, and RunsOn machines reach that limit. With either secret empty, + # as on a fork's pull request, this step does nothing and pulls stay + # anonymous. scripts/__tests__/workflow-docker-hub-login.test.mjs + # requires it. + - name: Log in to Docker Hub + env: + DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }} + DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }} + run: | + set -euo pipefail + if [ -z "$DOCKER_HUB_USERNAME" ] || [ -z "$DOCKER_HUB_PASSWORD" ]; then + echo "No Docker Hub credentials, so image pulls stay anonymous." + exit 0 + fi + printf '%s' "$DOCKER_HUB_PASSWORD" | + docker login --username "$DOCKER_HUB_USERNAME" --password-stdin + # The DynamoDB <-> Postgres cross-store suite moves protect-dynamodb # 6.0.1 items into EQL v3 columns and back, so it needs a database. # `integration-db` gives this job its own compose project and ephemeral diff --git a/scripts/__tests__/workflow-docker-hub-login.test.mjs b/scripts/__tests__/workflow-docker-hub-login.test.mjs index 710da4ca19..1cb80850c7 100644 --- a/scripts/__tests__/workflow-docker-hub-login.test.mjs +++ b/scripts/__tests__/workflow-docker-hub-login.test.mjs @@ -3,6 +3,7 @@ import { dirname, join, relative } from 'node:path' import { describe, expect, it } from 'vitest' import { expr } from './lib/expressions.mjs' import { REPO_ROOT } from './lib/repo-root.mjs' +import { isRunsOnJob } from './lib/runs-on.mjs' import { readWorkflow, workflowFiles } from './lib/workflows.mjs' /** @@ -33,8 +34,14 @@ import { readWorkflow, workflowFiles } from './lib/workflows.mjs' * task that reaches either through its body, its `depends`, or a nested * `mise run`. A login a job did not need costs one step and nothing else. * - * Only a literal `runs-on=` label counts as RunsOn. GitHub-hosted runners are - * not limited this way, and Blacksmith jobs are leaving. + * A job counts as RunsOn when its label starts with `runs-on=`. It also + * counts when `MATRIX_RUNNERS` in `lib/runs-on.mjs` says its matrix gives it + * RunsOn machines, because a matrix runner is an expression this file cannot + * read. GitHub-hosted runners are not limited this way. + * + * In a called workflow, `secrets.*` is empty unless the caller passes it. A + * login there would skip, and the job would pull anonymously with no error. + * So every caller of a workflow whose RunsOn jobs log in passes both secrets. */ // --------------------------------------------------------------------------- @@ -269,11 +276,9 @@ export function credentialsFinding(credentials) { return null } -const isRunsOn = (job) => String(job?.['runs-on'] ?? '').startsWith('runs-on=') - /** Every finding for one job, or [] when it is correct. */ -export function jobFindings(where, job) { - if (!isRunsOn(job)) return [] +export function jobFindings(where, job, ref) { + if (!isRunsOnJob(job, ref)) return [] const findings = [] const containers = [ ...Object.entries(job.services ?? {}).map(([name, svc]) => [ @@ -310,8 +315,41 @@ export function jobFindings(where, job) { function runsOnJobs() { return workflowFiles().flatMap((file) => Object.entries(readWorkflow(file)?.jobs ?? {}) - .filter(([, job]) => isRunsOn(job)) - .map(([name, job]) => ({ where: `${file} ${name}`, job })), + .map(([name, job]) => ({ where: `${file} ${name}`, ref: `${file}#${name}`, job })) + .filter(({ job, ref }) => isRunsOnJob(job, ref)), + ) +} + +/** Whether a calling job passes both Docker Hub secrets to the workflow it calls. */ +export function callerFinding(job) { + if (job?.secrets === 'inherit') return null + const passed = job?.secrets ?? {} + const missing = [ + ['DOCKER_HUB_USERNAME', USERNAME], + ['DOCKER_HUB_PASSWORD', PASSWORD], + ] + .filter(([name, value]) => passed[name] !== value) + .map(([name]) => name) + return missing.length + ? `does not pass ${missing.join(' and ')} to the workflow it calls, so its login would skip` + : null +} + +/** Each local workflow call whose called RunsOn jobs log in, and what it lacks. */ +function callerFindings() { + return workflowFiles().flatMap((file) => + Object.entries(readWorkflow(file)?.jobs ?? {}) + .filter(([, job]) => String(job?.uses ?? '').startsWith('./.github/workflows/')) + .flatMap(([name, job]) => { + const called = job.uses.replace(/^\.\//, '').replace(/@.*$/, '') + const logsIn = Object.entries(readWorkflow(called)?.jobs ?? {}).some( + ([id, calledJob]) => + isRunsOnJob(calledJob, `${called}#${id}`) && + (calledJob.steps ?? []).some((step) => loginFinding(step) === null), + ) + const finding = logsIn ? callerFinding(job) : null + return finding ? [`${file}#${name}: ${finding}`] : [] + }), ) } @@ -322,7 +360,7 @@ describe('Docker Hub login on RunsOn', () => { it('finds the jobs it checks', () => { // A discovery test that finds nothing passes having checked nothing. - expect(jobs.length).toBeGreaterThan(20) + expect(jobs.length).toBeGreaterThan(50) expect( jobs.filter(({ job }) => (job.steps ?? []).some((s) => stepPulls(s))) .length, @@ -332,9 +370,13 @@ describe('Docker Hub login on RunsOn', () => { }) it('logs in before every pull', () => { - expect(jobs.flatMap(({ where, job }) => jobFindings(where, job))).toEqual( - [], - ) + expect( + jobs.flatMap(({ where, job, ref }) => jobFindings(where, job, ref)), + ).toEqual([]) + }) + + it('passes the Docker Hub secrets to every called workflow whose RunsOn jobs log in', () => { + expect(callerFindings()).toEqual([]) }) // Every job in the tree is correct, so the test above runs none of the @@ -367,6 +409,30 @@ describe('Docker Hub login on RunsOn', () => { expect( jobFindings('w j', { 'runs-on': 'ubuntu-latest', steps: [up] }), ).toEqual([]) + // A matrix runner that MATRIX_RUNNERS marks as RunsOn is in scope. + expect( + jobFindings( + 'w j', + // biome-ignore lint/suspicious/noTemplateCurlyInString: a GitHub Actions expression, the literal `runs-on` value under test. + { 'runs-on': '${{ matrix.cfg.os }}', steps: [up] }, + '.github/workflows/_build-ffi-artifacts.yml#binaries', + ), + ).toEqual([expect.stringMatching(/no Docker Hub login comes before it/)]) + }) + + it('reports a call that does not pass both secrets', () => { + const uses = './.github/workflows/x.yml' + expect(callerFinding({ uses })).toMatch(/DOCKER_HUB_USERNAME/) + expect(callerFinding({ uses, secrets: 'inherit' })).toBeNull() + expect( + callerFinding({ + uses, + secrets: { DOCKER_HUB_USERNAME: USERNAME, DOCKER_HUB_PASSWORD: PASSWORD }, + }), + ).toBeNull() + expect( + callerFinding({ uses, secrets: { DOCKER_HUB_USERNAME: USERNAME } }), + ).toMatch(/DOCKER_HUB_PASSWORD/) }) it('reports a login that would fail on a fork pull request', () => { From 07de8dda32958a9bd78314c91118ad13466ffd3b Mon Sep 17 00:00:00 2001 From: Lindsay Holmwood Date: Thu, 19 Nov 2026 22:36:41 +1100 Subject: [PATCH 10/23] test(ci): require every RunsOn job to wait for the apt lock A new RunsOn machine can still be running apt from boot, and apt-get fails at once on the held lock. The two apt-get steps on RunsOn already pass -o DPkg::Lock::Timeout=300. This test fails when a step in a RunsOn job, or in a local action it uses, runs apt without it. --- scripts/__tests__/workflow-runs-on.test.mjs | 63 +++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/scripts/__tests__/workflow-runs-on.test.mjs b/scripts/__tests__/workflow-runs-on.test.mjs index 3fc2981ed6..66665499d4 100644 --- a/scripts/__tests__/workflow-runs-on.test.mjs +++ b/scripts/__tests__/workflow-runs-on.test.mjs @@ -1,4 +1,7 @@ +import { existsSync } from 'node:fs' +import { join } from 'node:path' import { describe, expect, it } from 'vitest' +import { REPO_ROOT } from './lib/repo-root.mjs' import { isRunsOnJob, MATRIX_RUNNERS, @@ -42,6 +45,50 @@ function isExpressionRunner(job) { const expressionRunnerRefs = () => refsWhere(({ job }) => isExpressionRunner(job)) +// A new RunsOn machine can still be running apt from boot. apt-get fails at +// once on the held lock unless told to wait for it. +const APT_COMMAND = + /\bapt(?:-get)?\s.*\b(?:update|install|upgrade|dist-upgrade|remove|purge|autoremove)\b/ + +export function aptFinding(run) { + for (const line of String(run).split('\n')) { + if (/^\s*#/.test(line)) continue + if (APT_COMMAND.test(line) && !line.includes('DPkg::Lock::Timeout=')) + return `runs apt without waiting for the lock: "${line.trim()}". Add -o DPkg::Lock::Timeout=300.` + } + return null +} + +/** A step, or the steps of the local composite action it uses. */ +function stepsOf(step, seen = new Set()) { + const uses = typeof step?.uses === 'string' ? step.uses.trim() : '' + if (!uses.startsWith('./')) return [step] + const dir = uses.replace(/^\.\//, '').replace(/\/$/, '') + if (seen.has(dir)) return [] + seen.add(dir) + for (const file of ['action.yml', 'action.yaml']) { + const rel = `${dir}/${file}` + if (existsSync(join(REPO_ROOT, rel))) + return (readWorkflow(rel)?.runs?.steps ?? []).flatMap((inner) => + stepsOf(inner, seen), + ) + } + return [] +} + +export function aptFindingsInRunsOnJobs() { + return jobs + .filter(({ job, ref }) => isRunsOnJob(job, ref)) + .flatMap(({ ref, job }) => + (job.steps ?? []).flatMap((step, i) => + stepsOf(step) + .map((inner) => aptFinding(inner?.run ?? '')) + .filter(Boolean) + .map((finding) => `${ref} step ${i + 1}: ${finding}`), + ), + ) +} + describe('RunsOn runner labels', () => { it('builds the labels ADR 0004 names', () => { expect(runsOnLabel(16)).toBe( @@ -99,3 +146,19 @@ describe('RunsOn runner labels', () => { ).toBe(true) }) }) + +describe('apt on a new RunsOn machine', () => { + it('recognises an apt command that does not wait for the lock', () => { + expect(aptFinding('sudo apt-get update')).toMatch(/DPkg::Lock::Timeout/) + expect(aptFinding('sudo apt install -y jq')).toMatch(/DPkg::Lock::Timeout/) + expect( + aptFinding('sudo apt-get -o DPkg::Lock::Timeout=300 install -y doxygen'), + ).toBeNull() + expect(aptFinding('# sudo apt-get update')).toBeNull() + expect(aptFinding('apt-cache policy doxygen')).toBeNull() + }) + + it('waits for the apt lock in every RunsOn job', () => { + expect(aptFindingsInRunsOnJobs()).toEqual([]) + }) +}) From 62f7342fe046f07f51ac450f20b41c99396347a9 Mon Sep 17 00:00:00 2001 From: Lindsay Holmwood Date: Thu, 19 Nov 2026 22:37:51 +1100 Subject: [PATCH 11/23] style(ci): format the RunsOn guard tests with Biome --- .../__tests__/workflow-docker-hub-login.test.mjs | 15 ++++++++++++--- scripts/__tests__/workflow-runs-on.test.mjs | 3 +-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/scripts/__tests__/workflow-docker-hub-login.test.mjs b/scripts/__tests__/workflow-docker-hub-login.test.mjs index 1cb80850c7..62dad7f6f7 100644 --- a/scripts/__tests__/workflow-docker-hub-login.test.mjs +++ b/scripts/__tests__/workflow-docker-hub-login.test.mjs @@ -315,7 +315,11 @@ export function jobFindings(where, job, ref) { function runsOnJobs() { return workflowFiles().flatMap((file) => Object.entries(readWorkflow(file)?.jobs ?? {}) - .map(([name, job]) => ({ where: `${file} ${name}`, ref: `${file}#${name}`, job })) + .map(([name, job]) => ({ + where: `${file} ${name}`, + ref: `${file}#${name}`, + job, + })) .filter(({ job, ref }) => isRunsOnJob(job, ref)), ) } @@ -339,7 +343,9 @@ export function callerFinding(job) { function callerFindings() { return workflowFiles().flatMap((file) => Object.entries(readWorkflow(file)?.jobs ?? {}) - .filter(([, job]) => String(job?.uses ?? '').startsWith('./.github/workflows/')) + .filter(([, job]) => + String(job?.uses ?? '').startsWith('./.github/workflows/'), + ) .flatMap(([name, job]) => { const called = job.uses.replace(/^\.\//, '').replace(/@.*$/, '') const logsIn = Object.entries(readWorkflow(called)?.jobs ?? {}).some( @@ -427,7 +433,10 @@ describe('Docker Hub login on RunsOn', () => { expect( callerFinding({ uses, - secrets: { DOCKER_HUB_USERNAME: USERNAME, DOCKER_HUB_PASSWORD: PASSWORD }, + secrets: { + DOCKER_HUB_USERNAME: USERNAME, + DOCKER_HUB_PASSWORD: PASSWORD, + }, }), ).toBeNull() expect( diff --git a/scripts/__tests__/workflow-runs-on.test.mjs b/scripts/__tests__/workflow-runs-on.test.mjs index 66665499d4..e129015b9d 100644 --- a/scripts/__tests__/workflow-runs-on.test.mjs +++ b/scripts/__tests__/workflow-runs-on.test.mjs @@ -31,8 +31,7 @@ const jobs = workflowFiles().flatMap((file) => })), ) -const refsWhere = (predicate) => - jobs.filter(predicate).map(({ ref }) => ref) +const refsWhere = (predicate) => jobs.filter(predicate).map(({ ref }) => ref) /** A runner chosen when the job starts, so a guard cannot read it. */ function isExpressionRunner(job) { From 966b32c647be0782f86d230952e1088fed9b2b31 Mon Sep 17 00:00:00 2001 From: Lindsay Holmwood Date: Thu, 19 Nov 2026 22:56:56 +1100 Subject: [PATCH 12/23] ci(runners): log in before the README walkthrough pulls its database e2e/tests/prisma-example-readme.e2e.test.ts runs the Prisma example's README, and the README runs `docker compose up -d`, which pulls postgres:16 from Docker Hub. The login test cannot see a pull made from test code. Two RunsOn jobs run that test: the README walkthrough job, and tests.yml's e2e-tests, whose login came after the step. The walkthrough job now logs in before the step, and e2e-tests logs in before "Run E2E tests". HIDDEN_PULLS in the login test names both steps as pulls, and the test fails when an entry names a step that is gone. --- .../workflows/prisma-example-readme-e2e.yml | 18 ++++++++++ .github/workflows/tests.yml | 34 +++++++++---------- .../workflow-docker-hub-login.test.mjs | 30 +++++++++++++++- 3 files changed, 64 insertions(+), 18 deletions(-) diff --git a/.github/workflows/prisma-example-readme-e2e.yml b/.github/workflows/prisma-example-readme-e2e.yml index 310e03ce63..d13fea4d25 100644 --- a/.github/workflows/prisma-example-readme-e2e.yml +++ b/.github/workflows/prisma-example-readme-e2e.yml @@ -158,6 +158,24 @@ jobs: - name: Build @cipherstash/stack-prisma run: pnpm exec turbo run build --filter @cipherstash/stack-prisma + # Docker Hub refuses pulls without a login after too many from one + # address, and RunsOn machines reach that limit. With either secret empty, + # as on a fork's pull request, this step does nothing and pulls stay + # anonymous. scripts/__tests__/workflow-docker-hub-login.test.mjs + # requires it. + - name: Log in to Docker Hub + env: + DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }} + DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }} + run: | + set -euo pipefail + if [ -z "$DOCKER_HUB_USERNAME" ] || [ -z "$DOCKER_HUB_PASSWORD" ]; then + echo "No Docker Hub credentials, so image pulls stay anonymous." + exit 0 + fi + printf '%s' "$DOCKER_HUB_PASSWORD" | + docker login --username "$DOCKER_HUB_USERNAME" --password-stdin + - name: Run README walkthrough e2e run: pnpm exec turbo run test:e2e --filter @cipherstash/e2e -- --run tests/prisma-example-readme.e2e.test.ts diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c17cf58250..3abfe79c34 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -470,23 +470,6 @@ jobs: id: auth-binding uses: ./.github/actions/build-auth-binding - # Run the standalone `e2e/` workspace via turbo so the `^build` - # dep on the `test:e2e` task builds cli + wizard first. CLI's own - # E2E (`languages/typescript/packages/cli/tests/e2e/**`) is covered by the `run-tests` - # job above; we filter to the new workspace here to avoid duplication. - - name: Run E2E tests - run: pnpm exec turbo run test:e2e --filter @cipherstash/e2e - - # The step above runs under turbo's strict env mode, which filters out - # every env var `turbo.json` does not declare, so the job-level CS_* - # never reach vitest there and auth-gated suites skip. The - # protect-dynamodb compatibility suite proves a migration claim made to - # customers, so the default e2e config leaves it out and it runs here - # with `--env-mode=loose`, which lets the credentials through. It fails - # rather than skips if they are missing. - - name: Run the protect-dynamodb compatibility suite - run: pnpm exec turbo run test:protect-compat --filter @cipherstash/e2e --env-mode=loose - # Docker Hub refuses pulls without a login after too many from one # address, and RunsOn machines reach that limit. With either secret empty, # as on a fork's pull request, this step does nothing and pulls stay @@ -505,6 +488,23 @@ jobs: printf '%s' "$DOCKER_HUB_PASSWORD" | docker login --username "$DOCKER_HUB_USERNAME" --password-stdin + # Run the standalone `e2e/` workspace via turbo so the `^build` + # dep on the `test:e2e` task builds cli + wizard first. CLI's own + # E2E (`languages/typescript/packages/cli/tests/e2e/**`) is covered by the `run-tests` + # job above; we filter to the new workspace here to avoid duplication. + - name: Run E2E tests + run: pnpm exec turbo run test:e2e --filter @cipherstash/e2e + + # The step above runs under turbo's strict env mode, which filters out + # every env var `turbo.json` does not declare, so the job-level CS_* + # never reach vitest there and auth-gated suites skip. The + # protect-dynamodb compatibility suite proves a migration claim made to + # customers, so the default e2e config leaves it out and it runs here + # with `--env-mode=loose`, which lets the credentials through. It fails + # rather than skips if they are missing. + - name: Run the protect-dynamodb compatibility suite + run: pnpm exec turbo run test:protect-compat --filter @cipherstash/e2e --env-mode=loose + # The DynamoDB <-> Postgres cross-store suite moves protect-dynamodb # 6.0.1 items into EQL v3 columns and back, so it needs a database. # `integration-db` gives this job its own compose project and ephemeral diff --git a/scripts/__tests__/workflow-docker-hub-login.test.mjs b/scripts/__tests__/workflow-docker-hub-login.test.mjs index 62dad7f6f7..be36a51842 100644 --- a/scripts/__tests__/workflow-docker-hub-login.test.mjs +++ b/scripts/__tests__/workflow-docker-hub-login.test.mjs @@ -212,6 +212,20 @@ function pullingTasks(index) { const PULLING_TASKS = pullingTasks(taskIndex()) +// Pulls this file cannot find, because test code or a README the test runs +// starts the container. Each named step counts as a pull. +export const HIDDEN_PULLS = { + '.github/workflows/prisma-example-readme-e2e.yml#walkthrough': { + step: 'Run README walkthrough e2e', + reason: + "e2e/tests/prisma-example-readme.e2e.test.ts runs the Prisma example's README, whose `docker compose up -d` pulls postgres:16.", + }, + '.github/workflows/tests.yml#e2e-tests': { + step: 'Run E2E tests', + reason: 'e2e/vitest.config.ts includes the same README walkthrough test.', + }, +} + // --------------------------------------------------------------------------- // Steps and jobs // --------------------------------------------------------------------------- @@ -297,7 +311,10 @@ export function jobFindings(where, job, ref) { ) } const steps = job.steps ?? [] - const firstPull = steps.findIndex((step) => stepPulls(step)) + const hidden = HIDDEN_PULLS[ref]?.step + const firstPull = steps.findIndex( + (step) => stepPulls(step) || (hidden && step?.name === hidden), + ) if (firstPull === -1) return findings const logins = steps .map((step, i) => ({ i, finding: loginFinding(step) })) @@ -385,6 +402,17 @@ describe('Docker Hub login on RunsOn', () => { expect(callerFindings()).toEqual([]) }) + it('names a RunsOn job and a real step for every hidden pull', () => { + // A stale entry would stop guarding the pull it was written for. + const stale = Object.entries(HIDDEN_PULLS) + .filter(([ref, { step }]) => { + const entry = jobs.find((j) => j.ref === ref) + return !(entry?.job.steps ?? []).some((s) => s?.name === step) + }) + .map(([ref]) => ref) + expect(stale).toEqual([]) + }) + // Every job in the tree is correct, so the test above runs none of the // branches that report a wrong one. These do. const runsOn = 'runs-on=1/family=c8a+m8a/cpu=8' From 9b868517058e26d975085136c967c3d14a5fcccf Mon Sep 17 00:00:00 2001 From: Lindsay Holmwood Date: Wed, 25 Nov 2026 02:22:26 +1100 Subject: [PATCH 13/23] ci(runners): retry apt-get update until boot-time apt lets go A fresh RunsOn machine can still be running apt from boot. The two RunsOn steps that install packages pass -o DPkg::Lock::Timeout=300, so apt-get install waits for the dpkg lock. That option does not reach apt-get update. In the apt source for 2.4, 2.7 and 2.8, update takes the package-list lock without waiting, so it fails at once while the boot run holds that lock. A review of #1416 found this. Both steps now retry apt-get update up to 20 times, 15 seconds apart. That is 5 minutes, the same as the install's lock timeout. The RunsOn guard test now also fails on an apt-get update that is not in such a loop. --- .github/workflows/_build-eql-docs.yml | 8 +++++++- .github/workflows/_build-ffi-artifacts.yml | 8 +++++++- scripts/__tests__/workflow-runs-on.test.mjs | 19 +++++++++++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/.github/workflows/_build-eql-docs.yml b/.github/workflows/_build-eql-docs.yml index 6878893b4b..f3fd186571 100644 --- a/.github/workflows/_build-eql-docs.yml +++ b/.github/workflows/_build-eql-docs.yml @@ -55,9 +55,15 @@ jobs: # A fresh RunsOn machine can still be running apt from boot, and apt-get # fails at once on a held lock unless told to wait for it. + # DPkg::Lock::Timeout makes install wait. It does not make update wait + # for the package-list lock, so update retries for up to 5 minutes. - name: Install Doxygen run: | - sudo apt-get -o DPkg::Lock::Timeout=300 update + for attempt in $(seq 1 20); do + sudo apt-get -o DPkg::Lock::Timeout=300 update && break + if [ "$attempt" -eq 20 ]; then exit 1; fi + sleep 15 + done sudo apt-get -o DPkg::Lock::Timeout=300 install -y doxygen - name: Generate documentation diff --git a/.github/workflows/_build-ffi-artifacts.yml b/.github/workflows/_build-ffi-artifacts.yml index dab6503e72..a701dd637e 100644 --- a/.github/workflows/_build-ffi-artifacts.yml +++ b/.github/workflows/_build-ffi-artifacts.yml @@ -124,11 +124,17 @@ jobs: # # A fresh RunsOn machine can still be running apt from boot, and apt-get # fails at once on a held lock unless told to wait for it. + # DPkg::Lock::Timeout makes install wait. It does not make update wait + # for the package-list lock, so update retries for up to 5 minutes. - name: Install cross-compile toolchain (linux-arm64-gnu) if: ${{ matrix.cfg.platform == 'linux-arm64-gnu' }} run: | set -euo pipefail - sudo apt-get -o DPkg::Lock::Timeout=300 update + for attempt in $(seq 1 20); do + sudo apt-get -o DPkg::Lock::Timeout=300 update && break + if [ "$attempt" -eq 20 ]; then exit 1; fi + sleep 15 + done sudo apt-get -o DPkg::Lock::Timeout=300 install -y gcc-13-aarch64-linux-gnu sudo ln -sf /usr/bin/aarch64-linux-gnu-gcc-13 /usr/bin/aarch64-linux-gnu-gcc diff --git a/scripts/__tests__/workflow-runs-on.test.mjs b/scripts/__tests__/workflow-runs-on.test.mjs index e129015b9d..cd56d46e62 100644 --- a/scripts/__tests__/workflow-runs-on.test.mjs +++ b/scripts/__tests__/workflow-runs-on.test.mjs @@ -49,11 +49,18 @@ const expressionRunnerRefs = () => const APT_COMMAND = /\bapt(?:-get)?\s.*\b(?:update|install|upgrade|dist-upgrade|remove|purge|autoremove)\b/ +// DPkg::Lock::Timeout covers only the dpkg locks. apt-get update takes the +// package-list lock without waiting, whatever the option says, so it must +// be retried in a loop that ends with `&& break`. +const APT_UPDATE = /\bapt(?:-get)?\s.*\bupdate\b/ + export function aptFinding(run) { for (const line of String(run).split('\n')) { if (/^\s*#/.test(line)) continue if (APT_COMMAND.test(line) && !line.includes('DPkg::Lock::Timeout=')) return `runs apt without waiting for the lock: "${line.trim()}". Add -o DPkg::Lock::Timeout=300.` + if (APT_UPDATE.test(line) && !/&&\s*break\b/.test(line)) + return `runs apt-get update without retrying it: "${line.trim()}". It does not wait for the package-list lock, so retry it in a loop with && break.` } return null } @@ -157,6 +164,18 @@ describe('apt on a new RunsOn machine', () => { expect(aptFinding('apt-cache policy doxygen')).toBeNull() }) + it('recognises an apt-get update that is not retried', () => { + expect( + aptFinding('sudo apt-get -o DPkg::Lock::Timeout=300 update'), + ).toMatch(/&& break/) + expect( + aptFinding(' sudo apt-get -o DPkg::Lock::Timeout=300 update && break'), + ).toBeNull() + expect( + aptFinding('sudo apt-get -o DPkg::Lock::Timeout=300 upgrade -y'), + ).toBeNull() + }) + it('waits for the apt lock in every RunsOn job', () => { expect(aptFindingsInRunsOnJobs()).toEqual([]) }) From 017d1fdb05686e83fb26254c173b414cf0beda81 Mon Sep 17 00:00:00 2001 From: Lindsay Holmwood Date: Thu, 26 Nov 2026 16:31:44 +1100 Subject: [PATCH 14/23] test(ci): share one copy of the mise task readers Three guard tests each had their own copy of the helpers that read mise task definitions. A bug in one copy was in all three. The helpers now live in scripts/__tests__/lib/mise-tasks.mjs. The Docker Hub login guard kept #MISE comment lines when it searched a task for a pull. It now strips them, as the other two guards do. A #MISE line holds settings, not commands. The guard finds the same six pulling tasks as before. This change does not alter what any guard checks. --- scripts/__tests__/crates-ci.test.mjs | 37 ++-------- scripts/__tests__/eql-suite-ci.test.mjs | 73 ++----------------- scripts/__tests__/lib/mise-tasks.mjs | 44 +++++++++++ .../workflow-docker-hub-login.test.mjs | 40 +++------- 4 files changed, 65 insertions(+), 129 deletions(-) create mode 100644 scripts/__tests__/lib/mise-tasks.mjs diff --git a/scripts/__tests__/crates-ci.test.mjs b/scripts/__tests__/crates-ci.test.mjs index 8b3a64bb3f..7bb535560f 100644 --- a/scripts/__tests__/crates-ci.test.mjs +++ b/scripts/__tests__/crates-ci.test.mjs @@ -2,6 +2,12 @@ import { execFileSync } from 'node:child_process' import { existsSync, readdirSync, readFileSync } from 'node:fs' import { join } from 'node:path' import { describe, expect, it } from 'vitest' +import { + parseIncludes, + parseStringArray, + parseTomlTasks, + stripCommentLines, +} from './lib/mise-tasks.mjs' import { REPO_ROOT } from './lib/repo-root.mjs' import { readWorkflow, WORKFLOW_DIR, workflowFiles } from './lib/workflows.mjs' @@ -38,42 +44,11 @@ const IMPORTED_WORKFLOW_DIR = '.github/imported-workflows' // The task graph // --------------------------------------------------------------------------- -/** The `["a", 'b']` inside a TOML array, without a TOML parser. */ -const parseStringArray = (inner) => - [...inner.matchAll(/"([^"]+)"|'([^']+)'/g)].map((m) => m[1] ?? m[2]) - -/** `[task_config].includes` from the root mise.toml. */ -function parseIncludes(miseText) { - const section = /^\[task_config\][^\n]*\n([\s\S]*?)(?=^\[|$(?![\s\S]))/m.exec( - miseText, - ) - const array = /^includes\s*=\s*\[([^\]]*)\]/m.exec(section?.[1] ?? '') - return array ? parseStringArray(array[1]) : [] -} - -/** - * mise task blocks. In mise.toml a task is `[tasks."name"]`; in an included - * file every top-level table is a task, `["name"]` (see - * `eql-suite-ci.test.mjs` for why the dialects must not be merged). - */ -function parseTomlTasks(text, { bareTables }) { - const header = bareTables - ? /^\[(?:"([^"]+)"|([\w:.-]+))\]/ - : /^\[tasks\.(?:"([^"]+)"|([\w:.-]+))\]/ - return text - .split(/^(?=\[)/m) - .map((block) => ({ match: header.exec(block), block })) - .filter(({ match }) => match) - .map(({ match, block }) => ({ name: match[1] ?? match[2], block })) -} - const parseDepends = (block) => { const m = /^[ \t]*depends\s*=\s*\[([^\]]*)\]/m.exec(block) return m ? parseStringArray(m[1]) : [] } -const stripCommentLines = (text) => text.replace(/^[ \t]*#.*$/gm, '') - function taskGraph() { const tasks = new Map() const bySource = new Map() diff --git a/scripts/__tests__/eql-suite-ci.test.mjs b/scripts/__tests__/eql-suite-ci.test.mjs index ee00032a80..9efedfa93c 100644 --- a/scripts/__tests__/eql-suite-ci.test.mjs +++ b/scripts/__tests__/eql-suite-ci.test.mjs @@ -3,6 +3,12 @@ import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs' import { dirname, join, relative, sep } from 'node:path' import yaml from 'js-yaml' import { describe, expect, it } from 'vitest' +import { + parseIncludes, + parseStringArray, + parseTomlTasks, + stripCommentLines, +} from './lib/mise-tasks.mjs' import { REPO_ROOT } from './lib/repo-root.mjs' import { readWorkflow, WORKFLOW_DIR, workflowFiles } from './lib/workflows.mjs' @@ -599,54 +605,6 @@ const MISE_TOML = `${EQL_PACKAGE}/mise.toml` const readRepo = (relPath) => readFileSync(join(REPO_ROOT, relPath), 'utf8') -/** The `["a", 'b']` inside a TOML array, without a TOML parser. */ -const parseStringArray = (inner) => - [...inner.matchAll(/"([^"]+)"|'([^']+)'/g)].map((m) => m[1] ?? m[2]) - -/** - * `[task_config].includes`, read rather than hard-coded. - * - * The list used to be a `MISE_CONFIGS` const here, which is a copy of a - * declaration that lives in mise.toml — and the failure mode of a stale copy is - * the one this file is about: a fourth config lands, this scan never opens it, - * and every task in it becomes unguarded silently. Reading the real list means - * a new entry is covered the day it is added; `TASK_SOURCES` below then insists - * each entry actually yielded a task, so an entry that resolves to nothing - * fails rather than contributing nothing. - */ -function parseIncludes(miseText) { - const section = /^\[task_config\][^\n]*\n([\s\S]*?)(?=^\[|$)/m.exec(miseText) - const array = /^includes\s*=\s*\[([^\]]*)\]/m.exec(section?.[1] ?? '') - return array ? parseStringArray(array[1]) : [] -} - -/** - * mise's task blocks, without a TOML parser. - * - * Adding one is an audit decision in this repo, and the shape needed here is - * small: a table header, an optional `depends = [...]`, and the body text. - * - * The two dialects are NOT interchangeable, and merging them would be wrong in - * both directions. In `mise.toml` a task is `[tasks."name"]` and a bare - * `[settings]` / `[tools]` / `[env]` table is configuration. In a file named by - * `includes` the whole document is tasks, so EVERY top-level table is a task - * name and `[tasks."name"]` is not a task at all — mise rejects the file with - * "unknown field `name`, expected one of `description`, `alias`, …". That is - * why `tasks/postgres.toml` writes `["postgres:up"]` and `tasks/fixtures.toml` - * writes `["fixture:generate:all"]`, and why the old single regex parsed 0 of - * their 6 tasks. - */ -function parseTomlTasks(text, { bareTables }) { - const header = bareTables - ? /^\[(?:"([^"]+)"|([\w:.-]+))\]/ - : /^\[tasks\.(?:"([^"]+)"|([\w:.-]+))\]/ - return text - .split(/^(?=\[)/m) // split on top-level table headers; keep header + body - .map((block) => ({ match: header.exec(block), block })) - .filter(({ match }) => match) - .map(({ match, block }) => ({ name: match[1] ?? match[2], block })) -} - /** * A task's `depends`, from either dialect. * @@ -660,25 +618,6 @@ function parseDepends(text) { return m ? parseStringArray(m[1]) : [] } -/** - * Comment lines, in both TOML and shell. Prose is not a step — see `invokes` - * and `scriptBodies`, which both read a body only after this has run. - * - * Memoised on the exact input string. The mutation test below re-runs the whole - * reachability walk once per workflow, so this is called tens of thousands of - * times over the same ~100 bodies; without the cache that test spends most of a - * second re-stripping text and starts flaking against vitest's 5s timeout. - */ -const strippedBodies = new Map() -function stripCommentLines(text) { - let stripped = strippedBodies.get(text) - if (stripped === undefined) { - stripped = text.replace(/^[ \t]*#.*$/gm, '') - strippedBodies.set(text, stripped) - } - return stripped -} - /** * How many hops of script→script delegation to follow before giving up. * diff --git a/scripts/__tests__/lib/mise-tasks.mjs b/scripts/__tests__/lib/mise-tasks.mjs new file mode 100644 index 0000000000..be8b21d105 --- /dev/null +++ b/scripts/__tests__/lib/mise-tasks.mjs @@ -0,0 +1,44 @@ +// Reads mise task definitions without a TOML parser: adding one is an audit +// decision in this repo, and the guards need only headers, `depends` and +// body text. + +export const parseStringArray = (inner) => + [...inner.matchAll(/"([^"]+)"|'([^']+)'/g)].map((m) => m[1] ?? m[2]) + +export function parseIncludes(miseText) { + const section = /^\[task_config\][^\n]*\n([\s\S]*?)(?=^\[|$(?![\s\S]))/m.exec( + miseText, + ) + const array = /^includes\s*=\s*\[([^\]]*)\]/m.exec(section?.[1] ?? '') + return array ? parseStringArray(array[1]) : [] +} + +/** + * The two dialects must not be merged. In `mise.toml` a task is + * `[tasks."name"]`, and a bare `[tools]` or `[env]` is configuration. In a + * file named by `includes`, every top-level table is a task, `["name"]`, and + * mise rejects `[tasks."name"]` there. Pass `bareTables: true` for such a file. + */ +export function parseTomlTasks(text, { bareTables }) { + const header = bareTables + ? /^\[(?:"([^"]+)"|([\w:.-]+))\]/ + : /^\[tasks\.(?:"([^"]+)"|([\w:.-]+))\]/ + return text + .split(/^(?=\[)/m) + .map((block) => ({ match: header.exec(block), block })) + .filter(({ match }) => match) + .map(({ match, block }) => ({ name: match[1] ?? match[2], block })) +} + +// Memoised: eql-suite-ci.test.mjs re-runs its reachability walk once per +// workflow, tens of thousands of calls over ~100 bodies, and without the cache +// it flakes against vitest's 5s timeout. +const strippedBodies = new Map() +export function stripCommentLines(text) { + let stripped = strippedBodies.get(text) + if (stripped === undefined) { + stripped = text.replace(/^[ \t]*#.*$/gm, '') + strippedBodies.set(text, stripped) + } + return stripped +} diff --git a/scripts/__tests__/workflow-docker-hub-login.test.mjs b/scripts/__tests__/workflow-docker-hub-login.test.mjs index be36a51842..91b7054df1 100644 --- a/scripts/__tests__/workflow-docker-hub-login.test.mjs +++ b/scripts/__tests__/workflow-docker-hub-login.test.mjs @@ -2,6 +2,12 @@ import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs' import { dirname, join, relative } from 'node:path' import { describe, expect, it } from 'vitest' import { expr } from './lib/expressions.mjs' +import { + parseIncludes, + parseStringArray, + parseTomlTasks, + stripCommentLines, +} from './lib/mise-tasks.mjs' import { REPO_ROOT } from './lib/repo-root.mjs' import { isRunsOnJob } from './lib/runs-on.mjs' import { readWorkflow, workflowFiles } from './lib/workflows.mjs' @@ -91,32 +97,6 @@ function miseConfigs(dir = REPO_ROOT, found = []) { return found } -const parseStringArray = (inner) => - [...inner.matchAll(/"([^"]+)"|'([^']+)'/g)].map((m) => m[1] ?? m[2]) - -function parseIncludes(text) { - const section = /^\[task_config\][^\n]*\n([\s\S]*?)(?=^\[|$(?![\s\S]))/m.exec( - text, - ) - const array = /^includes\s*=\s*\[([^\]]*)\]/m.exec(section?.[1] ?? '') - return array ? parseStringArray(array[1]) : [] -} - -/** - * Task blocks. A mise config writes `[tasks."name"]`; an included file makes - * every top-level table a task, `["name"]`. - */ -function parseTomlTasks(text, { bareTables }) { - const header = bareTables - ? /^\[(?:"([^"]+)"|([\w:.-]+))\]/ - : /^\[tasks\.(?:"([^"]+)"|([\w:.-]+))\]/ - return text - .split(/^(?=\[)/m) - .map((block) => ({ match: header.exec(block), block })) - .filter(({ match }) => match) - .map(({ match, block }) => ({ name: match[1] ?? match[2], body: block })) -} - /** File tasks: `tasks/test/splinter.sh` is the task `test:splinter`. */ function fileTasks(dir, base = dir, found = []) { for (const name of readdirSync(dir)) { @@ -128,7 +108,7 @@ function fileTasks(dir, base = dir, found = []) { .replace(/\.[^./]+$/, '') .split('/') .join(':'), - body: readFileSync(path, 'utf8'), + block: readFileSync(path, 'utf8'), }) } return found @@ -141,9 +121,9 @@ function fileTasks(dir, base = dir, found = []) { */ function taskIndex() { const index = new Map() - const add = ({ name, body }) => { + const add = ({ name, block }) => { if (!index.has(name)) index.set(name, []) - index.get(name).push(body) + index.get(name).push(block) } for (const config of miseConfigs()) { const text = readFileSync(join(REPO_ROOT, config), 'utf8') @@ -161,8 +141,6 @@ function taskIndex() { return index } -const stripCommentLines = (text) => text.replace(/^[ \t]*#(?!MISE).*$/gm, '') - // A quote starts a command only at the start of a line, as in a TOML // `run = [ "mise run …" ]` entry. Mid-line it is a message to the reader. const COMMAND_START = String.raw`(?:^[ \t]*["']?|(?:&&|\|\||[;|(){}])[ \t]*)` From 0100f1054c3e1846228bff5d4539c3d7e0eca80b Mon Sep 17 00:00:00 2001 From: Lindsay Holmwood Date: Thu, 26 Nov 2026 16:32:32 +1100 Subject: [PATCH 15/23] test(ci): end a mise task only at a table header The mise task reader split a file at every line that starts with "[". A shell test such as `[ -n "$listing" ] || exit 1` inside a multi-line run string also starts with "[". The reader then dropped the rest of that task. Six tasks in packages/eql/mise.toml were cut short this way. A command after such a line was invisible to the guards. A `docker run` there would not have needed a Docker Hub login, and a cargo call there would not have counted as a caller. The reader now splits only at a line that is a whole table header, such as `[tools]`, `[tasks."name"]`, or `["name"]`. None of the six tasks pulls an image or calls a task after its "[" line today, so the guards report the same results. --- scripts/__tests__/lib/mise-tasks.mjs | 14 +++++-- scripts/__tests__/mise-tasks.test.mjs | 54 +++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 4 deletions(-) create mode 100644 scripts/__tests__/mise-tasks.test.mjs diff --git a/scripts/__tests__/lib/mise-tasks.mjs b/scripts/__tests__/lib/mise-tasks.mjs index be8b21d105..035d36fb62 100644 --- a/scripts/__tests__/lib/mise-tasks.mjs +++ b/scripts/__tests__/lib/mise-tasks.mjs @@ -5,10 +5,16 @@ export const parseStringArray = (inner) => [...inner.matchAll(/"([^"]+)"|'([^']+)'/g)].map((m) => m[1] ?? m[2]) +// A whole line that names a table. A line of a multi-line `run` string can +// also start with `[`, such as `[ -n "$x" ] || exit 1`, and is not a header. +const TABLE_HEADER = String.raw`\[(?:tasks\.)?(?:"[^"]+"|[\w:.-]+)\][ \t]*(?:#[^\n]*)?$` +const BEFORE_HEADER = new RegExp(`^(?=${TABLE_HEADER})`, 'm') + export function parseIncludes(miseText) { - const section = /^\[task_config\][^\n]*\n([\s\S]*?)(?=^\[|$(?![\s\S]))/m.exec( - miseText, - ) + const section = new RegExp( + String.raw`^\[task_config\][^\n]*\n([\s\S]*?)(?=^${TABLE_HEADER}|$(?![\s\S]))`, + 'm', + ).exec(miseText) const array = /^includes\s*=\s*\[([^\]]*)\]/m.exec(section?.[1] ?? '') return array ? parseStringArray(array[1]) : [] } @@ -24,7 +30,7 @@ export function parseTomlTasks(text, { bareTables }) { ? /^\[(?:"([^"]+)"|([\w:.-]+))\]/ : /^\[tasks\.(?:"([^"]+)"|([\w:.-]+))\]/ return text - .split(/^(?=\[)/m) + .split(BEFORE_HEADER) .map((block) => ({ match: header.exec(block), block })) .filter(({ match }) => match) .map(({ match, block }) => ({ name: match[1] ?? match[2], block })) diff --git a/scripts/__tests__/mise-tasks.test.mjs b/scripts/__tests__/mise-tasks.test.mjs new file mode 100644 index 0000000000..6ad9c2a169 --- /dev/null +++ b/scripts/__tests__/mise-tasks.test.mjs @@ -0,0 +1,54 @@ +import { describe, expect, it } from 'vitest' +import { parseIncludes, parseTomlTasks } from './lib/mise-tasks.mjs' + +describe('reading mise tasks', () => { + it('keeps a shell line that starts with [ inside its task', () => { + const text = [ + '[tasks."test:pg"]', + 'run = """', + 'listing=$(cargo test --list)', + '[ -n "$listing" ] || { echo "no tests" >&2; exit 1; }', + 'docker run --rm postgres:17 true', + '"""', + '', + '[tasks.other]', + 'run = "true"', + ].join('\n') + const tasks = parseTomlTasks(text, { bareTables: false }) + expect(tasks.map(({ name }) => name)).toEqual(['test:pg', 'other']) + expect(tasks[0].block).toContain('docker run --rm postgres:17 true') + }) + + it('splits at each form of table header', () => { + const text = [ + '[tools]', + 'node = "24"', + '[tasks."a:b"] # a comment', + 'run = "one"', + '[tasks.c]', + 'run = "two"', + '[env]', + 'X = "1"', + ].join('\n') + const tasks = parseTomlTasks(text, { bareTables: false }) + expect(tasks.map(({ name }) => name)).toEqual(['a:b', 'c']) + expect(tasks[1].block).not.toContain('X = "1"') + expect( + parseTomlTasks('["x"]\nrun = "1"\n[y]\nrun = "2"\n', { + bareTables: true, + }).map(({ name }) => name), + ).toEqual(['x', 'y']) + }) + + it('reads includes that span lines', () => { + const text = [ + '[task_config]', + 'includes = [', + ' "a/tasks.toml",', + " 'b',", + ']', + '[env]', + ].join('\n') + expect(parseIncludes(text)).toEqual(['a/tasks.toml', 'b']) + }) +}) From a3b15bba63b329754f65fc2ea69b91ffda4248f8 Mon Sep 17 00:00:00 2001 From: Lindsay Holmwood Date: Thu, 26 Nov 2026 16:32:58 +1100 Subject: [PATCH 16/23] test(ci): share one way to expand a local composite action The apt guard and the Docker Hub login guard each expanded a step that uses a local composite action into the action's own steps. The two copies did the same work in the same way. The expander is now stepsOf in scripts/__tests__/lib/workflows.mjs, and both guards call it. This change does not alter what either guard checks. --- scripts/__tests__/lib/workflows.mjs | 23 ++++++++++++- .../workflow-docker-hub-login.test.mjs | 33 +++++++------------ scripts/__tests__/workflow-runs-on.test.mjs | 22 +------------ 3 files changed, 35 insertions(+), 43 deletions(-) diff --git a/scripts/__tests__/lib/workflows.mjs b/scripts/__tests__/lib/workflows.mjs index e8f933176a..40b2b9b5e4 100644 --- a/scripts/__tests__/lib/workflows.mjs +++ b/scripts/__tests__/lib/workflows.mjs @@ -1,4 +1,4 @@ -import { readdirSync, readFileSync } from 'node:fs' +import { existsSync, readdirSync, readFileSync } from 'node:fs' import { join } from 'node:path' import yaml from 'js-yaml' import { REPO_ROOT } from './repo-root.mjs' @@ -53,3 +53,24 @@ export function workflowFiles() { export function readWorkflow(relPath) { return yaml.load(readFileSync(join(REPO_ROOT, relPath), 'utf8')) } + +/** + * A step, or the steps of the local composite action it uses, expanded through + * nested local actions. A cycle between actions, or a missing manifest, adds + * no steps. + */ +export function stepsOf(step, seen = new Set()) { + const uses = typeof step?.uses === 'string' ? step.uses.trim() : '' + if (!uses.startsWith('./')) return [step] + const dir = uses.replace(/^\.\//, '').replace(/\/$/, '') + if (seen.has(dir)) return [] + seen.add(dir) + for (const file of ['action.yml', 'action.yaml']) { + const rel = `${dir}/${file}` + if (existsSync(join(REPO_ROOT, rel))) + return (readWorkflow(rel)?.runs?.steps ?? []).flatMap((inner) => + stepsOf(inner, seen), + ) + } + return [] +} diff --git a/scripts/__tests__/workflow-docker-hub-login.test.mjs b/scripts/__tests__/workflow-docker-hub-login.test.mjs index 91b7054df1..2740ee0c8a 100644 --- a/scripts/__tests__/workflow-docker-hub-login.test.mjs +++ b/scripts/__tests__/workflow-docker-hub-login.test.mjs @@ -10,7 +10,7 @@ import { } from './lib/mise-tasks.mjs' import { REPO_ROOT } from './lib/repo-root.mjs' import { isRunsOnJob } from './lib/runs-on.mjs' -import { readWorkflow, workflowFiles } from './lib/workflows.mjs' +import { readWorkflow, stepsOf, workflowFiles } from './lib/workflows.mjs' /** * Every RunsOn job logs in to Docker Hub before it pulls an image. @@ -208,26 +208,17 @@ export const HIDDEN_PULLS = { // Steps and jobs // --------------------------------------------------------------------------- -/** Whether one step may pull an image. `seen` guards composite-action cycles. */ -export function stepPulls(step, seen = new Set()) { - const uses = typeof step?.uses === 'string' ? step.uses.trim() : '' - if (PULLING_ACTION.test(uses)) return true - if (uses.startsWith('./')) { - const dir = uses.replace(/^\.\//, '').replace(/\/$/, '') - if (seen.has(dir)) return false - seen.add(dir) - for (const file of ['action.yml', 'action.yaml']) { - const rel = `${dir}/${file}` - if (!existsSync(join(REPO_ROOT, rel))) continue - const steps = readWorkflow(rel)?.runs?.steps ?? [] - return steps.some((inner) => stepPulls(inner, seen)) - } - return false - } - const run = typeof step?.run === 'string' ? stripCommentLines(step.run) : '' - return ( - PULLS.test(run) || [...PULLING_TASKS].some((task) => invokes(run, task)) - ) +/** Whether one step, or the local composite action it uses, may pull an image. */ +export function stepPulls(step) { + return stepsOf(step).some((inner) => { + const uses = typeof inner?.uses === 'string' ? inner.uses.trim() : '' + if (PULLING_ACTION.test(uses)) return true + const run = + typeof inner?.run === 'string' ? stripCommentLines(inner.run) : '' + return ( + PULLS.test(run) || [...PULLING_TASKS].some((task) => invokes(run, task)) + ) + }) } const USERNAME = expr('secrets.DOCKER_HUB_USERNAME') diff --git a/scripts/__tests__/workflow-runs-on.test.mjs b/scripts/__tests__/workflow-runs-on.test.mjs index cd56d46e62..bf56d27b4d 100644 --- a/scripts/__tests__/workflow-runs-on.test.mjs +++ b/scripts/__tests__/workflow-runs-on.test.mjs @@ -1,14 +1,11 @@ -import { existsSync } from 'node:fs' -import { join } from 'node:path' import { describe, expect, it } from 'vitest' -import { REPO_ROOT } from './lib/repo-root.mjs' import { isRunsOnJob, MATRIX_RUNNERS, RUNS_ON_LABELS, runsOnLabel, } from './lib/runs-on.mjs' -import { readWorkflow, workflowFiles } from './lib/workflows.mjs' +import { readWorkflow, stepsOf, workflowFiles } from './lib/workflows.mjs' /** * Every self-hosted job runs on a RunsOn machine of the size its Blacksmith @@ -65,23 +62,6 @@ export function aptFinding(run) { return null } -/** A step, or the steps of the local composite action it uses. */ -function stepsOf(step, seen = new Set()) { - const uses = typeof step?.uses === 'string' ? step.uses.trim() : '' - if (!uses.startsWith('./')) return [step] - const dir = uses.replace(/^\.\//, '').replace(/\/$/, '') - if (seen.has(dir)) return [] - seen.add(dir) - for (const file of ['action.yml', 'action.yaml']) { - const rel = `${dir}/${file}` - if (existsSync(join(REPO_ROOT, rel))) - return (readWorkflow(rel)?.runs?.steps ?? []).flatMap((inner) => - stepsOf(inner, seen), - ) - } - return [] -} - export function aptFindingsInRunsOnJobs() { return jobs .filter(({ job, ref }) => isRunsOnJob(job, ref)) From e7a3b5e0ef7f4c823c6eb4cf86432b98a2613ef0 Mon Sep 17 00:00:00 2001 From: Lindsay Holmwood Date: Thu, 26 Nov 2026 16:33:48 +1100 Subject: [PATCH 17/23] test(ci): find more ways a step can pull an image The Docker Hub login guard decides which steps may pull an image. It missed these commands: - `docker compose pull`, `run`, and `create` - `docker-compose run` and `pull` - `docker buildx bake` - `docker container run` and `create` - `docker image pull` It also read a `\`-continued command one line at a time. So `docker compose \` with `up -d` on the next line was not a pull, and neither was `mise run \` with the task name on the next line. A RunsOn step that pulled in one of those ways needed no login under the guard. The guard now matches all of them, and joins continued lines before it matches. No job in the tree pulls without a login under the wider match. --- .../workflow-docker-hub-login.test.mjs | 39 +++++++++++++++---- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/scripts/__tests__/workflow-docker-hub-login.test.mjs b/scripts/__tests__/workflow-docker-hub-login.test.mjs index 2740ee0c8a..a07c9a5b33 100644 --- a/scripts/__tests__/workflow-docker-hub-login.test.mjs +++ b/scripts/__tests__/workflow-docker-hub-login.test.mjs @@ -55,8 +55,19 @@ import { readWorkflow, stepsOf, workflowFiles } from './lib/workflows.mjs' // --------------------------------------------------------------------------- /** A command that starts or builds a container, so may pull an image. */ -const PULLS = - /\bdocker(?:-compose\s+up\b|\s+(?:compose\b[^\n]*\bup\b|run\b|pull\b|create\b|build\b|buildx\s+build\b))/ +const PULLS = new RegExp( + [ + String.raw`\bdocker(?:-compose|\s+compose)\b[^\n]*\b(?:up|pull|run|create)\b`, + String.raw`\bdocker\s+(?:run|pull|create|build)\b`, + String.raw`\bdocker\s+buildx\s+(?:build|bake)\b`, + String.raw`\bdocker\s+container\s+(?:run|create)\b`, + String.raw`\bdocker\s+image\s+(?:pull|build)\b`, + ].join('|'), +) + +/** Comment lines gone, and each `\`-continued command on one line. */ +const commands = (script) => + stripCommentLines(script).replace(/\\\r?\n[ \t]*/g, ' ') /** * `docker/` actions that pull: QEMU's binfmt image, the BuildKit image, and @@ -150,7 +161,7 @@ function invokes(text, taskName) { return new RegExp( `${COMMAND_START}mise\\s+run\\s+[^\\n'"]*?(? @@ -162,9 +173,7 @@ const dependsOf = (body) => function pullingTasks(index) { const pulling = new Set( [...index] - .filter(([, bodies]) => - bodies.some((body) => PULLS.test(stripCommentLines(body))), - ) + .filter(([, bodies]) => bodies.some((body) => PULLS.test(commands(body)))) .map(([name]) => name), ) // Grow the set until nothing new reaches a member: a fixpoint, so a cycle @@ -213,8 +222,7 @@ export function stepPulls(step) { return stepsOf(step).some((inner) => { const uses = typeof inner?.uses === 'string' ? inner.uses.trim() : '' if (PULLING_ACTION.test(uses)) return true - const run = - typeof inner?.run === 'string' ? stripCommentLines(inner.run) : '' + const run = typeof inner?.run === 'string' ? commands(inner.run) : '' return ( PULLS.test(run) || [...PULLING_TASKS].some((task) => invokes(run, task)) ) @@ -493,7 +501,22 @@ describe('Docker Hub login on RunsOn', () => { expect(stepPulls({ uses: './.github/actions/integration-db' })).toBe(true) expect(stepPulls({ uses: 'docker/setup-qemu-action@abc' })).toBe(true) expect(stepPulls({ uses: 'docker/login-action@abc' })).toBe(false) + for (const run of [ + 'docker compose \\\n -f x.yml \\\n up -d', + 'docker compose -f x.yml pull', + 'docker compose run --rm app true', + 'docker compose create', + 'docker-compose run app true', + 'docker-compose pull', + 'docker buildx bake', + 'docker container run --rm alpine true', + 'docker container create alpine', + 'docker image pull alpine', + 'mise run \\\n postgres:up', + ]) + expect({ run, pulls: stepPulls({ run }) }).toEqual({ run, pulls: true }) expect(stepPulls({ run: 'docker exec -i pg psql -f-' })).toBe(false) + expect(stepPulls({ run: 'docker compose logs pg' })).toBe(false) expect(stepPulls({ run: 'docker compose down' })).toBe(false) expect(stepPulls({ run: '# docker run in a comment' })).toBe(false) }) From 43cfff23b0900f744482348ea694f7bf80c15500 Mon Sep 17 00:00:00 2001 From: Lindsay Holmwood Date: Thu, 26 Nov 2026 16:34:20 +1100 Subject: [PATCH 18/23] test(ci): read apt commands as the shell does The apt guard reported two kinds of command wrongly. - It treated any "update" after `apt` as `apt-get update`. So `apt-get -o DPkg::Lock::Timeout=300 install -y update-notifier-common` was reported as an update without a retry. The guard now needs `update` to be the subcommand. - It checked each physical line on its own. A command split with `\` that does wait for the lock was reported as one that does not, and `update \` with `&& break` on the next line was reported as not retried. The guard now joins continued lines first. No step in the tree uses either form today, so the guard's result on the tree is the same. --- scripts/__tests__/workflow-runs-on.test.mjs | 34 +++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/scripts/__tests__/workflow-runs-on.test.mjs b/scripts/__tests__/workflow-runs-on.test.mjs index bf56d27b4d..278205371e 100644 --- a/scripts/__tests__/workflow-runs-on.test.mjs +++ b/scripts/__tests__/workflow-runs-on.test.mjs @@ -49,10 +49,15 @@ const APT_COMMAND = // DPkg::Lock::Timeout covers only the dpkg locks. apt-get update takes the // package-list lock without waiting, whatever the option says, so it must // be retried in a loop that ends with `&& break`. -const APT_UPDATE = /\bapt(?:-get)?\s.*\bupdate\b/ +// +// `update` must be the subcommand: options, each with an optional value, may +// come before it, but a package name such as update-notifier-common is not it. +const APT_UPDATE = + /\bapt(?:-get)?\s+(?:-\S+\s+(?:(?!-)\S+\s+)?)*update(?![\w-])/ export function aptFinding(run) { - for (const line of String(run).split('\n')) { + const joined = String(run).replace(/\\\r?\n[ \t]*/g, ' ') + for (const line of joined.split('\n')) { if (/^\s*#/.test(line)) continue if (APT_COMMAND.test(line) && !line.includes('DPkg::Lock::Timeout=')) return `runs apt without waiting for the lock: "${line.trim()}". Add -o DPkg::Lock::Timeout=300.` @@ -154,6 +159,31 @@ describe('apt on a new RunsOn machine', () => { expect( aptFinding('sudo apt-get -o DPkg::Lock::Timeout=300 upgrade -y'), ).toBeNull() + expect( + aptFinding('sudo apt-get -q -o DPkg::Lock::Timeout=300 update'), + ).toMatch(/&& break/) + // A package whose name starts with "update" is not an update. + expect( + aptFinding( + 'sudo apt-get -o DPkg::Lock::Timeout=300 install -y update-notifier-common', + ), + ).toBeNull() + }) + + it('reads a command continued with a backslash as one line', () => { + expect( + aptFinding( + 'sudo apt-get install -y \\\n -o DPkg::Lock::Timeout=300 doxygen', + ), + ).toBeNull() + expect( + aptFinding( + 'sudo apt-get -o DPkg::Lock::Timeout=300 update \\\n && break', + ), + ).toBeNull() + expect(aptFinding('sudo apt-get install -y \\\n doxygen')).toMatch( + /DPkg::Lock::Timeout/, + ) }) it('waits for the apt lock in every RunsOn job', () => { From 1fd007a39c0e63c106520941cf904e76410ee4ae Mon Sep 17 00:00:00 2001 From: Lindsay Holmwood Date: Thu, 26 Nov 2026 16:42:21 +1100 Subject: [PATCH 19/23] test(ci): read only tracked mise files in the login guard The Docker Hub login guard found mise configs and file tasks by walking the working tree with statSync, as soon as the file loaded. statSync follows symbolic links. So one broken link in any untracked folder failed the whole test file with ENOENT, and a link loop made the walk run forever. The walk also read gitignored files such as mise.local.toml, and descended into .claude/worktrees. The guard now lists files with `git ls-files`. A broken link in an untracked folder no longer fails it. The guard finds the same six pulling tasks as before. --- .../workflow-docker-hub-login.test.mjs | 58 ++++++++++--------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/scripts/__tests__/workflow-docker-hub-login.test.mjs b/scripts/__tests__/workflow-docker-hub-login.test.mjs index a07c9a5b33..4215b96fa9 100644 --- a/scripts/__tests__/workflow-docker-hub-login.test.mjs +++ b/scripts/__tests__/workflow-docker-hub-login.test.mjs @@ -1,5 +1,6 @@ -import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs' -import { dirname, join, relative } from 'node:path' +import { execFileSync } from 'node:child_process' +import { existsSync, readFileSync, statSync } from 'node:fs' +import { basename, dirname, join, relative } from 'node:path' import { describe, expect, it } from 'vitest' import { expr } from './lib/expressions.mjs' import { @@ -94,35 +95,36 @@ export function onDockerHub(image) { // mise tasks // --------------------------------------------------------------------------- -const SKIP_DIRS = new Set(['node_modules', '.git', 'target', 'dist']) - -/** Every tracked-looking `mise.toml` / `mise..toml`, repo-relative. */ -function miseConfigs(dir = REPO_ROOT, found = []) { - for (const name of readdirSync(dir)) { - if (SKIP_DIRS.has(name)) continue - const path = join(dir, name) - if (statSync(path).isDirectory()) miseConfigs(path, found) - else if (/^\.?mise(\.[\w-]+)?\.toml$/.test(name)) - found.push(relative(REPO_ROOT, path)) - } - return found +// Tracked files only. A walk of the working tree would read gitignored +// configs such as mise.local.toml, descend into .claude/worktrees, and fail on +// a broken symbolic link anywhere in an untracked folder. +function trackedFiles(relDir = '.') { + return execFileSync('git', ['ls-files', '-z', '--', relDir], { + cwd: REPO_ROOT, + encoding: 'utf8', + }) + .split('\0') + .filter(Boolean) } +/** Every `mise.toml` / `mise..toml`, repo-relative. */ +const miseConfigs = () => + trackedFiles().filter((rel) => + /^\.?mise(\.[\w-]+)?\.toml$/.test(basename(rel)), + ) + /** File tasks: `tasks/test/splinter.sh` is the task `test:splinter`. */ -function fileTasks(dir, base = dir, found = []) { - for (const name of readdirSync(dir)) { - const path = join(dir, name) - if (statSync(path).isDirectory()) fileTasks(path, base, found) - else if (!name.endsWith('.toml')) - found.push({ - name: relative(base, path) - .replace(/\.[^./]+$/, '') - .split('/') - .join(':'), - block: readFileSync(path, 'utf8'), - }) - } - return found +function fileTasks(dir) { + const relDir = relative(REPO_ROOT, dir) + return trackedFiles(relDir) + .filter((rel) => !rel.endsWith('.toml')) + .map((rel) => ({ + name: relative(relDir, rel) + .replace(/\.[^./]+$/, '') + .split('/') + .join(':'), + block: readFileSync(join(REPO_ROOT, rel), 'utf8'), + })) } /** From 067cc2caaa44073fcf97cc2309edfa8e5c35bdc0 Mon Sep 17 00:00:00 2001 From: Lindsay Holmwood Date: Thu, 26 Nov 2026 16:44:44 +1100 Subject: [PATCH 20/23] ci(runners): say a fork pull request only where one can run Four comments above a Docker Hub login said the step does nothing "as on a fork's pull request". None of those workflows runs for a pull request: - release-postgres-eql-image.yml runs only by manual dispatch. - _build-ffi-artifacts.yml is called by release.yml, which runs on pushes to main, and by ffi-preflight.yml, which runs by dispatch. - bench-eql.yml runs on push, on a schedule, and by dispatch. The comments now say only that the step does nothing when either secret is empty. --- .github/workflows/_build-ffi-artifacts.yml | 6 +++--- .github/workflows/bench-eql.yml | 5 ++--- .github/workflows/release-postgres-eql-image.yml | 10 ++++------ 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/.github/workflows/_build-ffi-artifacts.yml b/.github/workflows/_build-ffi-artifacts.yml index a701dd637e..805ca4b58d 100644 --- a/.github/workflows/_build-ffi-artifacts.yml +++ b/.github/workflows/_build-ffi-artifacts.yml @@ -234,9 +234,9 @@ jobs: # Docker Hub refuses pulls without a login after too many from one # address, and RunsOn machines reach that limit. With either secret empty, - # as on a fork's pull request, this step does nothing and pulls stay - # anonymous. scripts/__tests__/workflow-docker-hub-login.test.mjs - # requires it. Only the RunsOn legs log in. The macOS leg has no Docker, + # this step does nothing and pulls stay anonymous. + # scripts/__tests__/workflow-docker-hub-login.test.mjs requires it. Only + # the RunsOn legs log in. The macOS leg has no Docker, # so `docker login` would fail there once the secrets exist. - name: Log in to Docker Hub if: ${{ startsWith(matrix.cfg.os, 'runs-on=') }} diff --git a/.github/workflows/bench-eql.yml b/.github/workflows/bench-eql.yml index 6912f5130a..f78d9ba6e4 100644 --- a/.github/workflows/bench-eql.yml +++ b/.github/workflows/bench-eql.yml @@ -148,9 +148,8 @@ jobs: # Docker Hub refuses pulls without a login after too many from one # address, and RunsOn machines reach that limit. With either secret empty, - # as on a fork's pull request, this step does nothing and pulls stay - # anonymous. scripts/__tests__/workflow-docker-hub-login.test.mjs - # requires it. + # this step does nothing and pulls stay anonymous. + # scripts/__tests__/workflow-docker-hub-login.test.mjs requires it. - name: Log in to Docker Hub env: DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }} diff --git a/.github/workflows/release-postgres-eql-image.yml b/.github/workflows/release-postgres-eql-image.yml index d6344ed098..735c621fec 100644 --- a/.github/workflows/release-postgres-eql-image.yml +++ b/.github/workflows/release-postgres-eql-image.yml @@ -137,9 +137,8 @@ jobs: # Docker Hub refuses pulls without a login after too many from one # address, and RunsOn machines reach that limit. With either secret empty, - # as on a fork's pull request, this step does nothing and pulls stay - # anonymous. scripts/__tests__/workflow-docker-hub-login.test.mjs - # requires it. + # this step does nothing and pulls stay anonymous. + # scripts/__tests__/workflow-docker-hub-login.test.mjs requires it. - name: Log in to Docker Hub env: DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }} @@ -219,9 +218,8 @@ jobs: steps: # Docker Hub refuses pulls without a login after too many from one # address, and RunsOn machines reach that limit. With either secret empty, - # as on a fork's pull request, this step does nothing and pulls stay - # anonymous. scripts/__tests__/workflow-docker-hub-login.test.mjs - # requires it. + # this step does nothing and pulls stay anonymous. + # scripts/__tests__/workflow-docker-hub-login.test.mjs requires it. - name: Log in to Docker Hub env: DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }} From d4cb035871e22aa7d86f963abbadf119b70cb17d Mon Sep 17 00:00:00 2001 From: Lindsay Holmwood Date: Thu, 26 Nov 2026 16:44:50 +1100 Subject: [PATCH 21/23] ci(runners): stop calling Blacksmith the current runner in comments After the swap, every self-hosted job runs on RunsOn. Seven comments still described Blacksmith as the runner: - workflow-mise-cache-image.test.mjs explained the shared cache key with Blacksmith labels. It now uses the two RunsOn images. - eql-suite-ci.test.mjs said the root actionlint.yaml carries a Blacksmith label. It lists no self-hosted labels now. - lint-no-workflow-caching.mjs and its third-party cache fixture said eleven jobs run on Blacksmith. They now name RunsOn's own drop-in cache action, runs-on/cache, beside Blacksmith's. - dependabot.yml called tests-rust.yml a Blacksmith job. - release.yml and tests-supply-chain.yml contrasted their GitHub-hosted runner with Blacksmith. Only comments change. --- .github/dependabot.yml | 2 +- .github/workflows/release.yml | 2 +- .github/workflows/tests-supply-chain.yml | 2 +- scripts/__tests__/eql-suite-ci.test.mjs | 6 ++++-- .../lint-no-workflow-caching/thirdparty-cache.yml | 6 +++--- scripts/__tests__/workflow-mise-cache-image.test.mjs | 6 +++--- scripts/lint-no-workflow-caching.mjs | 8 ++++---- 7 files changed, 17 insertions(+), 15 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 3b2407d024..7a83f16156 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -78,7 +78,7 @@ updates: versioning-strategy: lockfile-only # Monthly, where npm and actions are weekly. The deviation is about # validation cost, not risk appetite: a Cargo.lock bump is checked by - # tests-rust.yml — one Blacksmith job, 45-minute timeout, cargo test + + # tests-rust.yml — one RunsOn job, 45-minute timeout, cargo test + # clippy on host AND wasm32 — and the release additionally cross-builds # six platform binaries. Security fixes are not delayed by this: Dependabot # security updates are driven by alerts, not by `schedule`. diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0a22b72006..8fe0acfb32 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -498,7 +498,7 @@ jobs: needs.gate.outputs.auth != 'true' || needs.publish-auth.result == 'success' ) - # GitHub-hosted (not Blacksmith): npm provenance attestations, which are + # GitHub-hosted (not RunsOn): npm provenance attestations, which are # generated automatically by OIDC trusted publishing, are only accepted # from github-hosted runners — self-hosted runners are rejected with E422. runs-on: ubuntu-latest diff --git a/.github/workflows/tests-supply-chain.yml b/.github/workflows/tests-supply-chain.yml index d2831856f7..589d241596 100644 --- a/.github/workflows/tests-supply-chain.yml +++ b/.github/workflows/tests-supply-chain.yml @@ -13,7 +13,7 @@ name: Test supply chain security # See the "CI/CD Supply-Chain Hardening" section of SECURITY.md. # # Deliberately minimal: -# - GitHub-hosted runner (no Blacksmith transparent cache) +# - GitHub-hosted runner (no RunsOn transparent S3 cache) # - contents:read only # - no secrets # - no caching diff --git a/scripts/__tests__/eql-suite-ci.test.mjs b/scripts/__tests__/eql-suite-ci.test.mjs index 9efedfa93c..2f77d8d756 100644 --- a/scripts/__tests__/eql-suite-ci.test.mjs +++ b/scripts/__tests__/eql-suite-ci.test.mjs @@ -1486,8 +1486,10 @@ describe('the guard fails when a workflow stops calling a cargo check', () => { * site. Versioned docs artifacts are still * built by _build-eql-docs.yml * lint-release.yml -> merged into the root file of that name - * .github/actionlint.yaml -> DROPPED: the root copy already carries the - * `blacksmith-16vcpu-ubuntu-2204` label + * .github/actionlint.yaml -> DROPPED: the root copy is the one + * actionlint reads, and it lists every + * self-hosted runner label (none, since + * RunsOn labels are expressions) * ISSUE_TEMPLATE/docs-feedback.yml -> DROPPED: the root copy is the same file * with the Code of Conduct link already * repointed at cipherstash/stack diff --git a/scripts/__tests__/fixtures/lint-no-workflow-caching/thirdparty-cache.yml b/scripts/__tests__/fixtures/lint-no-workflow-caching/thirdparty-cache.yml index 391079b250..cf2346314c 100644 --- a/scripts/__tests__/fixtures/lint-no-workflow-caching/thirdparty-cache.yml +++ b/scripts/__tests__/fixtures/lint-no-workflow-caching/thirdparty-cache.yml @@ -2,9 +2,9 @@ # `^actions/cache(/(restore|save))?@`, and neither carries a `cache:` input for # the `with.cache` rule to read. Both restore the GitHub Actions cache anyway. # -# Not hypothetical. This repo runs eleven jobs on `blacksmith-*` runners, where -# `useblacksmith/cache` is the documented drop-in for `actions/cache`, and it -# has just absorbed a Cargo workspace at `packages/protect-ffi`, where +# Not hypothetical. Each runner vendor publishes a drop-in for `actions/cache`: +# `useblacksmith/cache` for Blacksmith, and `runs-on/cache` for RunsOn, where +# this repo's self-hosted jobs run. The repo has also absorbed a Cargo workspace at `packages/protect-ffi`, where # `Swatinem/rust-cache` is the conventional choice. Either could be added by # someone who reasonably believed this gate would catch the mistake. name: Third Party Cache diff --git a/scripts/__tests__/workflow-mise-cache-image.test.mjs b/scripts/__tests__/workflow-mise-cache-image.test.mjs index 1250b9cd6f..3d7f417b2a 100644 --- a/scripts/__tests__/workflow-mise-cache-image.test.mjs +++ b/scripts/__tests__/workflow-mise-cache-image.test.mjs @@ -8,9 +8,9 @@ import { readWorkflow, workflowFiles } from './lib/workflows.mjs' * Every cached `jdx/mise-action` step keys its cache by runner image. * * mise-action's default key is `mise-v1-----`. It names Linux, not the distro, so a job on - * `blacksmith-*-ubuntu-2404` (glibc 2.39) and one on `…-ubuntu-2204` (glibc - * 2.35) read and write the same entry. The `cargo:` tools in `mise.test.toml` + * of the mise config>`. It names Linux, not the distro, so a job on a RunsOn + * `image=ubuntu24-full-x64` machine (glibc 2.39) and one on + * `image=ubuntu22-full-x64` (glibc 2.35) read and write the same entry. The `cargo:` tools in `mise.test.toml` * are built where they are installed, so whichever job saves the key first * decides what glibc every other job's `cargo-nextest` and `cargo-llvm-cov` * need. When a 2404 job (fuzz, udeps) wins, every 2204 job dies with diff --git a/scripts/lint-no-workflow-caching.mjs b/scripts/lint-no-workflow-caching.mjs index 2fbb7d88b8..cfaf2d3140 100644 --- a/scripts/lint-no-workflow-caching.mjs +++ b/scripts/lint-no-workflow-caching.mjs @@ -80,10 +80,10 @@ const PARENT_USES = /^\.\.\// // `actions/cache*`, and an action that takes a `cache:` input. A third-party // cache action has neither, so it was invisible to the whole file. Reproduced // against a composite reached from a targeted workflow holding -// `useblacksmith/cache@v5` and `Swatinem/rust-cache@v2`: `OK`, exit 0. Both are -// live-relevant here — eleven jobs in this repo run on `blacksmith-*` runners, -// where `useblacksmith/cache` is the documented drop-in for `actions/cache`, -// and the absorbed Cargo workspace at `languages/typescript/packages/protect-ffi` is exactly where +// `useblacksmith/cache@v5` and `Swatinem/rust-cache@v2`: `OK`, exit 0. Both +// kinds are live-relevant here. The self-hosted jobs in this repo run on +// RunsOn, whose `runs-on/cache` is a drop-in for `actions/cache`, as +// `useblacksmith/cache` is on Blacksmith. And the absorbed Cargo workspace at `languages/typescript/packages/protect-ffi` is exactly where // someone reaches for `Swatinem/rust-cache`. // // The obvious repair is to enumerate the cache actions — by name From a2c70da4137adbf81cb6912ba41e2bdf00095867 Mon Sep 17 00:00:00 2001 From: Lindsay Holmwood Date: Thu, 26 Nov 2026 16:51:16 +1100 Subject: [PATCH 22/23] ci(runners): log out of Docker Hub after the last pull `docker login` stores the Docker Hub password in the Docker config file, base64-encoded. It stayed there until the job ended. So code in every later step could read it, including test suites and the packages that installs pull in. Each of the 17 RunsOn jobs that logs in now logs out right after its last step that may pull an image. The logout step uses `if: always()`, so it also runs after a failed step. `docker logout` exits 0 when no login happened, as on a run without the secrets. The Docker Hub login guard now checks the order. A job that logs in must have a logout with always() after its last pull, and no logout before a pull. The guard's list of pulls it cannot see now allows more than one step per job. It adds the credentialed migration harness step in tests.yml. With HARNESS_LIVE=1, the harness runs postgres:17-alpine and node:22-bookworm-slim with `docker run`. The logout in that job comes after it. --- .github/workflows/_build-ffi-artifacts.yml | 7 ++ .github/workflows/bench-eql.yml | 7 ++ .github/workflows/integration-drizzle.yml | 7 ++ .github/workflows/integration-prisma-next.yml | 7 ++ .github/workflows/integration-protect-ffi.yml | 7 ++ .github/workflows/integration-supabase.yml | 7 ++ .../workflows/prisma-example-readme-e2e.yml | 7 ++ .github/workflows/prisma-next-e2e.yml | 7 ++ .../workflows/release-postgres-eql-image.yml | 14 +++ .github/workflows/test-eql.yml | 37 ++++++ .github/workflows/tests-bench.yml | 7 ++ .github/workflows/tests.yml | 7 ++ .../workflow-docker-hub-login.test.mjs | 119 ++++++++++++++---- 13 files changed, 217 insertions(+), 23 deletions(-) diff --git a/.github/workflows/_build-ffi-artifacts.yml b/.github/workflows/_build-ffi-artifacts.yml index 805ca4b58d..7ad7813853 100644 --- a/.github/workflows/_build-ffi-artifacts.yml +++ b/.github/workflows/_build-ffi-artifacts.yml @@ -302,6 +302,13 @@ jobs: node -e "require(process.argv[1])" "$PWD/platforms/$PLATFORM/index.node" ' + # The login stored the Docker Hub password in the Docker config file, + # where any later step could read it. No later step pulls an image. + # scripts/__tests__/workflow-docker-hub-login.test.mjs checks the order. + - name: Log out of Docker Hub + if: ${{ always() && startsWith(matrix.cfg.os, 'runs-on=') }} + run: docker logout + - name: Place the binding in its platform package if: ${{ matrix.cfg.platform != 'linux-x64-musl' }} working-directory: languages/typescript/packages/protect-ffi diff --git a/.github/workflows/bench-eql.yml b/.github/workflows/bench-eql.yml index f78d9ba6e4..19a675899f 100644 --- a/.github/workflows/bench-eql.yml +++ b/.github/workflows/bench-eql.yml @@ -167,6 +167,13 @@ jobs: run: | mise run postgres:up "postgres-${POSTGRES_VERSION}" --extra-args "--detach --wait" + # The login stored the Docker Hub password in the Docker config file, + # where any later step could read it. No later step pulls an image. + # scripts/__tests__/workflow-docker-hub-login.test.mjs checks the order. + - name: Log out of Docker Hub + if: always() + run: docker logout + - name: Run bench tests # CS_* scoped to THIS step only (least privilege): test:bench -> test:sqlx:prep # -> fixture:generate:all encrypts via cipherstash-client and needs BOTH a diff --git a/.github/workflows/integration-drizzle.yml b/.github/workflows/integration-drizzle.yml index 7ca4f75b36..32a268a460 100644 --- a/.github/workflows/integration-drizzle.yml +++ b/.github/workflows/integration-drizzle.yml @@ -329,6 +329,13 @@ jobs: with: db: ${{ matrix.db }} + # The login stored the Docker Hub password in the Docker config file, + # where any later step could read it. No later step pulls an image. + # scripts/__tests__/workflow-docker-hub-login.test.mjs checks the order. + - name: Log out of Docker Hub + if: always() + run: docker logout + # `globalSetup` installs EQL v3 by shelling out to the real # `stash eql install --eql-version 3`, so an installer regression fails # here rather than hiding behind a test-only SQL apply. diff --git a/.github/workflows/integration-prisma-next.yml b/.github/workflows/integration-prisma-next.yml index 85d4ae3420..22d4017a38 100644 --- a/.github/workflows/integration-prisma-next.yml +++ b/.github/workflows/integration-prisma-next.yml @@ -201,6 +201,13 @@ jobs: with: db: ${{ matrix.db }} + # The login stored the Docker Hub password in the Docker config file, + # where any later step could read it. No later step pulls an image. + # scripts/__tests__/workflow-docker-hub-login.test.mjs checks the order. + - name: Log out of Docker Hub + if: always() + run: docker logout + # `globalSetup` installs EQL v3 by shelling out to the real # `stash eql install --eql-version 3`, so an installer regression fails # here rather than hiding behind a test-only SQL apply. diff --git a/.github/workflows/integration-protect-ffi.yml b/.github/workflows/integration-protect-ffi.yml index aced4eeab0..70ed1cbbb3 100644 --- a/.github/workflows/integration-protect-ffi.yml +++ b/.github/workflows/integration-protect-ffi.yml @@ -383,6 +383,13 @@ jobs: working-directory: languages/typescript/packages/protect-ffi run: mise run setup + # The login stored the Docker Hub password in the Docker config file, + # where any later step could read it. No later step pulls an image. + # scripts/__tests__/workflow-docker-hub-login.test.mjs checks the order. + - name: Log out of Docker Hub + if: always() + run: docker logout + # vitest directly rather than `mise run test:integration:all`, because # that task's first two steps are the debug cargo build and a wasm-pack # rebuild that `build-ffi-binding` has already done (above). What it runs diff --git a/.github/workflows/integration-supabase.yml b/.github/workflows/integration-supabase.yml index ca257509d6..067a8c749d 100644 --- a/.github/workflows/integration-supabase.yml +++ b/.github/workflows/integration-supabase.yml @@ -280,6 +280,13 @@ jobs: with: db: ${{ matrix.db }} + # The login stored the Docker Hub password in the Docker config file, + # where any later step could read it. No later step pulls an image. + # scripts/__tests__/workflow-docker-hub-login.test.mjs checks the order. + - name: Log out of Docker Hub + if: always() + run: docker logout + # `globalSetup` installs EQL v3 by shelling out to the real # `stash eql install --eql-version 3 --supabase --direct`, so an installer # regression fails here rather than hiding behind a test-only SQL apply. diff --git a/.github/workflows/prisma-example-readme-e2e.yml b/.github/workflows/prisma-example-readme-e2e.yml index d13fea4d25..12f6d103e9 100644 --- a/.github/workflows/prisma-example-readme-e2e.yml +++ b/.github/workflows/prisma-example-readme-e2e.yml @@ -179,6 +179,13 @@ jobs: - name: Run README walkthrough e2e run: pnpm exec turbo run test:e2e --filter @cipherstash/e2e -- --run tests/prisma-example-readme.e2e.test.ts + # The login stored the Docker Hub password in the Docker config file, + # where any later step could read it. No later step pulls an image. + # scripts/__tests__/workflow-docker-hub-login.test.mjs checks the order. + - name: Log out of Docker Hub + if: always() + run: docker logout + - name: Tear down bundled Postgres (best-effort) if: always() working-directory: languages/typescript/examples/prisma diff --git a/.github/workflows/prisma-next-e2e.yml b/.github/workflows/prisma-next-e2e.yml index bdf78807ad..ea5e0f36bb 100644 --- a/.github/workflows/prisma-next-e2e.yml +++ b/.github/workflows/prisma-next-e2e.yml @@ -213,6 +213,13 @@ jobs: sleep 1 done + # The login stored the Docker Hub password in the Docker config file, + # where any later step could read it. No later step pulls an image. + # scripts/__tests__/workflow-docker-hub-login.test.mjs checks the order. + - name: Log out of Docker Hub + if: always() + run: docker logout + - name: Run E2E suite run: pnpm exec turbo run test:e2e --filter @cipherstash/prisma-example --env-mode=loose diff --git a/.github/workflows/release-postgres-eql-image.yml b/.github/workflows/release-postgres-eql-image.yml index 735c621fec..7a106ca715 100644 --- a/.github/workflows/release-postgres-eql-image.yml +++ b/.github/workflows/release-postgres-eql-image.yml @@ -201,6 +201,13 @@ jobs: EQL_VERSION=${{ env.EQL_VERSION }} tags: ${{ steps.tags.outputs.tags }} + # The login stored the Docker Hub password in the Docker config file, + # where any later step could read it. No later step pulls an image. + # scripts/__tests__/workflow-docker-hub-login.test.mjs checks the order. + - name: Log out of Docker Hub + if: always() + run: docker logout + promote-latest: name: Promote PG17 image to :latest and : # No eql-armed condition: both its `needs` carry one, and a skipped `needs` @@ -238,6 +245,13 @@ jobs: with: cache-binary: false + # The login stored the Docker Hub password in the Docker config file, + # where any later step could read it. No later step pulls an image. + # scripts/__tests__/workflow-docker-hub-login.test.mjs checks the order. + - name: Log out of Docker Hub + if: always() + run: docker logout + - name: Login to GHCR uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3 with: diff --git a/.github/workflows/test-eql.yml b/.github/workflows/test-eql.yml index 1057b60e78..9facafed04 100644 --- a/.github/workflows/test-eql.yml +++ b/.github/workflows/test-eql.yml @@ -385,6 +385,13 @@ jobs: run: | mise run postgres:up "postgres-${POSTGRES_VERSION}" --extra-args "--detach --wait" + # The login stored the Docker Hub password in the Docker config file, + # where any later step could read it. No later step pulls an image. + # scripts/__tests__/workflow-docker-hub-login.test.mjs checks the order. + - name: Log out of Docker Hub + if: always() + run: docker logout + - name: Build EQL + archive test binaries run: | mise run test:sqlx:archive @@ -485,6 +492,13 @@ jobs: run: | mise run postgres:up "postgres-${POSTGRES_VERSION}" --extra-args "--detach --wait" + # The login stored the Docker Hub password in the Docker config file, + # where any later step could read it. No later step pulls an image. + # scripts/__tests__/workflow-docker-hub-login.test.mjs checks the order. + - name: Log out of Docker Hub + if: always() + run: docker logout + - name: Run shard ${{ matrix.shard }}/${{ needs.setup.outputs.shard-total }} run: | mise run test:sqlx:partition @@ -549,6 +563,13 @@ jobs: run: | mise run postgres:up "postgres-${POSTGRES_VERSION}" --extra-args "--detach --wait" + # The login stored the Docker Hub password in the Docker config file, + # where any later step could read it. No later step pulls an image. + # scripts/__tests__/workflow-docker-hub-login.test.mjs checks the order. + - name: Log out of Docker Hub + if: always() + run: docker logout + # Source-only doc checks (coverage + required-tags) moved to the dedicated # `docs-static` job so they run exactly once, not per-Postgres. This step # keeps only the DB-backed SQL-syntax validation, which genuinely needs the @@ -914,6 +935,14 @@ jobs: - name: Setup database run: | mise run postgres:up "postgres-${POSTGRES_VERSION}" --extra-args "--detach --wait" + + # The login stored the Docker Hub password in the Docker config file, + # where any later step could read it. No later step pulls an image. + # scripts/__tests__/workflow-docker-hub-login.test.mjs checks the order. + - name: Log out of Docker Hub + if: always() + run: docker logout + - name: Build and install EQL run: | set -euo pipefail @@ -1106,6 +1135,14 @@ jobs: - name: Setup database (Postgres 17) run: | mise run postgres:up "postgres-${POSTGRES_VERSION}" --extra-args "--detach --wait" + + # The login stored the Docker Hub password in the Docker config file, + # where any later step could read it. No later step pulls an image. + # scripts/__tests__/workflow-docker-hub-login.test.mjs checks the order. + - name: Log out of Docker Hub + if: always() + run: docker logout + - name: Run e2e property suite run: | mise run test:sqlx:e2e diff --git a/.github/workflows/tests-bench.yml b/.github/workflows/tests-bench.yml index 16233967a1..f470d05375 100644 --- a/.github/workflows/tests-bench.yml +++ b/.github/workflows/tests-bench.yml @@ -118,6 +118,13 @@ jobs: working-directory: local run: docker compose up --wait --wait-timeout 60 postgres + # The login stored the Docker Hub password in the Docker config file, + # where any later step could read it. No later step pulls an image. + # scripts/__tests__/workflow-docker-hub-login.test.mjs checks the order. + - name: Log out of Docker Hub + if: always() + run: docker logout + # `pnpm test:local` resolves to `vitest run`; the trailing `db-only` # is a vitest path filter that narrows to __tests__/db-only.test.ts # (credential-free smoke). Note: pnpm 10 forwards script args without diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3abfe79c34..2cc2521206 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -565,6 +565,13 @@ jobs: port="$(docker port pg18-upgrade 5432/tcp | head -n1 | sed 's/.*://')" echo "database-url=postgres://postgres:password@127.0.0.1:${port}/postgres" >> "$GITHUB_OUTPUT" + # The login stored the Docker Hub password in the Docker config file, + # where any later step could read it. No later step pulls an image. + # scripts/__tests__/workflow-docker-hub-login.test.mjs checks the order. + - name: Log out of Docker Hub + if: always() + run: docker logout + - name: Run the Postgres upgrade example on PostgreSQL 18 if: ${{ !cancelled() && steps.db18.outcome == 'success' }} run: pnpm exec turbo run test:protect-crossover --filter @cipherstash/e2e --env-mode=loose -- tests/protect-postgres-upgrade.e2e.test.ts diff --git a/scripts/__tests__/workflow-docker-hub-login.test.mjs b/scripts/__tests__/workflow-docker-hub-login.test.mjs index 4215b96fa9..bbe976c63e 100644 --- a/scripts/__tests__/workflow-docker-hub-login.test.mjs +++ b/scripts/__tests__/workflow-docker-hub-login.test.mjs @@ -204,17 +204,29 @@ const PULLING_TASKS = pullingTasks(taskIndex()) // Pulls this file cannot find, because test code or a README the test runs // starts the container. Each named step counts as a pull. export const HIDDEN_PULLS = { - '.github/workflows/prisma-example-readme-e2e.yml#walkthrough': { - step: 'Run README walkthrough e2e', - reason: - "e2e/tests/prisma-example-readme.e2e.test.ts runs the Prisma example's README, whose `docker compose up -d` pulls postgres:16.", - }, - '.github/workflows/tests.yml#e2e-tests': { - step: 'Run E2E tests', - reason: 'e2e/vitest.config.ts includes the same README walkthrough test.', - }, + '.github/workflows/prisma-example-readme-e2e.yml#walkthrough': [ + { + step: 'Run README walkthrough e2e', + reason: + "e2e/tests/prisma-example-readme.e2e.test.ts runs the Prisma example's README, whose `docker compose up -d` pulls postgres:16.", + }, + ], + '.github/workflows/tests.yml#e2e-tests': [ + { + step: 'Run E2E tests', + reason: 'e2e/vitest.config.ts includes the same README walkthrough test.', + }, + { + step: 'Run the credentialed Migration Harness self-test', + reason: + 'With HARNESS_LIVE=1, e2e/migration-harness runs postgres:17-alpine and node:22-bookworm-slim, and builds an image from node:22-bookworm-slim.', + }, + ], } +const isHiddenPull = (ref, step) => + (HIDDEN_PULLS[ref] ?? []).some((hidden) => hidden.step === step?.name) + // --------------------------------------------------------------------------- // Steps and jobs // --------------------------------------------------------------------------- @@ -253,6 +265,19 @@ export function loginFinding(step) { return null } +/** + * Whether a step logs out of Docker Hub even when an earlier step failed. The + * login stores the password in the Docker config file, where every later + * step's code can read it. + */ +export function logoutFinding(step) { + const run = typeof step?.run === 'string' ? step.run : '' + if (!/\bdocker\s+logout\b/.test(run)) return 'not a logout' + if (!/\balways\(\)/.test(String(step.if ?? ''))) + return 'logs out of Docker Hub only when every earlier step passed; add always() to its if' + return null +} + /** Whether a container's `credentials` log in, and still work without the secrets. */ export function credentialsFinding(credentials) { if (credentials === undefined) return 'sets no credentials' @@ -290,20 +315,34 @@ export function jobFindings(where, job, ref) { ) } const steps = job.steps ?? [] - const hidden = HIDDEN_PULLS[ref]?.step - const firstPull = steps.findIndex( - (step) => stepPulls(step) || (hidden && step?.name === hidden), - ) + const pulls = (step) => stepPulls(step) || isHiddenPull(ref, step) + const firstPull = steps.findIndex(pulls) if (firstPull === -1) return findings const logins = steps .map((step, i) => ({ i, finding: loginFinding(step) })) .filter(({ finding }) => finding !== 'not a login') for (const { i, finding } of logins) if (finding) findings.push(`${where}: step ${i + 1} ${finding}`) - const pullName = steps[firstPull].name ?? steps[firstPull].uses ?? 'run' + const nameOf = (i) => steps[i].name ?? steps[i].uses ?? 'run' if (!logins.some(({ i }) => i < firstPull)) findings.push( - `${where}: step ${firstPull + 1} (${pullName}) may pull an image, and no Docker Hub login comes before it`, + `${where}: step ${firstPull + 1} (${nameOf(firstPull)}) may pull an image, and no Docker Hub login comes before it`, + ) + if (logins.length === 0) return findings + const lastPull = steps.findLastIndex(pulls) + const logouts = steps + .map((step, i) => ({ i, finding: logoutFinding(step) })) + .filter(({ finding }) => finding !== 'not a logout') + for (const { i, finding } of logouts) { + if (finding) findings.push(`${where}: step ${i + 1} ${finding}`) + if (i < lastPull) + findings.push( + `${where}: step ${i + 1} logs out of Docker Hub before step ${lastPull + 1} (${nameOf(lastPull)}), which may pull an image`, + ) + } + if (!logouts.some(({ i, finding }) => i > lastPull && finding === null)) + findings.push( + `${where}: no Docker Hub logout with if: always() comes after step ${lastPull + 1} (${nameOf(lastPull)}), the last step that may pull an image`, ) return findings } @@ -383,12 +422,14 @@ describe('Docker Hub login on RunsOn', () => { it('names a RunsOn job and a real step for every hidden pull', () => { // A stale entry would stop guarding the pull it was written for. - const stale = Object.entries(HIDDEN_PULLS) - .filter(([ref, { step }]) => { - const entry = jobs.find((j) => j.ref === ref) - return !(entry?.job.steps ?? []).some((s) => s?.name === step) - }) - .map(([ref]) => ref) + const stale = Object.entries(HIDDEN_PULLS).flatMap(([ref, hidden]) => { + const entry = jobs.find((j) => j.ref === ref) + return hidden + .filter( + ({ step }) => !(entry?.job.steps ?? []).some((s) => s?.name === step), + ) + .map(({ step }) => `${ref} ${step}`) + }) expect(stale).toEqual([]) }) @@ -407,16 +448,21 @@ describe('Docker Hub login on RunsOn', () => { ].join('\n'), } const up = { name: 'Start Postgres', run: 'mise run postgres:up' } + const logout = { + name: 'Log out of Docker Hub', + if: 'always()', + run: 'docker logout', + } it('reports a pull with no login before it', () => { expect(jobFindings('w j', { 'runs-on': runsOn, steps: [up] })).toEqual([ expect.stringMatching(/no Docker Hub login comes before it/), ]) expect( - jobFindings('w j', { 'runs-on': runsOn, steps: [up, login] }), + jobFindings('w j', { 'runs-on': runsOn, steps: [up, login, logout] }), ).toEqual([expect.stringMatching(/no Docker Hub login comes before it/)]) expect( - jobFindings('w j', { 'runs-on': runsOn, steps: [login, up] }), + jobFindings('w j', { 'runs-on': runsOn, steps: [login, up, logout] }), ).toEqual([]) // Not RunsOn: out of scope. expect( @@ -433,6 +479,33 @@ describe('Docker Hub login on RunsOn', () => { ).toEqual([expect.stringMatching(/no Docker Hub login comes before it/)]) }) + it('reports a login with no logout after the last pull', () => { + const job = (...steps) => ({ 'runs-on': runsOn, steps }) + expect(jobFindings('w j', job(login, up))).toEqual([ + expect.stringMatching( + /no Docker Hub logout with if: always\(\) comes after step 2 \(Start Postgres\)/, + ), + ]) + expect( + jobFindings('w j', job(login, up, { ...logout, if: undefined })), + ).toEqual([ + expect.stringMatching(/step 3 logs out .* add always\(\) to its if/), + expect.stringMatching(/no Docker Hub logout with if: always\(\)/), + ]) + expect(jobFindings('w j', job(login, up, logout, up))).toEqual([ + expect.stringMatching(/step 3 logs out of Docker Hub before step 4/), + expect.stringMatching(/no Docker Hub logout .* after step 4/), + ]) + // A matrix leg's own condition may sit beside always(). + expect( + logoutFinding({ + ...logout, + // biome-ignore lint/suspicious/noTemplateCurlyInString: a GitHub Actions expression under test. + if: "${{ always() && startsWith(matrix.cfg.os, 'runs-on=') }}", + }), + ).toBeNull() + }) + it('reports a call that does not pass both secrets', () => { const uses = './.github/workflows/x.yml' expect(callerFinding({ uses })).toMatch(/DOCKER_HUB_USERNAME/) From 30978e000f1cdea906dd28faf69f86b16cbb940e Mon Sep 17 00:00:00 2001 From: Lindsay Holmwood Date: Thu, 26 Nov 2026 17:52:51 +1100 Subject: [PATCH 23/23] docs(skills): name the two Docker Hub secrets the FFI pre-flight passes The stash-supply-chain-security skill said that ffi-preflight.yml passes no secrets to the build workflow. The header comment of ffi-preflight.yml said the same. Since this pull request, the workflow passes exactly two secrets, by name: DOCKER_HUB_USERNAME and DOCKER_HUB_PASSWORD. The musl build logs in to Docker Hub with them before it pulls Alpine. Both texts now name those two secrets. Neither secret can authenticate an npm publish, so the dry run still cannot publish. The other safeguards are unchanged: no id-token permission, no `secrets: inherit`, no registry-url, and no npm token. The skill ships in the stash package, so a stash patch changeset comes with this change. The skill's paragraph also has shorter sentences now. --- .../supply-chain-skill-preflight-secrets.md | 5 +++++ .github/workflows/ffi-preflight.yml | 12 +++++++---- skills/stash-supply-chain-security/SKILL.md | 21 +++++++++++-------- 3 files changed, 25 insertions(+), 13 deletions(-) create mode 100644 .changeset/supply-chain-skill-preflight-secrets.md diff --git a/.changeset/supply-chain-skill-preflight-secrets.md b/.changeset/supply-chain-skill-preflight-secrets.md new file mode 100644 index 0000000000..0f1154196c --- /dev/null +++ b/.changeset/supply-chain-skill-preflight-secrets.md @@ -0,0 +1,5 @@ +--- +"stash": patch +--- + +The `stash-supply-chain-security` skill now describes the secrets of the FFI release pre-flight workflow correctly. It said that the workflow passes no secrets to its build. The workflow now passes exactly two, by name: `DOCKER_HUB_USERNAME` and `DOCKER_HUB_PASSWORD`. The musl build uses them to log in to Docker Hub before it pulls Alpine. They cannot authenticate an npm publish, so the workflow still cannot publish. diff --git a/.github/workflows/ffi-preflight.yml b/.github/workflows/ffi-preflight.yml index 5aaabc063f..96986d3486 100644 --- a/.github/workflows/ffi-preflight.yml +++ b/.github/workflows/ffi-preflight.yml @@ -9,10 +9,14 @@ name: FFI release pre-flight # It never publishes, and cannot — both authentication paths are absent, which # takes more than the one line it looks like. No `id-token` permission closes # OIDC; a plain `NPM_TOKEN` would authenticate a publish regardless, so there is -# also no secret passed (no `secrets: inherit` on the call below), no -# `registry-url` on setup-node (that is what writes an `_authToken` line into -# .npmrc), and no NPM_TOKEN or NODE_AUTH_TOKEN anywhere. Adding any one of them -# turns this dry run into a publisher. +# also no `secrets: inherit` on the call below, no `registry-url` on setup-node +# (that is what writes an `_authToken` line into .npmrc), and no NPM_TOKEN or +# NODE_AUTH_TOKEN anywhere. Adding any one of them turns this dry run into a +# publisher. +# +# The call below passes exactly two secrets, by name: DOCKER_HUB_USERNAME and +# DOCKER_HUB_PASSWORD. The musl build logs in to Docker Hub with them before it +# pulls Alpine. They cannot authenticate an npm publish. on: workflow_dispatch: diff --git a/skills/stash-supply-chain-security/SKILL.md b/skills/stash-supply-chain-security/SKILL.md index a5f63d371b..c7060aa63e 100644 --- a/skills/stash-supply-chain-security/SKILL.md +++ b/skills/stash-supply-chain-security/SKILL.md @@ -209,15 +209,18 @@ npm ≥ 11.5.1, no Actions cache. `optionalDependencies` are exact versions, so publishing it first exposes a version whose binaries do not exist yet. - `ffi-preflight.yml` is the dry run — `changeset publish` has no `--dry-run`. - Dispatch it against a Version Packages branch and it builds the real tarballs, - checks each binary's architecture and libc, installs the host pair and loads - it. It cannot publish, and "no `id-token`" is only half of why: that closes - the OIDC path, while a plain `NPM_TOKEN` would still authenticate one. Both - are absent — the workflow grants `contents: read`, passes no secrets (no - `secrets: inherit` on its call into the build workflow), sets no - `registry-url` (which is what writes an `_authToken` line into `.npmrc`), and - names no `NPM_TOKEN` or `NODE_AUTH_TOKEN`. Keep it that way; adding any one of - them turns a dry run into a publisher. + Dispatched against a Version Packages branch, it builds the real tarballs, + checks each binary's architecture and libc, then installs and loads the host + pair. It cannot publish. "No `id-token`" is only half of why. It closes the + OIDC path, but a plain `NPM_TOKEN` would still authenticate a publish. Both + paths are absent. The workflow grants only `contents: read`, and names no + `NPM_TOKEN` or `NODE_AUTH_TOKEN`. It sets no `registry-url`. That setting is + what writes an `_authToken` line into `.npmrc`. Its call into the build workflow passes + exactly two secrets, by name: `DOCKER_HUB_USERNAME` and + `DOCKER_HUB_PASSWORD`. The musl build logs in to Docker Hub with them before + it pulls Alpine. They cannot authenticate an npm publish. Keep it that way: + an `id-token` permission, `secrets: inherit`, a `registry-url`, or an npm + token would each turn the dry run into a publisher. Trusted publishing is configured **per package** on npmjs.com (package settings → Trusted publisher → GitHub Actions): owner/repo `cipherstash/stack`, workflow