diff --git a/.github/workflows/apidocs-drift.yml b/.github/workflows/apidocs-drift.yml index 7756fa669..c750974f4 100644 --- a/.github/workflows/apidocs-drift.yml +++ b/.github/workflows/apidocs-drift.yml @@ -82,7 +82,7 @@ jobs: workspaces: crates/bashkit-js - name: Setup pnpm - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0 + uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1 # pnpm/action-setup v6 no longer ships a default version; it reads # `packageManager` from the root package.json, which this repo does # not have (the field lives in crates/bashkit-js/package.json). Pin diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 686fbe59b..7e1aefa93 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -219,7 +219,7 @@ jobs: # override even for `cargo install`), which broke this job. A prebuilt # binary is immune to future tool-dependency MSRV bumps. - name: Install cargo-audit - uses: taiki-e/install-action@682ce6c3c696a4cd5168a05f98e51aa02b877941 # v2 + uses: taiki-e/install-action@b80e2bb2635f28eb98b9fce1e2f0887e1535c6b2 # v2 with: tool: cargo-audit @@ -228,7 +228,7 @@ jobs: # from pnpm-lock.yaml, and the PyPI scan reads uv.lock with the stdlib, # so neither ecosystem costs an install here. - name: Setup pnpm - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0 + uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1 with: version: 10.33.0 @@ -252,7 +252,7 @@ jobs: command: check licenses sources - name: Install cargo-vet - uses: taiki-e/install-action@682ce6c3c696a4cd5168a05f98e51aa02b877941 # v2 + uses: taiki-e/install-action@b80e2bb2635f28eb98b9fce1e2f0887e1535c6b2 # v2 with: # 0.10.2+ parses trusted-publisher entries in imports.lock (wasmtime # crates publish via GitHub trusted publishing); 0.10.0 rejects them. @@ -303,7 +303,7 @@ jobs: - name: Install uutils coreutils multicall for differential tests id: install_uutils continue-on-error: true - uses: taiki-e/install-action@682ce6c3c696a4cd5168a05f98e51aa02b877941 # v2 + uses: taiki-e/install-action@b80e2bb2635f28eb98b9fce1e2f0887e1535c6b2 # v2 with: tool: coreutils - name: Verify uutils on PATH @@ -421,9 +421,9 @@ jobs: persist-credentials: false - name: Install Rust toolchain + # 1.96.0 comes from rust-toolchain.toml (the matrix pins the same); + # the action no longer accepts a `toolchain:` input. uses: dtolnay/rust-toolchain@d86e0fa8f147d6539442c26a61ebba8becc19489 # 1.96.0 - with: - toolchain: ${{ matrix.rust }} - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2 @@ -655,16 +655,27 @@ jobs: with: persist-credentials: false + - name: Install Rust stable (default toolchain) + uses: dtolnay/rust-toolchain@d86e0fa8f147d6539442c26a61ebba8becc19489 # 1.96.0 + + # The action no longer accepts a `toolchain:` input (it installs + # the rust-toolchain.toml toolchain), so install the pinned nightly + # explicitly below. + # Pinned: nightly 2026-10-31 (rustc f9ceb4a4d) fails to compile bashkit + # (E0391 async-drop cycle on parser::ast::CommandList). Unpin once a + # later nightly builds `cargo +nightly check -p bashkit --lib`. - name: Install Rust nightly - uses: dtolnay/rust-toolchain@5b842231ba77f5c045dba54ac5560fed2db780e2 # nightly - with: - # Pinned: nightly 2026-10-31 (rustc f9ceb4a4d) fails to compile bashkit - # (E0391 async-drop cycle on parser::ast::CommandList). Unpin once a - # later nightly builds `cargo +nightly check -p bashkit --lib`. - toolchain: nightly-2026-10-30 + run: rustup toolchain install nightly-2026-10-30 --profile minimal + # Builds from source on the job's default toolchain, which is now the + # pinned stable; without this the unpinned tool would resolve to the + # newest release and an upstream MSRV bump would break an unchanged + # tree (the cargo-geiger 0.14.0 failure). Nightly outruns any released + # MSRV, so build it there, as the `toolchain:` input used to. - name: Install cargo-fuzz uses: taiki-e/cache-cargo-install-action@9ee83daaa7b96a6fab930949ecf1122bba04a389 # v3 + env: + RUSTUP_TOOLCHAIN: nightly-2026-10-30 with: tool: cargo-fuzz locked: true diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 2fb0e79b3..65abb7708 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -42,7 +42,7 @@ jobs: - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2 - name: Install cargo-tarpaulin - uses: taiki-e/install-action@682ce6c3c696a4cd5168a05f98e51aa02b877941 # v2 + uses: taiki-e/install-action@b80e2bb2635f28eb98b9fce1e2f0887e1535c6b2 # v2 with: tool: cargo-tarpaulin @@ -100,7 +100,7 @@ jobs: - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2 - name: Install cargo-llvm-cov - uses: taiki-e/install-action@682ce6c3c696a4cd5168a05f98e51aa02b877941 # v2 + uses: taiki-e/install-action@b80e2bb2635f28eb98b9fce1e2f0887e1535c6b2 # v2 with: tool: cargo-llvm-cov @@ -151,12 +151,12 @@ jobs: - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2 - name: Install cargo-llvm-cov - uses: taiki-e/install-action@682ce6c3c696a4cd5168a05f98e51aa02b877941 # v2 + uses: taiki-e/install-action@b80e2bb2635f28eb98b9fce1e2f0887e1535c6b2 # v2 with: tool: cargo-llvm-cov - name: Setup pnpm - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0 + uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1 with: version: 10.33.0 diff --git a/.github/workflows/fuzz.yml b/.github/workflows/fuzz.yml index 22f8051c3..eaf135246 100644 --- a/.github/workflows/fuzz.yml +++ b/.github/workflows/fuzz.yml @@ -33,16 +33,22 @@ jobs: with: persist-credentials: false + - name: Install Rust stable (default toolchain) + uses: dtolnay/rust-toolchain@d86e0fa8f147d6539442c26a61ebba8becc19489 # 1.96.0 + + # The action no longer accepts a `toolchain:` input (it installs + # the rust-toolchain.toml toolchain), so install the pinned nightly + # explicitly below. + # Pinned: nightly 2026-10-31 (rustc f9ceb4a4d) fails to compile bashkit + # (E0391 async-drop cycle on parser::ast::CommandList). Unpin once a + # later nightly builds `cargo +nightly check -p bashkit --lib`. - name: Install Rust nightly - uses: dtolnay/rust-toolchain@5b842231ba77f5c045dba54ac5560fed2db780e2 # nightly - with: - # Pinned: nightly 2026-10-31 (rustc f9ceb4a4d) fails to compile bashkit - # (E0391 async-drop cycle on parser::ast::CommandList). Unpin once a - # later nightly builds `cargo +nightly check -p bashkit --lib`. - toolchain: nightly-2026-10-30 + run: rustup toolchain install nightly-2026-10-30 --profile minimal + # On the nightly, not the pinned stable default: an unpinned source + # build on a pinned toolchain breaks when upstream raises its MSRV. - name: Install cargo-fuzz - run: cargo install cargo-fuzz --locked + run: cargo +nightly-2026-10-30 install cargo-fuzz --locked - name: Cache fuzz corpus uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v5 diff --git a/.github/workflows/js.yml b/.github/workflows/js.yml index 7aa5578f7..cc5a5fff8 100644 --- a/.github/workflows/js.yml +++ b/.github/workflows/js.yml @@ -47,7 +47,7 @@ jobs: - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2 - name: Setup pnpm - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0 + uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1 with: version: 10.33.0 @@ -116,7 +116,7 @@ jobs: - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2 - name: Setup pnpm - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0 + uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1 with: version: 10.33.0 @@ -275,7 +275,7 @@ jobs: # and an OS, and a restored arm64 `target/` must not reach the x64 # build. prefix-key: v0-rust-${{ matrix.target || 'host' }} - - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0 + - uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1 with: version: 10.33.0 - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v6 diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 2544e2f79..67681132f 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -25,14 +25,17 @@ jobs: with: persist-credentials: false + - name: Install Rust stable (default toolchain) + uses: dtolnay/rust-toolchain@d86e0fa8f147d6539442c26a61ebba8becc19489 # 1.96.0 + + # The action no longer accepts a `toolchain:` input (it installs + # the rust-toolchain.toml toolchain), so install the pinned nightly + # explicitly below. + # Pinned: nightly 2026-10-31 (rustc f9ceb4a4d) fails to compile bashkit + # (E0391 async-drop cycle on parser::ast::CommandList). Unpin once a + # later nightly builds `cargo +nightly check -p bashkit --lib`. - name: Install Rust nightly with Miri - uses: dtolnay/rust-toolchain@5b842231ba77f5c045dba54ac5560fed2db780e2 # nightly - with: - # Pinned: nightly 2026-10-31 (rustc f9ceb4a4d) fails to compile bashkit - # (E0391 async-drop cycle on parser::ast::CommandList). Unpin once a - # later nightly builds `cargo +nightly check -p bashkit --lib`. - toolchain: nightly-2026-10-30 - components: miri + run: rustup toolchain install nightly-2026-10-30 --profile minimal --component miri - name: Setup Miri run: cargo +nightly-2026-10-30 miri setup @@ -67,14 +70,14 @@ jobs: # dependencies resolve unlocked, and an MSRV bump in one of them past our # pinned toolchain broke this step once already in CI. - name: Install cargo-audit - uses: taiki-e/install-action@682ce6c3c696a4cd5168a05f98e51aa02b877941 # v2 + uses: taiki-e/install-action@b80e2bb2635f28eb98b9fce1e2f0887e1535c6b2 # v2 with: tool: cargo-audit # pnpm (and the node it needs) for the npm half of the scan; the PyPI # half reads uv.lock with the stdlib. Neither needs an install step. - name: Setup pnpm - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0 + uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1 with: version: 10.33.0 @@ -147,14 +150,17 @@ jobs: - name: Free disk space uses: ./.github/actions/free-disk-space - - name: Install Rust nightly - uses: dtolnay/rust-toolchain@5b842231ba77f5c045dba54ac5560fed2db780e2 # nightly - with: - # Pinned: nightly 2026-10-31 (rustc f9ceb4a4d) fails to compile bashkit - # (E0391 async-drop cycle on parser::ast::CommandList). Unpin once a - # later nightly builds `cargo +nightly check -p bashkit --lib`. - toolchain: nightly-2026-10-30 - components: rust-src + - name: Install Rust stable (default toolchain) + uses: dtolnay/rust-toolchain@d86e0fa8f147d6539442c26a61ebba8becc19489 # 1.96.0 + + # The action no longer accepts a `toolchain:` input (it installs + # the rust-toolchain.toml toolchain), so install the pinned nightly + # explicitly below. + # Pinned: nightly 2026-10-31 (rustc f9ceb4a4d) fails to compile bashkit + # (E0391 async-drop cycle on parser::ast::CommandList). Unpin once a + # later nightly builds `cargo +nightly check -p bashkit --lib`. + - name: Install Rust nightly with rust-src for build-std + run: rustup toolchain install nightly-2026-10-30 --profile minimal --component rust-src - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2 with: diff --git a/.github/workflows/publish-js.yml b/.github/workflows/publish-js.yml index 039d7421d..1a9eb3604 100644 --- a/.github/workflows/publish-js.yml +++ b/.github/workflows/publish-js.yml @@ -98,7 +98,7 @@ jobs: persist-credentials: false - name: Setup pnpm - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0 + uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1 with: version: 10.33.0 @@ -217,7 +217,7 @@ jobs: git checkout FETCH_HEAD -- crates/bashkit-js/__test__ - name: Setup pnpm - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0 + uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1 with: version: 10.33.0 @@ -353,7 +353,7 @@ jobs: git checkout FETCH_HEAD -- crates/bashkit-js/__test__ - name: Setup pnpm - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0 + uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1 with: version: 10.33.0 @@ -479,7 +479,7 @@ jobs: # steps: # - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 # - name: Setup pnpm - # uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0 + # uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1 # with: # version: 10.33.0 # - name: Setup node @@ -536,7 +536,7 @@ jobs: run: test "$(git rev-parse HEAD)" = "$SOURCE_SHA" - name: Setup pnpm - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0 + uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1 with: version: 10.33.0 diff --git a/.github/workflows/publish-python.yml b/.github/workflows/publish-python.yml index cc8e80f90..1358c9e3a 100644 --- a/.github/workflows/publish-python.yml +++ b/.github/workflows/publish-python.yml @@ -151,13 +151,14 @@ jobs: # nightly satisfies our deps' MSRV (monty needs 1.96) + edition 2024; # its LLVM matches Emscripten 4.0.9's binaryen. pyodide-build manages its # own matching emsdk via the cross-build env (no setup-emsdk needed). + - name: Install Rust stable (default toolchain) + uses: dtolnay/rust-toolchain@d86e0fa8f147d6539442c26a61ebba8becc19489 # 1.96.0 + + # The action no longer accepts a `toolchain:` input (it installs + # the rust-toolchain.toml toolchain), so install the pinned nightly + # explicitly below. - name: Install nightly Rust with the Emscripten target - # @nightly matches the repo's other nightly jobs; the exact nightly is - # pinned via the toolchain: input below. - uses: dtolnay/rust-toolchain@5b842231ba77f5c045dba54ac5560fed2db780e2 # nightly - with: - toolchain: ${{ env.RUST_NIGHTLY }} - targets: wasm32-unknown-emscripten + run: rustup toolchain install ${{ env.RUST_NIGHTLY }} --profile minimal --target wasm32-unknown-emscripten - name: Install pyodide-build run: pip install "pyodide-build==${PYODIDE_BUILD_VERSION}" diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 524b33b4c..da8d21080 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -285,13 +285,14 @@ jobs: # so it has to be recent; its LLVM (19+) matches Emscripten 4.0.9's # binaryen, which is what avoids the wasm-opt target-feature skew that # older Emscripten (3.1.x) hit. See knowledge/runtimes/emscripten-wheels.md. + - name: Install Rust stable (default toolchain) + uses: dtolnay/rust-toolchain@d86e0fa8f147d6539442c26a61ebba8becc19489 # 1.96.0 + + # The action no longer accepts a `toolchain:` input (it installs + # the rust-toolchain.toml toolchain), so install the pinned nightly + # explicitly below. - name: Install nightly Rust with the Emscripten target - # @nightly matches the repo's other nightly jobs (fuzz.yml, nightly.yml, - # ci.yml); the exact nightly is pinned via the toolchain: input below. - uses: dtolnay/rust-toolchain@5b842231ba77f5c045dba54ac5560fed2db780e2 # nightly - with: - toolchain: ${{ env.RUST_NIGHTLY }} - targets: wasm32-unknown-emscripten + run: rustup toolchain install ${{ env.RUST_NIGHTLY }} --profile minimal --target wasm32-unknown-emscripten - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2 diff --git a/.github/workflows/site.yml b/.github/workflows/site.yml index c0d2e7181..4d687a466 100644 --- a/.github/workflows/site.yml +++ b/.github/workflows/site.yml @@ -60,7 +60,7 @@ jobs: with: persist-credentials: false - name: Setup pnpm - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0 + uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1 with: version: 10.11.1 - name: Setup Node.js diff --git a/crates/bashkit/tests/integration/python_tenant_stress_tests.rs b/crates/bashkit/tests/integration/python_tenant_stress_tests.rs index 12b923df2..8eef08868 100644 --- a/crates/bashkit/tests/integration/python_tenant_stress_tests.rs +++ b/crates/bashkit/tests/integration/python_tenant_stress_tests.rs @@ -10,17 +10,24 @@ #![cfg(feature = "python")] -use bashkit::{Bash, PythonLimits}; +use bashkit::{Bash, PythonLimits, SessionLimits}; use std::time::Duration; +/// Largest `BASHKIT_STRESS_ROUNDS` accepted, and the basis for the session +/// exec() headroom in `tenant`. Keep the two together: they drifted apart once +/// (see `tenant`) and the soak failed on the cap rather than on its subject. +const MAX_ROUNDS: usize = 1000; + fn rounds() -> usize { std::env::var("BASHKIT_STRESS_ROUNDS") .ok() .map(|v| { v.parse::() .ok() - .filter(|n| (1..=1000).contains(n)) - .unwrap_or_else(|| panic!("BASHKIT_STRESS_ROUNDS must be 1..=1000, got {v:?}")) + .filter(|n| (1..=MAX_ROUNDS).contains(n)) + .unwrap_or_else(|| { + panic!("BASHKIT_STRESS_ROUNDS must be 1..={MAX_ROUNDS}, got {v:?}") + }) }) .unwrap_or(3) } @@ -33,6 +40,13 @@ fn tenant(limit_mib: usize, max_ms: u64) -> Bash { .max_duration(Duration::from_millis(max_ms)) .max_recursion(200), ) + // The session exec() cap (1,000 by default) is not what these tests + // measure, and the soak multiplies their call counts straight through + // it: at BASHKIT_STRESS_ROUNDS=300 the budget-reuse test makes 3,000 + // calls and died on the cap at call 1,000 with "session exec() call + // limit exceeded", never reaching what it asserts. Sized off + // MAX_ROUNDS so the largest soak this file can ask for still fits. + .session_limits(SessionLimits::default().max_exec_calls(20 * MAX_ROUNDS as u64)) .env("BASHKIT_ALLOW_INPROCESS_PYTHON", "1") .build() } diff --git a/knowledge/operations/dependencies.md b/knowledge/operations/dependencies.md index 0b9878e81..4b0b008e6 100644 --- a/knowledge/operations/dependencies.md +++ b/knowledge/operations/dependencies.md @@ -210,6 +210,34 @@ the vendored parser in one deliberate change — not inside an aggregated `scripts/tests/test_dependabot_coverage.py` enforces all three. +## A source-built CI tool rides the toolchain of the step that installs it + +`taiki-e/cache-cargo-install-action` and a bare `cargo install` both build from +source, so the tool version they can resolve is bounded by the toolchain active +*in that step*. On the pinned toolchain an unpinned tool resolves to the newest +release, and an upstream MSRV bump then breaks a tree that has not changed: +cargo-geiger 0.14.0 shipped requiring rustc 1.97 and nightly run 259 went red +the next morning with the unsafe-code audit skipped. + +Two ways out, and the choice is per step: pin the version (`tool: name@version` +where the action reads it, or `--version`), or build on a nightly, which +outruns any released MSRV. + +Which toolchain a step gets changed with the `dtolnay/rust-toolchain` schema. +The action dropped its `toolchain:` input and now always installs the +`rust-toolchain.toml` toolchain, so a job wanting nightly installs it +*alongside* the stable default (`rustup toolchain install nightly-`) and +selects it per command (`cargo +nightly- fuzz build`). A `cargo install` +in such a job therefore gets **stable**, not nightly, unless it says otherwise +— via `RUSTUP_TOOLCHAIN` on the step or `cargo +nightly-` in its `run`. +Both cargo-fuzz installs needed that opt-in when the jobs migrated; reading the +exemption per job instead of per step would have reopened the geiger hole. + +`scripts/tests/test_pinned_ci_tools.py` enforces this, and also rejects an +input the action silently drops — a pin that looks right and does nothing is +worse than no pin, because the job keeps reporting the failure it was meant to +fix. + ## Measure size and audit surface separately The `idna_adapter` pin removes 21 crates but only **15 KB (0.16%)** from the diff --git a/scripts/tests/test_pinned_ci_tools.py b/scripts/tests/test_pinned_ci_tools.py index 7a452bc1d..74c40a82e 100644 --- a/scripts/tests/test_pinned_ci_tools.py +++ b/scripts/tests/test_pinned_ci_tools.py @@ -6,8 +6,18 @@ tool resolves to the newest release and an upstream MSRV bump breaks a tree that has not changed: cargo-geiger 0.14.0 shipped on 2026-10-12 requiring rustc 1.97, and nightly run 259 went red the next morning with the unsafe-code audit -skipped. A job that installs the nightly toolchain is exempt — nightly outruns -any released MSRV — which is why `cargo-fuzz` in the fuzz job needs no pin. +skipped. A step that *runs on* a pinned nightly is exempt — nightly outruns any +released MSRV — which is why `cargo-fuzz` needs no pin. + +"Runs on nightly" is a property of the step, not of the job. The toolchain +action dropped its `toolchain:` input, so a job that wants nightly now installs +it alongside a stable default (`rustup toolchain install nightly-...`) and +selects it per command (`cargo +nightly-... fuzz build`). A `cargo install` in +such a job gets the *stable* default unless it opts in, so merely containing a +nightly install no longer exempts a step: it must name the nightly itself, via +`RUSTUP_TOOLCHAIN` on the step or `cargo +nightly-...` in its `run`, either +of which may name the nightly through `${{ env.X }}`. Exempting +per job here would have silently reopened the geiger hole for `cargo-fuzz`. The first attempt at pinning geiger passed `version: 0.13.0`. That action has no `version` input, and GitHub Actions treats an unknown input as a warning @@ -64,7 +74,62 @@ def nightly_toolchain_shas(): return shas -def job_uses_nightly(job, nightly_shas): +# The toolchain action removed its `toolchain:` input, so newer jobs install +# the pinned nightly with an explicit run step instead of a `# nightly`-marked +# action ref. Either spelling marks the job as *having* a nightly available. +RUSTUP_NIGHTLY_INSTALL = re.compile(r'rustup\s+toolchain\s+install\s+\S*nightly') + +# `cargo +nightly-2026-10-30 install ...` — the per-command toolchain selector. +CARGO_PLUS_NIGHTLY = re.compile(r'cargo\s+\+\S*nightly') +# `${{ env.RUST_NIGHTLY }}` — a job naming its nightly through a variable. +ENV_EXPR = re.compile(r'\$\{\{\s*env\.([A-Za-z_][A-Za-z0-9_]*)\s*\}\}') + + +def env_scopes(spec, job, step=None): + """`env` mappings that apply to a step, innermost first.""" + return [ + (step or {}).get('env') or {}, + job.get('env') or {}, + spec.get('env') or {}, + ] + + +def resolve_env(value, scopes): + """`value` with `${{ env.NAME }}` replaced from the first scope defining NAME. + + An unresolved reference is left as written, which keeps `_is_nightly` + false rather than matching the variable's own name: `RUST_NIGHTLY` is not + evidence that what it holds is a nightly. + """ + def sub(match): + name = match.group(1) + for scope in scopes: + if name in scope: + return str(scope[name]) + return match.group(0) + + return ENV_EXPR.sub(sub, value or '') + + +def _is_nightly(value, scopes=()): + return 'nightly' in resolve_env(value, scopes) + + +def job_installs_nightly_via_rustup(spec, job): + for step in job.get('steps') or []: + run = resolve_env(step.get('run') or '', env_scopes(spec, job, step)) + if RUSTUP_NIGHTLY_INSTALL.search(run): + return True + return False + + +def job_default_is_nightly(job, nightly_shas): + """True when the job's *default* toolchain is a nightly. + + Only the old `dtolnay/rust-toolchain@ # nightly` ref does this. The + rustup spelling installs nightly next to the stable default, so commands + there get stable unless they ask for nightly. + """ for step in job.get('steps') or []: uses = step.get('uses') or '' if TOOLCHAIN_ACTION in uses: @@ -74,16 +139,84 @@ def job_uses_nightly(job, nightly_shas): return False +def job_has_nightly(spec, job, nightly_shas): + """True when the job sets up a nightly at all, in either spelling.""" + return job_default_is_nightly(job, nightly_shas) or ( + job_installs_nightly_via_rustup(spec, job) + ) + + +def step_runs_on_nightly(spec, job, step, nightly_shas): + """True when this step's `cargo` resolves to a nightly toolchain.""" + if job_default_is_nightly(job, nightly_shas): + return True + # Opt-in, in the two spellings that actually redirect cargo. Both may name + # the nightly through `${{ env.X }}`, which is how the Pyodide jobs do it. + scopes = env_scopes(spec, job, step) + env = {**(job.get('env') or {}), **(step.get('env') or {})} + if _is_nightly(env.get('RUSTUP_TOOLCHAIN'), scopes): + return True + run = resolve_env(step.get('run') or '', scopes) + return bool(CARGO_PLUS_NIGHTLY.search(run)) + + +def nightly_job_ids(): + """`workflow:job` ids setting up a nightly toolchain, either spelling.""" + shas = nightly_toolchain_shas() + ids = set() + for path in sorted(WORKFLOWS.glob('*.yml')): + spec = yaml.safe_load(path.read_text()) + for job_name, job in (spec.get('jobs') or {}).items(): + if job_has_nightly(spec, job, shas): + ids.add(f'{path.name}:{job_name}') + return ids + + def source_build_steps(): """(workflow, job, step, on_nightly) per source-build action step.""" nightly_shas = nightly_toolchain_shas() for path in sorted(WORKFLOWS.glob('*.yml')): spec = yaml.safe_load(path.read_text()) for job_name, job in (spec.get('jobs') or {}).items(): - on_nightly = job_uses_nightly(job, nightly_shas) for step in job.get('steps') or []: if SOURCE_BUILD_ACTION in (step.get('uses') or ''): - yield path.name, job_name, step, on_nightly + yield ( + path.name, + job_name, + step, + step_runs_on_nightly(spec, job, step, nightly_shas), + ) + + +# `cargo install ` in a `run:` block builds from source just like the +# action does, so it carries the same MSRV hazard and needs the same pin. +CARGO_INSTALL = re.compile( + r'cargo\s+(?:\+\S+\s+)?install\s+(?P[^\n]*)' +) + + +def cargo_install_run_steps(): + """(workflow, job, tool, pinned, on_nightly) per `cargo install` run step.""" + nightly_shas = nightly_toolchain_shas() + for path in sorted(WORKFLOWS.glob('*.yml')): + spec = yaml.safe_load(path.read_text()) + for job_name, job in (spec.get('jobs') or {}).items(): + for step in job.get('steps') or []: + run = step.get('run') or '' + for match in CARGO_INSTALL.finditer(run): + rest = match.group('rest').split() + tools = [arg for arg in rest if not arg.startswith('-')] + if not tools: + continue + tool = tools[0] + pinned = '--version' in rest or '@' in tool + yield ( + path.name, + job_name, + tool, + pinned, + step_runs_on_nightly(spec, job, step, nightly_shas), + ) class PinnedCiToolTests(unittest.TestCase): @@ -93,10 +226,77 @@ def test_discovery_finds_both_kinds_of_job(self): steps = list(source_build_steps()) self.assertTrue(steps, f'no {SOURCE_BUILD_ACTION} steps found') self.assertTrue( - nightly_toolchain_shas(), - f'no `{TOOLCHAIN_ACTION}@ # nightly` ref found; the comment ' - 'spelling this parser relies on may have changed', + nightly_job_ids(), + f'no nightly toolchain install found (neither a ' + f'`{TOOLCHAIN_ACTION}@ # nightly` ref nor a ' + '`rustup toolchain install nightly-...` step); the spelling ' + 'this parser relies on may have changed', ) + self.assertTrue( + list(cargo_install_run_steps()), + 'no `cargo install` run steps found; the spelling this parser ' + 'relies on may have changed', + ) + # The exemption is worth nothing if nothing is ever exempt. + on_nightly = [ + True for *_, nightly in source_build_steps() if nightly + ] + [True for *_, nightly in cargo_install_run_steps() if nightly] + self.assertTrue( + on_nightly, + 'no source-built tool runs on nightly; the opt-in spellings ' + '(`RUSTUP_TOOLCHAIN`, `cargo +nightly-...`) may have changed', + ) + + def test_cargo_install_on_the_pinned_toolchain_pins_a_version(self): + # Same hazard as the action, different spelling: an unpinned + # `cargo install` on the pinned stable resolves to the newest release. + for workflow, job, tool, pinned, on_nightly in cargo_install_run_steps(): + if on_nightly: + continue + with self.subTest(workflow=workflow, job=job, tool=tool): + self.assertTrue( + pinned, + f'{workflow}:{job} runs `cargo install {tool}` on the ' + 'pinned toolchain with no version; pass `--version ` ' + 'or run it on the nightly (`cargo +nightly-... install`) ' + 'so an upstream MSRV bump cannot break a tree that has ' + 'not changed', + ) + + def test_the_detector_follows_an_env_indirection(self): + # A job can name its nightly through a variable: the Pyodide jobs run + # `rustup toolchain install ${{ env.RUST_NIGHTLY }}` and set + # `RUSTUP_TOOLCHAIN` to the same expression — the very route this + # file treats as an opt-in. Matching only a literal `nightly` token + # called those jobs non-nightly, so a source build added there would + # be asked to pin a tool that is already on a nightly. Every job that + # installs a toolchain through rustup must be discovered. + shas = nightly_toolchain_shas() + checked = 0 + for path in sorted(WORKFLOWS.glob('*.yml')): + spec = yaml.safe_load(path.read_text()) + for job_name, job in (spec.get('jobs') or {}).items(): + installs = [ + step for step in job.get('steps') or [] + if 'rustup toolchain install' in (step.get('run') or '') + ] + if not installs: + continue + checked += 1 + with self.subTest(workflow=path.name, job=job_name): + self.assertTrue( + job_has_nightly(spec, job, shas), + f'{path.name}:{job_name} installs a toolchain via rustup ' + 'but the detector does not see a nightly', + ) + for step in installs: + self.assertTrue( + step_runs_on_nightly(spec, job, step, shas) + or not (step.get('env') or {}).get('RUSTUP_TOOLCHAIN'), + 'a step pinning RUSTUP_TOOLCHAIN to this job\'s nightly ' + 'must count as running on it', + ) + self.assertGreaterEqual(checked, 4, 'rustup install jobs not found') def test_tools_on_the_pinned_toolchain_pin_a_version(self): for workflow, job, step, on_nightly in source_build_steps():