diff --git a/.github/workflows/ci-cla-quota-rerun.yml b/.github/workflows/ci-cla-quota-rerun.yml index 95975cdf6835..f3b0743260ed 100644 --- a/.github/workflows/ci-cla-quota-rerun.yml +++ b/.github/workflows/ci-cla-quota-rerun.yml @@ -52,7 +52,7 @@ jobs: vars.GLAEDA_ROUTE_APP_ID != '' && (github.event_name != 'workflow_run' || (github.event.workflow_run.event == 'pull_request_target' && (github.event.workflow_run.conclusion == 'failure' || github.event.workflow_run.run_attempt > 1))) - runs-on: ${{ github.repository_owner != 'manaflow-ai' && 'ubuntu-24.04' || vars.LINUX_RUNNER || 'blacksmith-4vcpu-ubuntu-2404' }} + runs-on: ${{ github.repository_owner != 'manaflow-ai' && 'ubuntu-24.04' || 'blacksmith-4vcpu-ubuntu-2404' }} timeout-minutes: 47 # One pass at a time; a pass waiting for the reset is never cancelled. Passes # that arrive meanwhile collapse into one pending pass. Job level, so the many diff --git a/.github/workflows/ci-compile-attribution.yml b/.github/workflows/ci-compile-attribution.yml index ead58a78a145..9a016e272346 100644 --- a/.github/workflows/ci-compile-attribution.yml +++ b/.github/workflows/ci-compile-attribution.yml @@ -53,9 +53,10 @@ jobs: analyze: name: Analyze if: ${{ github.repository == 'manaflow-ai/cmux' && github.ref == 'refs/heads/main' && (github.event_name == 'workflow_dispatch' || github.event.workflow_run.head_branch == 'main' && contains(fromJSON('["push","workflow_dispatch"]'), github.event.workflow_run.event) && contains(fromJSON('[".github/workflows/seed-derived-data.yml",".github/workflows/main-compile-probe.yml"]'), github.event.workflow_run.path)) }} - # Analysis only reads trusted main history and the Actions/PR APIs. It - # needs no secret or write token, so use the shared Linux runner pool. - runs-on: ${{ github.repository_owner != 'manaflow-ai' && 'ubuntu-24.04' || vars.LINUX_RUNNER || 'blacksmith-4vcpu-ubuntu-2404' }} + # Analysis only reads trusted main history and the Actions/PR APIs, but it + # mints App tokens to read on their budget, so it runs on a literal + # Blacksmith label no variable can move (tests/test_ci_fork_runner_routing.py). + runs-on: ${{ github.repository_owner != 'manaflow-ai' && 'ubuntu-24.04' || 'blacksmith-4vcpu-ubuntu-2404' }} timeout-minutes: 15 permissions: actions: read diff --git a/.github/workflows/ci-guard-attribution.yml b/.github/workflows/ci-guard-attribution.yml index a8073b9a0edd..b4e264a19765 100644 --- a/.github/workflows/ci-guard-attribution.yml +++ b/.github/workflows/ci-guard-attribution.yml @@ -49,9 +49,10 @@ jobs: # ci.yml skips `fast-guards` for its pull requests (cmux-next has its own lanes), so its # analysis always ended "no completed verdict" after reading the run's jobs. Skipped here. if: ${{ github.repository == 'manaflow-ai/cmux' && contains(fromJSON('["success","failure","timed_out","startup_failure","action_required","cancelled"]'), github.event.workflow_run.conclusion) && (github.event.workflow_run.event == 'pull_request' || github.event.workflow_run.head_branch == 'main') && !(github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.path == '.github/workflows/ci.yml' && github.event.workflow_run.pull_requests[0].base.ref == 'feat-cmux-next') }} - # Analysis only reads trusted main history and the Actions/PR APIs. It - # needs no secret or write token, so use the shared Linux runner pool. - runs-on: ${{ github.repository_owner != 'manaflow-ai' && 'ubuntu-24.04' || vars.LINUX_RUNNER || 'blacksmith-4vcpu-ubuntu-2404' }} + # Analysis only reads trusted main history and the Actions/PR APIs, but it + # mints App tokens to read on their budget, so it runs on a literal + # Blacksmith label no variable can move (tests/test_ci_fork_runner_routing.py). + runs-on: ${{ github.repository_owner != 'manaflow-ai' && 'ubuntu-24.04' || 'blacksmith-4vcpu-ubuntu-2404' }} timeout-minutes: 20 permissions: actions: read diff --git a/.github/workflows/ci-hosted-queue-rescue.yml b/.github/workflows/ci-hosted-queue-rescue.yml index 142bdcedb4db..8b54e4c4ff1b 100644 --- a/.github/workflows/ci-hosted-queue-rescue.yml +++ b/.github/workflows/ci-hosted-queue-rescue.yml @@ -47,7 +47,7 @@ jobs: github.repository == 'manaflow-ai/cmux' && contains(fromJSON('["failure","cancelled"]'), github.event.workflow_run.conclusion) && contains(fromJSON('["pull_request","pull_request_target","issue_comment","merge_group"]'), github.event.workflow_run.event) - runs-on: ${{ github.repository_owner != 'manaflow-ai' && 'ubuntu-24.04' || vars.LINUX_RUNNER || 'blacksmith-4vcpu-ubuntu-2404' }} + runs-on: ${{ github.repository_owner != 'manaflow-ai' && 'ubuntu-24.04' || 'blacksmith-4vcpu-ubuntu-2404' }} timeout-minutes: 5 steps: - name: Mint the cmux-bot token diff --git a/.github/workflows/ci-macos.yml b/.github/workflows/ci-macos.yml index 24250041205b..47aab89ca9bd 100644 --- a/.github/workflows/ci-macos.yml +++ b/.github/workflows/ci-macos.yml @@ -224,7 +224,7 @@ jobs: # no gap to take the pinned runner first. Any failure outputs "" and # admission keeps pr_admission_runner on attempt 1, its label after. if: ${{ github.repository_owner == 'manaflow-ai' && (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'workflow_dispatch') && vars.CI_OWNED_SPREAD == '1' && vars.GLAEDA_ROUTE_APP_ID != '' && (startsWith(inputs.pr_root_runner, 'glaeda-root-') || startsWith(inputs.pr_root_runner, 'glaeda-aws-root-')) && contains(inputs.pr_owned_jobs, ' admission ') && (inputs.macos == 'true' || inputs.cli == 'true') && (inputs.compile_admitted != 'true' || inputs.full_suite == 'true' || inputs.cli == 'true') }} - runs-on: ${{ github.repository_owner != 'manaflow-ai' && 'ubuntu-24.04' || github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository && !contains(fromJSON(inputs.owned_head_repos), github.event.pull_request.head.repo.full_name) && 'blacksmith-4vcpu-ubuntu-2404' || vars.LINUX_RUNNER || 'blacksmith-4vcpu-ubuntu-2404' }} + runs-on: ${{ github.repository_owner != 'manaflow-ai' && 'ubuntu-24.04' || 'blacksmith-4vcpu-ubuntu-2404' }} timeout-minutes: 3 permissions: contents: read @@ -1742,7 +1742,7 @@ jobs: needs: - macos-compile-admission if: ${{ !cancelled() && needs.macos-compile-admission.result == 'success' && github.repository_owner == 'manaflow-ai' && github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && vars.CI_PR_POOL_OWNED == '1' && vars.GLAEDA_ROUTE_APP_ID != '' && (github.run_attempt <= 2 || github.triggering_actor != 'github-actions[bot]') }} - runs-on: ${{ github.repository_owner != 'manaflow-ai' && 'ubuntu-24.04' || github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository && !contains(fromJSON(inputs.owned_head_repos), github.event.pull_request.head.repo.full_name) && 'blacksmith-4vcpu-ubuntu-2404' || vars.LINUX_RUNNER || 'blacksmith-4vcpu-ubuntu-2404' }} + runs-on: ${{ github.repository_owner != 'manaflow-ai' && 'ubuntu-24.04' || 'blacksmith-4vcpu-ubuntu-2404' }} timeout-minutes: 3 permissions: contents: read diff --git a/.github/workflows/ci-queue-janitor.yml b/.github/workflows/ci-queue-janitor.yml index 73bf019c0f67..4aad4e063063 100644 --- a/.github/workflows/ci-queue-janitor.yml +++ b/.github/workflows/ci-queue-janitor.yml @@ -99,7 +99,7 @@ jobs: contents: read name: Sweep wasted macOS demand if: ${{ !(github.event_name == 'workflow_run' && github.event.workflow_run.pull_requests[0].base.ref == 'feat-cmux-next') }} - runs-on: ${{ github.repository_owner != 'manaflow-ai' && 'ubuntu-24.04' || vars.LINUX_RUNNER || 'blacksmith-4vcpu-ubuntu-2404' }} + runs-on: ${{ github.repository_owner != 'manaflow-ai' && 'ubuntu-24.04' || 'blacksmith-4vcpu-ubuntu-2404' }} timeout-minutes: 10 steps: # Before the freshness gate, so its one read is on the App's budget too. Minting diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e4ec4144a49d..fecf4482d342 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -57,7 +57,7 @@ concurrency: jobs: changes: - runs-on: ${{ github.repository_owner != 'manaflow-ai' && 'ubuntu-24.04' || github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository && 'blacksmith-4vcpu-ubuntu-2404' || vars.LINUX_RUNNER || 'blacksmith-4vcpu-ubuntu-2404' }} + runs-on: ${{ github.repository_owner != 'manaflow-ai' && 'ubuntu-24.04' || 'blacksmith-4vcpu-ubuntu-2404' }} timeout-minutes: 5 outputs: macos: ${{ steps.detect.outputs.macos }} @@ -1162,7 +1162,7 @@ jobs: name: Reverse test impact (report only) needs: [changes] if: ${{ github.event_name == 'pull_request' && needs.changes.result == 'success' && needs.changes.outputs.reverse_test_impact == 'true' }} - runs-on: ${{ github.repository_owner != 'manaflow-ai' && 'ubuntu-24.04' || github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository && 'blacksmith-4vcpu-ubuntu-2404' || vars.LINUX_RUNNER || 'blacksmith-4vcpu-ubuntu-2404' }} + runs-on: ${{ github.repository_owner != 'manaflow-ai' && 'ubuntu-24.04' || 'blacksmith-4vcpu-ubuntu-2404' }} timeout-minutes: 5 continue-on-error: true permissions: diff --git a/.github/workflows/cmux-next-dev-daily-dispatch.yml b/.github/workflows/cmux-next-dev-daily-dispatch.yml index e2e592f51eb4..c3c5726559db 100644 --- a/.github/workflows/cmux-next-dev-daily-dispatch.yml +++ b/.github/workflows/cmux-next-dev-daily-dispatch.yml @@ -27,7 +27,7 @@ jobs: # environment cmux-next.yml mints the same App's token under # (test_supplychain_security.py). environment: ci-routing-agent - runs-on: ${{ github.repository_owner != 'manaflow-ai' && 'ubuntu-24.04' || vars.LINUX_RUNNER || 'blacksmith-4vcpu-ubuntu-2404' }} + runs-on: ${{ github.repository_owner != 'manaflow-ai' && 'ubuntu-24.04' || 'blacksmith-4vcpu-ubuntu-2404' }} permissions: actions: write contents: read diff --git a/.github/workflows/iroh-release-gate.yml b/.github/workflows/iroh-release-gate.yml index 9150f6c42cba..260f989b2fcc 100644 --- a/.github/workflows/iroh-release-gate.yml +++ b/.github/workflows/iroh-release-gate.yml @@ -65,7 +65,7 @@ jobs: # owned Macs, and glaeda keeps ios-streamed-validate's `validate`, the # same shape, on Blacksmith. needs: resolve-ref - runs-on: ${{ github.repository_owner != 'manaflow-ai' && 'ubuntu-24.04' || vars.LINUX_RUNNER || 'blacksmith-4vcpu-ubuntu-2404' }} + runs-on: ${{ github.repository_owner != 'manaflow-ai' && 'ubuntu-24.04' || 'blacksmith-4vcpu-ubuntu-2404' }} timeout-minutes: 5 # Reads the queue janitor's pool snapshot (e2e_runner_pool.py's budget) # and the owned runners through the routing App's own budget. diff --git a/.github/workflows/nightly-next-launch-smoke.yml b/.github/workflows/nightly-next-launch-smoke.yml index 17eb7aa67456..0ed1f3cab147 100644 --- a/.github/workflows/nightly-next-launch-smoke.yml +++ b/.github/workflows/nightly-next-launch-smoke.yml @@ -70,7 +70,7 @@ env: jobs: pick: if: github.repository == 'manaflow-ai/cmux' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) - runs-on: ${{ github.repository_owner != 'manaflow-ai' && 'ubuntu-24.04' || github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository && 'blacksmith-16vcpu-ubuntu-2404' || !startsWith(vars.LINUX_RUNNER, 'blacksmith-') && vars.LINUX_RUNNER || vars.CI_CLOUD_OVERFLOW_SAVED && 'blacksmith-32vcpu-ubuntu-2404' || 'blacksmith-16vcpu-ubuntu-2404' }} + runs-on: ${{ github.repository_owner != 'manaflow-ai' && 'ubuntu-24.04' || vars.CI_CLOUD_OVERFLOW_SAVED && 'blacksmith-32vcpu-ubuntu-2404' || 'blacksmith-16vcpu-ubuntu-2404' }} timeout-minutes: 8 # The routing App's read-only key for the placement, in the environment cmux-next's placement # uses; a pull request's run takes none (and mints no token). diff --git a/.github/workflows/nightly-next-train.yml b/.github/workflows/nightly-next-train.yml index 6a8cc59f6077..74b168fa70ee 100644 --- a/.github/workflows/nightly-next-train.yml +++ b/.github/workflows/nightly-next-train.yml @@ -184,7 +184,7 @@ jobs: name: Pick the train compile's runner if: github.repository == 'manaflow-ai/cmux' && inputs.mode == 'build' && startsWith(github.ref, 'refs/heads/nightly-train/') continue-on-error: true - runs-on: ${{ github.repository_owner != 'manaflow-ai' && 'ubuntu-24.04' || vars.LINUX_RUNNER || 'blacksmith-4vcpu-ubuntu-2404' }} + runs-on: ${{ github.repository_owner != 'manaflow-ai' && 'ubuntu-24.04' || 'blacksmith-4vcpu-ubuntu-2404' }} # The routing App's key, as nightly.yml's pick-nightly-build-runner reads it. environment: ci-routing-agent timeout-minutes: 5 diff --git a/.github/workflows/sdk-release-cut.yml b/.github/workflows/sdk-release-cut.yml index bbba1db161c2..3c60e85f90a0 100644 --- a/.github/workflows/sdk-release-cut.yml +++ b/.github/workflows/sdk-release-cut.yml @@ -516,7 +516,7 @@ jobs: needs: - validate-release - revalidate-tags - runs-on: ${{ github.repository_owner != 'manaflow-ai' && 'ubuntu-24.04' || vars.LINUX_RUNNER || 'blacksmith-4vcpu-ubuntu-2404' }} + runs-on: ${{ github.repository_owner != 'manaflow-ai' && 'ubuntu-24.04' || 'blacksmith-4vcpu-ubuntu-2404' }} timeout-minutes: 10 permissions: {} environment: diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index 3ad908e3e5f4..78d3bf355e01 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -88,7 +88,7 @@ jobs: # job lengths, whatever Blacksmith's wait, as for pull requests. A job an owned Mac leaves queued or refuses is re-run by # ci-owned-pool-rescue.yml, and every re-run attempt of build or test takes # retry_label (Blacksmith) instead, so a busy Mac never strands a run. - runs-on: ${{ github.repository_owner != 'manaflow-ai' && 'ubuntu-24.04' || vars.LINUX_RUNNER || 'blacksmith-4vcpu-ubuntu-2404' }} + runs-on: ${{ github.repository_owner != 'manaflow-ai' && 'ubuntu-24.04' || 'blacksmith-4vcpu-ubuntu-2404' }} timeout-minutes: 5 # Reads the queue janitor's pool snapshot and the runs created since it # (four or five API calls; see e2e_runner_pool.py for the budget), and the diff --git a/.github/workflows/test-ios.yml b/.github/workflows/test-ios.yml index e803052c0e8c..ed06272287e0 100644 --- a/.github/workflows/test-ios.yml +++ b/.github/workflows/test-ios.yml @@ -127,7 +127,7 @@ jobs: # owned Mac leaves queued or refuses is re-run by ci-owned-pool-rescue.yml # (its sweeper), and every re-run attempt takes retry_runs_on (Blacksmith). # scripts/ci/ios_runner_pool.py has the rules. - runs-on: ${{ github.repository_owner != 'manaflow-ai' && 'ubuntu-24.04' || github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository && 'blacksmith-4vcpu-ubuntu-2404' || vars.LINUX_RUNNER || 'blacksmith-4vcpu-ubuntu-2404' }} + runs-on: ${{ github.repository_owner != 'manaflow-ai' && 'ubuntu-24.04' || 'blacksmith-4vcpu-ubuntu-2404' }} timeout-minutes: 5 # Reads the queue janitor's pool snapshot and the runs created since it # (see ios_runner_pool.py for the API budget). diff --git a/docs/ci-runners.md b/docs/ci-runners.md index 7a35cdecaddc..5cd5871a1f28 100644 --- a/docs/ci-runners.md +++ b/docs/ci-runners.md @@ -94,7 +94,7 @@ gh variable list --repo manaflow-ai/cmux | Variable | Used by | Intended steady state | Fallback baked into the workflow | | --- | --- | --- | --- | -| `LINUX_RUNNER` | every Linux job (`ci.yml` web/typecheck/db, presence, cloud-vm, nightly/ios decide jobs, homebrew, tmux fuzz) | `blacksmith-4vcpu-ubuntu-2404` | `blacksmith-4vcpu-ubuntu-2404` | +| `LINUX_RUNNER` | every Linux job (`ci.yml` web/typecheck/db, presence, cloud-vm, nightly/ios decide jobs, homebrew, tmux fuzz) except a job that holds a GitHub App key: that job runs on a literal Blacksmith label or the `CI_TRUSTED_RUNNER` selector, so no variable can move the key to a reused machine (`tests/test_ci_fork_runner_routing.py`) | `blacksmith-4vcpu-ubuntu-2404` | `blacksmith-4vcpu-ubuntu-2404` | | `CI_TRUSTED_RUNNER` | jobs holding trusted tokens that must run on an ephemeral VM: the required `backend migrations applied` check and `web-complexity-trusted.yml` (`validate-cla-policy.rb` accepts this exact selector for the CLA checks too, with a runner guard step that admits only GitHub-hosted runners and Blacksmith VMs; `cla.yml` and `cla-policy-guard.yml` pin `ubuntu-24.04` until they move to it). Only `ubuntu-24.04`, `blacksmith-2vcpu-ubuntu-2404` or `blacksmith-4vcpu-ubuntu-2404` is accepted; any other value, owned label included, falls back. Set it to `ubuntu-24.04` when Blacksmith stalls, or leave it unset when GitHub-hosted runners stall | unset | `blacksmith-4vcpu-ubuntu-2404` (forks: `ubuntu-24.04`) | | `LINUX_ARM64_RUNNER` | native ARM64 package entrypoint verification | `ubuntu-24.04-arm` | `ubuntu-24.04-arm` | | `MACOS_RUNNER_15` | the macOS 15 default: `macos-compile-admission`, non-PR `app-host-unit-tests`, nightly helper and test-cache jobs, `iroh-release-gate.yml` streamed validation | `blacksmith-6vcpu-macos-15` | `blacksmith-6vcpu-macos-15` | diff --git a/tests/test_ci_fork_runner_routing.py b/tests/test_ci_fork_runner_routing.py index 4e91693aafc2..8c6ce7dea948 100644 --- a/tests/test_ci_fork_runner_routing.py +++ b/tests/test_ci_fork_runner_routing.py @@ -122,6 +122,50 @@ ("web-complexity-trusted.yml", "complexity"), ) +# A job that holds a GitHub App private key (a `create-github-app-token` step or a +# `private-key:`) must run where no repository variable can move it to a reused machine, +# where the key could outlive the job; and such a job, with a token that can write +# variables, must not pick its own runner. So its runs-on is a literal Blacksmith label +# (behind the fork branch at most) or the exact CI_TRUSTED_RUNNER selector, which admits +# only ephemeral labels. #27022 let CI_CONTROL_RUNNER move the overflow watch, which +# mints GLAEDA_ROUTE_APP_KEY; LINUX_RUNNER moved a dozen more such jobs. +APP_KEY_MARKER = re.compile(r"create-github-app-token@|^\s*private-key:", re.MULTILINE) +APP_KEY_LITERAL_RUNNER = re.compile( + r"^(?:blacksmith-[a-z0-9-]+" + r"|\$\{\{ github\.repository_owner != 'manaflow-ai' && '(?:ubuntu-24\.04|macos-\d+)' \|\| " + # While the overflow switch's record exists, a larger literal Blacksmith size: the variable + # only chooses between two literal labels. + r"(?:vars\.CI_CLOUD_OVERFLOW_SAVED && 'blacksmith-[a-z0-9-]+' \|\| )?'blacksmith-[a-z0-9-]+' \}\})$" +) +# (workflow, job) -> why its runner may come from elsewhere. Exact jobs only. +APP_KEY_RUNNER_EXCEPTIONS = { + ("nightly.yml", "generate-nightly-deltas"): + "pick-classic-sign-runner's output, which names only Blacksmith macOS labels " + "(classic_nightly_build_runner.py), else the literal Blacksmith fallback", + ("dogfood-artifact-publish.yml", "capture"): + "open: CMUX_BOT_APP_KEY runs on blacksmith-6vcpu-macos-15 unless CI_PAID_MACOS_OVERFLOW is 1, then " + "on MACOS_RUNNER_DISPLAY; the overflow switch sets both (to the owned GUI pool) in a Blacksmith " + "outage, so the key can reach a reused mini; fix: mint the token in a separate job", +} + + +def app_key_jobs() -> list[tuple[str, str, str]]: + """(workflow, job, runs-on) for every job that holds a GitHub App private key.""" + found = [] + for path in sorted(WORKFLOWS.glob("*.y*ml")): + text = path.read_text(encoding="utf-8") + jobs = re.search(r"(?ms)^jobs:\n(.*)", text) + if jobs is None: + continue + for block in re.finditer(r"(?ms)^ ([A-Za-z0-9_-]+):\n(.*?)(?=^ \S|\Z)", jobs.group(1)): + body = block.group(2) + if not APP_KEY_MARKER.search(body): + continue + runs_on = re.search(r"(?m)^ runs-on:\s*(.*?)\s*(?:#.*)?$", body) + found.append((path.name, block.group(1), runs_on.group(1) if runs_on else "")) + return found + + # A fork pull request into manaflow-ai runs with repository_owner == # 'manaflow-ai', so the owner branches above do not catch it. Before any # repository variable or pool picker output can pick a runner, it must take @@ -1044,6 +1088,34 @@ def test_merge_gating_checks_route_through_the_trusted_runner(self) -> None: self.assertEqual(len(runs_on), 1, runs_on) self.assertRegex(runs_on[0], TRUSTED_RUNNER_LINE) + def test_a_job_with_an_app_key_runs_where_no_variable_can_move_it(self) -> None: + jobs = app_key_jobs() + names = {(workflow, job) for workflow, job, _ in jobs} + # Not vacuous: the overflow watch and the queue janitor mint GLAEDA_ROUTE_APP_KEY. + self.assertIn(("ci-cloud-overflow-probe.yml", "watch"), names) + self.assertIn(("ci-queue-janitor.yml", "sweep"), names) + for key in APP_KEY_RUNNER_EXCEPTIONS: + self.assertIn(key, names, f"stale exception {key}") + for workflow, job, runs_on in jobs: + if (workflow, job) in APP_KEY_RUNNER_EXCEPTIONS: + continue + with self.subTest(workflow=workflow, job=job): + self.assertTrue(APP_KEY_LITERAL_RUNNER.match(runs_on) or runs_on == TRUSTED_RUNNER_EXPRESSION, + f"{workflow}:{job} holds an App key on a movable runner: {runs_on}") + + def test_the_app_key_runner_rule_refuses_a_variable(self) -> None: + fork = "github.repository_owner != 'manaflow-ai' && 'ubuntu-24.04' || " + for refused in (f"${{{{ {fork}vars.LINUX_RUNNER || 'blacksmith-4vcpu-ubuntu-2404' }}}}", + "${{ vars.CI_CONTROL_RUNNER || 'blacksmith-6vcpu-macos-26' }}", + f"${{{{ {fork}vars.CI_CLOUD_OVERFLOW_SAVED && vars.LINUX_RUNNER || " + "'blacksmith-4vcpu-ubuntu-2404' }}", + "glaeda-std-xcode-26.6", "ubuntu-24.04"): + self.assertIsNone(APP_KEY_LITERAL_RUNNER.match(refused), refused) + for allowed in ("blacksmith-6vcpu-macos-26", f"${{{{ {fork}'blacksmith-4vcpu-ubuntu-2404' }}}}", + f"${{{{ {fork}vars.CI_CLOUD_OVERFLOW_SAVED && 'blacksmith-16vcpu-ubuntu-2404' || " + "'blacksmith-4vcpu-ubuntu-2404' }}"): + self.assertIsNotNone(APP_KEY_LITERAL_RUNNER.match(allowed), allowed) + def test_trusted_runner_selector_admits_only_ephemeral_labels(self) -> None: self.assertEqual(outsider_runner_errors("x.yml", f"jobs:\n a:\n runs-on: {TRUSTED_RUNNER_EXPRESSION}\n"), []) for label in TRUSTED_RUNNER_LABELS: diff --git a/tests/test_ci_queue_janitor.py b/tests/test_ci_queue_janitor.py index ea8c145e28fb..409a4e67842e 100644 --- a/tests/test_ci_queue_janitor.py +++ b/tests/test_ci_queue_janitor.py @@ -754,7 +754,9 @@ def test_triggers_permissions_and_runner(self): self.assertNotIn("pull_request", text.split("jobs:")[0].replace("pull-requests: read", "")) self.assertIn("\npermissions: {}\n", text) self.assertIn(" sweep:\n permissions:\n actions: write\n pull-requests: read\n contents: read\n", text) - self.assertIn("runs-on: ${{ github.repository_owner != 'manaflow-ai' && 'ubuntu-24.04' || vars.LINUX_RUNNER || 'blacksmith-4vcpu-ubuntu-2404' }}", text) + self.assertIn("runs-on: ${{ github.repository_owner != 'manaflow-ai' && 'ubuntu-24.04' || 'blacksmith-4vcpu-ubuntu-2404' }}", text) + # It mints GLAEDA_ROUTE_APP_KEY and CMUX_BOT_APP_KEY: no variable picks its runner. + self.assertNotIn("vars.LINUX_RUNNER", text) self.assertIn("concurrency:\n group: ci-queue-janitor\n cancel-in-progress: false\n", text) self.assertIn("vars.CI_JANITOR_QUEUE_THRESHOLD", text) self.assertIn("ORPHAN_MINUTES: ${{ vars.CI_JANITOR_ORPHAN_MINUTES }}", text) diff --git a/tests/test_e2e_sibling_build.py b/tests/test_e2e_sibling_build.py index be7bac488221..771a5a27a091 100644 --- a/tests/test_e2e_sibling_build.py +++ b/tests/test_e2e_sibling_build.py @@ -242,7 +242,10 @@ def setUp(self) -> None: def test_the_wait_runs_on_linux_before_the_build(self) -> None: sibling_job = self.jobs["sibling"] self.assertNotIn("macos", str(sibling_job["runs-on"])) - self.assertEqual(sibling_job["runs-on"], self.jobs["runner"]["runs-on"]) + # The same Linux fallback as the runner job. The runner job holds an App key, so no variable + # moves it; the sibling holds none and may still follow LINUX_RUNNER. + fallback = self.jobs["runner"]["runs-on"].rsplit("||", 1)[1] + self.assertTrue(sibling_job["runs-on"].endswith("||" + fallback), sibling_job["runs-on"]) self.assertIn("sibling", self.jobs["build"]["needs"]) wait = next(step for step in sibling_job["steps"] if "e2e_sibling_build.py wait" in str(step.get("run"))) self.assertTrue(wait["run"].endswith("|| true")) diff --git a/tests/test_tui_publish_workflow_security.py b/tests/test_tui_publish_workflow_security.py index b169cdf45723..b7bd0f04abc3 100644 --- a/tests/test_tui_publish_workflow_security.py +++ b/tests/test_tui_publish_workflow_security.py @@ -719,7 +719,9 @@ def test_release_app_token_is_scoped_to_the_atomic_push() -> None: assert "SDK_RELEASE_APP_PRIVATE_KEY" not in revalidate_tags assert "actions/create-github-app-token@" not in revalidate_tags - assert "runs-on: ${{ github.repository_owner != 'manaflow-ai' && 'ubuntu-24.04' || vars.LINUX_RUNNER || 'blacksmith-4vcpu-ubuntu-2404' }}" in cut_tags + # It holds the release App key: a literal label no variable can move (test_ci_fork_runner_routing.py). + assert "runs-on: ${{ github.repository_owner != 'manaflow-ai' && 'ubuntu-24.04' || 'blacksmith-4vcpu-ubuntu-2404' }}" in cut_tags + assert "vars." not in cut_tags.split("runs-on:", 1)[1].split("\n", 1)[0] assert "actions/checkout@" not in cut_tags assert "actions/download-artifact@" not in cut_tags assert "actions/setup-node@" not in cut_tags