From e920f064401250fc6309ff5bd28367d9018b6ee2 Mon Sep 17 00:00:00 2001 From: George Oastler Date: Fri, 6 Nov 2026 21:47:42 +0000 Subject: [PATCH] Accept pick-runner JSON as runs-on in shared workflows --- .github/workflows/auto-update-pr.yml | 3 ++- .github/workflows/cancel-runs-on-pr-close.yml | 4 +++- .github/workflows/ci.yml | 2 ++ .github/workflows/pr-housekeeping.yml | 4 ++-- .github/workflows/security.yml | 8 ++++---- .github/workflows/static.yml | 14 +++++++------- .github/workflows/test.yml | 14 +++++++------- README.md | 2 ++ 8 files changed, 29 insertions(+), 22 deletions(-) diff --git a/.github/workflows/auto-update-pr.yml b/.github/workflows/auto-update-pr.yml index cac3e22..3970c32 100644 --- a/.github/workflows/auto-update-pr.yml +++ b/.github/workflows/auto-update-pr.yml @@ -23,6 +23,7 @@ name: auto-update-pr on: workflow_call: inputs: + runs-on: {description: "Runner: a label, or a JSON array of labels (pick-runner output).", type: string, default: "ubuntu-latest"} actions-ref: description: "Commit of prosopo/github_actions holding the script; pass the SHA this workflow is pinned at (see cache-main.yml)." type: string @@ -47,7 +48,7 @@ permissions: jobs: update: - runs-on: ubuntu-latest + runs-on: ${{ fromJSON(startsWith(inputs.runs-on, '[') && inputs.runs-on || toJSON(inputs.runs-on)) }} timeout-minutes: 15 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 diff --git a/.github/workflows/cancel-runs-on-pr-close.yml b/.github/workflows/cancel-runs-on-pr-close.yml index d021772..f11a2e3 100644 --- a/.github/workflows/cancel-runs-on-pr-close.yml +++ b/.github/workflows/cancel-runs-on-pr-close.yml @@ -24,6 +24,8 @@ name: cancel-runs-on-pr-close on: workflow_call: + inputs: + runs-on: {description: "Runner: a label, or a JSON array of labels (pick-runner output).", type: string, default: "ubuntu-latest"} permissions: contents: read @@ -33,7 +35,7 @@ jobs: permissions: actions: write contents: read - runs-on: ubuntu-latest + runs-on: ${{ fromJSON(startsWith(inputs.runs-on, '[') && inputs.runs-on || toJSON(inputs.runs-on)) }} timeout-minutes: 10 env: GH_TOKEN: ${{ github.token }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2447637..7c09aa4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,6 +62,8 @@ jobs: uses: ./.github/workflows/static.yml with: actions-ref: ${{ github.event.pull_request.head.sha || github.sha }} + # JSON form, as pick-runner outputs it; the fixture calls below use a plain label. + runs-on: '["ubuntu-latest"]' # The JS here is only stage fixtures; the js job is where the # repo-wide linters run, since every change under .github/ selects it. js-command: pnpm run setup:lint-tools && PATH="$HOME/.local/bin:$PATH" pnpm run lint diff --git a/.github/workflows/pr-housekeeping.yml b/.github/workflows/pr-housekeeping.yml index 83cb1ca..537307e 100644 --- a/.github/workflows/pr-housekeeping.yml +++ b/.github/workflows/pr-housekeeping.yml @@ -10,7 +10,7 @@ on: description: "Commit of prosopo/github_actions whose actions this uses; pass the SHA the caller pins this workflow at (see cache-main.yml)." type: string required: true - runs-on: {description: "Runner label.", type: string, default: "ubuntu-latest"} + runs-on: {description: "Runner: a label, or a JSON array of labels (pick-runner output).", type: string, default: "ubuntu-latest"} permissions: contents: read @@ -18,7 +18,7 @@ permissions: jobs: housekeeping: if: ${{ github.event_name != 'pull_request' || (github.event.pull_request.head.repo.full_name == github.repository && !github.event.pull_request.draft) }} - runs-on: ${{ inputs.runs-on }} + runs-on: ${{ fromJSON(startsWith(inputs.runs-on, '[') && inputs.runs-on || toJSON(inputs.runs-on)) }} timeout-minutes: 5 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml index fd8afcf..fc1fe66 100644 --- a/.github/workflows/security.yml +++ b/.github/workflows/security.yml @@ -15,7 +15,7 @@ on: description: "Commit of prosopo/github_actions whose actions this uses; pass the SHA the caller pins this workflow at (see cache-main.yml)." type: string required: true - runs-on: {description: "Runner label.", type: string, default: "ubuntu-latest"} + runs-on: {description: "Runner: a label, or a JSON array of labels (pick-runner output).", type: string, default: "ubuntu-latest"} dependency-review-severity: description: "Lowest severity (low, moderate, high, critical) of a newly added vulnerable dependency that fails the PR." type: string @@ -31,7 +31,7 @@ permissions: jobs: scan: if: ${{ github.event_name != 'pull_request' || (github.event.pull_request.head.repo.full_name == github.repository && !github.event.pull_request.draft) }} - runs-on: ${{ inputs.runs-on }} + runs-on: ${{ fromJSON(startsWith(inputs.runs-on, '[') && inputs.runs-on || toJSON(inputs.runs-on)) }} timeout-minutes: 20 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -72,7 +72,7 @@ jobs: semgrep: if: ${{ github.event_name != 'pull_request' || (github.event.pull_request.head.repo.full_name == github.repository && !github.event.pull_request.draft) }} - runs-on: ${{ inputs.runs-on }} + runs-on: ${{ fromJSON(startsWith(inputs.runs-on, '[') && inputs.runs-on || toJSON(inputs.runs-on)) }} timeout-minutes: 30 container: image: semgrep/semgrep:1.145.0 @@ -116,7 +116,7 @@ jobs: # head lockfiles with osv-scanner and diff (scripts/dependency_diff.py). dependency-review: if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository }} - runs-on: ${{ inputs.runs-on }} + runs-on: ${{ fromJSON(startsWith(inputs.runs-on, '[') && inputs.runs-on || toJSON(inputs.runs-on)) }} timeout-minutes: 15 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index 9fb91c8..dbb0fb9 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -15,7 +15,7 @@ on: type: string required: true runs-on: - description: "Runner label for every job." + description: "Runner for every job: a label, or a JSON array of labels (pick-runner output)." type: string default: "ubuntu-latest" timeout-minutes: @@ -65,7 +65,7 @@ permissions: jobs: changes: if: ${{ github.event_name != 'pull_request' || (github.event.pull_request.head.repo.full_name == github.repository && !github.event.pull_request.draft) }} - runs-on: ${{ inputs.runs-on }} + runs-on: ${{ fromJSON(startsWith(inputs.runs-on, '[') && inputs.runs-on || toJSON(inputs.runs-on)) }} timeout-minutes: 5 outputs: js: ${{ steps.detect.outputs.js-changed }} @@ -97,7 +97,7 @@ jobs: js: needs: changes if: ${{ needs.changes.outputs.js == 'true' }} - runs-on: ${{ inputs.runs-on }} + runs-on: ${{ fromJSON(startsWith(inputs.runs-on, '[') && inputs.runs-on || toJSON(inputs.runs-on)) }} timeout-minutes: ${{ inputs.timeout-minutes }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -156,7 +156,7 @@ jobs: rust: needs: changes if: ${{ needs.changes.outputs.rust == 'true' }} - runs-on: ${{ inputs.runs-on }} + runs-on: ${{ fromJSON(startsWith(inputs.runs-on, '[') && inputs.runs-on || toJSON(inputs.runs-on)) }} timeout-minutes: ${{ inputs.timeout-minutes }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -197,7 +197,7 @@ jobs: python: needs: changes if: ${{ needs.changes.outputs.python == 'true' }} - runs-on: ${{ inputs.runs-on }} + runs-on: ${{ fromJSON(startsWith(inputs.runs-on, '[') && inputs.runs-on || toJSON(inputs.runs-on)) }} timeout-minutes: ${{ inputs.timeout-minutes }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -238,7 +238,7 @@ jobs: go: needs: changes if: ${{ needs.changes.outputs.go == 'true' }} - runs-on: ${{ inputs.runs-on }} + runs-on: ${{ fromJSON(startsWith(inputs.runs-on, '[') && inputs.runs-on || toJSON(inputs.runs-on)) }} timeout-minutes: ${{ inputs.timeout-minutes }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -276,7 +276,7 @@ jobs: php: needs: changes if: ${{ needs.changes.outputs.php == 'true' }} - runs-on: ${{ inputs.runs-on }} + runs-on: ${{ fromJSON(startsWith(inputs.runs-on, '[') && inputs.runs-on || toJSON(inputs.runs-on)) }} timeout-minutes: ${{ inputs.timeout-minutes }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2ff6093..5764b49 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,7 +15,7 @@ on: type: string required: true runs-on: - description: "Runner label for every job." + description: "Runner for every job: a label, or a JSON array of labels (pick-runner output)." type: string default: "ubuntu-latest" timeout-minutes: @@ -65,7 +65,7 @@ permissions: jobs: changes: if: ${{ github.event_name != 'pull_request' || (github.event.pull_request.head.repo.full_name == github.repository && !github.event.pull_request.draft) }} - runs-on: ${{ inputs.runs-on }} + runs-on: ${{ fromJSON(startsWith(inputs.runs-on, '[') && inputs.runs-on || toJSON(inputs.runs-on)) }} timeout-minutes: 5 outputs: js: ${{ steps.detect.outputs.js-changed }} @@ -97,7 +97,7 @@ jobs: js: needs: changes if: ${{ needs.changes.outputs.js == 'true' }} - runs-on: ${{ inputs.runs-on }} + runs-on: ${{ fromJSON(startsWith(inputs.runs-on, '[') && inputs.runs-on || toJSON(inputs.runs-on)) }} timeout-minutes: ${{ inputs.timeout-minutes }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -156,7 +156,7 @@ jobs: rust: needs: changes if: ${{ needs.changes.outputs.rust == 'true' }} - runs-on: ${{ inputs.runs-on }} + runs-on: ${{ fromJSON(startsWith(inputs.runs-on, '[') && inputs.runs-on || toJSON(inputs.runs-on)) }} timeout-minutes: ${{ inputs.timeout-minutes }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -197,7 +197,7 @@ jobs: python: needs: changes if: ${{ needs.changes.outputs.python == 'true' }} - runs-on: ${{ inputs.runs-on }} + runs-on: ${{ fromJSON(startsWith(inputs.runs-on, '[') && inputs.runs-on || toJSON(inputs.runs-on)) }} timeout-minutes: ${{ inputs.timeout-minutes }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -238,7 +238,7 @@ jobs: go: needs: changes if: ${{ needs.changes.outputs.go == 'true' }} - runs-on: ${{ inputs.runs-on }} + runs-on: ${{ fromJSON(startsWith(inputs.runs-on, '[') && inputs.runs-on || toJSON(inputs.runs-on)) }} timeout-minutes: ${{ inputs.timeout-minutes }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -276,7 +276,7 @@ jobs: php: needs: changes if: ${{ needs.changes.outputs.php == 'true' }} - runs-on: ${{ inputs.runs-on }} + runs-on: ${{ fromJSON(startsWith(inputs.runs-on, '[') && inputs.runs-on || toJSON(inputs.runs-on)) }} timeout-minutes: ${{ inputs.timeout-minutes }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 diff --git a/README.md b/README.md index b3f03dd..20c6efa 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,8 @@ Each takes `actions-ref`: pass the same SHA the `uses:` line pins, so the workfl runs-on: ${{ fromJSON(needs.runner.outputs.default) }} ``` + The shared stage workflows' `runs-on` input takes either a label or this JSON, so a caller passes `runs-on: ${{ needs.runner.outputs.default }}` straight through. + Two calls in one run need distinct `workflow` or `concurrency-key` inputs, or they queue behind each other. `ci.yml`'s `selftest-pick-runner` jobs call it as above and check the output shape. - `ci-coverage-audit.yml`: weekly (and on dispatch), the CI coverage matrix for every repo in `.github/scripts/ciaudit/repos.txt`: per unit (package, crate, Python project, Dockerfile, ...) whether CI builds, lints, typechecks, tests and e2e-tests it, from a static walk of each triggered workflow (reusable workflows, composite actions, package scripts, turbo tasks) cross-checked against its latest green run. HTML and JSON in the `ci-coverage` artifact, a text matrix in the step summary. A gap that is deliberate goes in `.github/scripts/ciaudit/optouts.json` with its reason. Run locally: `fetch.py --repos-file repos.txt --dest-prefix snap/` then `audit.py --snap-prefix snap/ --repos-file repos.txt --out-json r.json --out-html r.html`; `why.py` prints the evidence behind one unit. - `auto-update-pr.yml`: updates one random behind, mergeable, auto-merge PR at a time (`.github/scripts/auto_update_pr.py`).