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