From a004f85a9aed6a538262ef76fdca0828e8d0a872 Mon Sep 17 00:00:00 2001 From: forkwright Date: Tue, 25 Aug 2026 16:54:17 -0500 Subject: [PATCH] fix(gate): skip the Rust build cache on a repo with no Cargo manifest Swatinem/rust-cache shells out to `cargo metadata`, which fails outright where there is no Cargo.toml: `error: could not find Cargo.toml`. The step ran unconditionally, so it failed the whole gate for a cache it could never have populated. Not every consumer of this gate is a Rust repo. typikon passes `true` for fmt, clippy and nextest and uses check_cmd for its own non-Rust checks -- deliberately, with a comment saying so -- and has no Cargo.toml anywhere in its tree. Its gate has been failing on this step rather than on anything it actually checks. The guard is a positive test for what the cache needs, so a repo that gains Rust later picks the cache back up with no further change, and a repo that never had it stops being asked for one. Both event-shape checkers still pass: gate evaluation 10/10, and 16 pull_request-only values examined with none reaching git unguarded. --- .github/workflows/hybrid-gate.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.github/workflows/hybrid-gate.yml b/.github/workflows/hybrid-gate.yml index d2b395e..0d86003 100644 --- a/.github/workflows/hybrid-gate.yml +++ b/.github/workflows/hybrid-gate.yml @@ -314,7 +314,23 @@ jobs: components: rustfmt, clippy cache: false + # WHY guarded: rust-cache shells out to `cargo metadata`, which fails outright on a + # repo with no Cargo.toml -- `error: could not find Cargo.toml`. Consumers of this gate + # are not all Rust repos: several pass `true` for fmt/clippy/nextest and use check_cmd + # for their own non-Rust checks, which works fine until this step runs unasked and + # fails the whole job for a cache it could never have populated. + - name: Detect a Cargo manifest + id: cargo-manifest + run: | + if [ -f Cargo.toml ]; then + echo "present=true" >> "$GITHUB_OUTPUT" + else + echo "present=false" >> "$GITHUB_OUTPUT" + echo "no Cargo.toml at the repo root; skipping the Rust build cache" + fi + - uses: Swatinem/rust-cache@f0d9c3887740aee45f6153b24b3a6b815192ec16 # v2 + if: steps.cargo-manifest.outputs.present == 'true' with: key: ${{ inputs.rust_cache_key }}