From 96e4fada7a885f971d542d9cc5eb2bcf3a80766c Mon Sep 17 00:00:00 2001 From: leynos Date: Tue, 7 Jul 2026 12:22:09 +0200 Subject: [PATCH] Add a setup-commands input to the cargo mutation workflow Callers cannot inject steps into a `workflow_call` job, so repositories whose builds need job-level preparation had no way to satisfy it before cargo-mutants runs. The concrete case is agent-template-rust review feedback: generated repos render `.cargo/config.toml` with `-fuse-ld=mold` on the default Linux target and their CI installs mold before any cargo command; the mutation baseline would fail to link on a bare runner. `setup-commands` (default empty, preserving existing behaviour) runs caller-supplied shell in each mutants job after toolchain setup and before cargo-mutants, via a temp script under `set -euo pipefail`. The input executes with the same privileges the caller's own workflows already hold in their repository. --- .github/workflows/mutation-cargo.yml | 19 +++++++++++++++++++ docs/mutation-cargo-workflow.md | 1 + 2 files changed, 20 insertions(+) diff --git a/.github/workflows/mutation-cargo.yml b/.github/workflows/mutation-cargo.yml index 49151204..fa417c7e 100644 --- a/.github/workflows/mutation-cargo.yml +++ b/.github/workflows/mutation-cargo.yml @@ -58,6 +58,14 @@ on: "--all-features" so feature-gated tests run against mutants. type: string default: "" + setup-commands: + description: >- + Shell commands run in each mutants job before cargo-mutants + (e.g. installing a linker such as mold, or system packages + the build needs). Executed with bash under `set -euo + pipefail`; empty means no extra setup. + type: string + default: "" # Default the token to no scopes; jobs opt in explicitly. permissions: {} @@ -185,6 +193,17 @@ jobs: cargo binstall --no-confirm cargo-mutants fi + - name: Run setup commands + if: ${{ inputs.setup-commands != '' }} + shell: bash + env: + SETUP_COMMANDS: ${{ inputs.setup-commands }} + run: | + set -euo pipefail + script="${RUNNER_TEMP}/mutation-setup-commands.sh" + printf '%s\n' "${SETUP_COMMANDS}" > "${script}" + bash -euo pipefail "${script}" + - name: Install uv (act) if: ${{ env.ACT == 'true' }} shell: bash diff --git a/docs/mutation-cargo-workflow.md b/docs/mutation-cargo-workflow.md index 55d361e2..56473dcb 100644 --- a/docs/mutation-cargo-workflow.md +++ b/docs/mutation-cargo-workflow.md @@ -83,6 +83,7 @@ jobs: | `shard-count` | `6` | Fan-out for full dispatch runs (scoped runs stay single-shard). | | `cargo-mutants-version` | pinned | Tool version; the summary parser is validated against it. | | `extra-args` | (empty) | Extra cargo-mutants arguments (shell-lexed), e.g. `--all-features`. | +| `setup-commands` | (empty) | Shell commands run before cargo-mutants in each mutants job (e.g. `sudo apt-get install -y mold` when the repo's `.cargo/config.toml` selects that linker). | ## Notes