Skip to content

ci: extract the cargo cache block into a composite action - #692

Merged
jdrouet merged 1 commit into
mainfrom
ci/cargo-cache-action
Sep 13, 2026
Merged

jdrouet merged 1 commit into
mainfrom
ci/cargo-cache-action

Conversation

@jdrouet

@jdrouet jdrouet commented Sep 13, 2026

Copy link
Copy Markdown
Owner

The same actions/cache@v6 block — five cargo/target paths — is copy-pasted nine times across eight workflows. Only the key name differs, and every key already has the shape ${{ runner.os }}-<name>-${{ hashFiles('**/Cargo.lock') }}.

One local composite action at .github/actions/cargo-cache with a name input replaces all nine. 72 lines out, 18 in across the workflows, plus the 18-line action: net about 36 lines, and one place to change the cached paths instead of nine.

Cache keys are unchanged, all nine. That is the thing worth checking here: a changed key does not fail CI, it just silently throws away the cache and everything gets slower. I verified it mechanically rather than by eye — parsing each workflow, substituting the name input into the action's template, and comparing against the key string on main. All nine match character for character.

That includes exampl-axum-testing in example-axum.yml, which is a pre-existing typo. I kept it: fixing it would change the key and discard that cache. Worth fixing on its own some time, when losing one cache entry is the intended cost.

The toolchain step is deliberately not folded in. Nine workflows want dtolnay/rust-toolchain@stable and code-checking.yml wants @nightly with components: rustfmt,clippy; parameterizing that would mean pinning @master and passing the toolchain as an input, which is weaker than the version-pinned refs in use today. It is one line per workflow already.

Local checks can only prove the YAML parses (all 16 workflows plus the action do) and that every site is preceded by actions/checkout, which a local composite action needs. Whether the caches actually restore is what this PR's own CI run shows.

Touches mrml-cli-main.yml, so it will want a rebase if #687 lands first.

Signed-off-by: Jeremie Drouet <jeremie.drouet@gmail.com>
@github-actions

Copy link
Copy Markdown
Contributor

📈 This is how your metrics evolved 📉


@jdrouet
jdrouet merged commit c608841 into main Sep 13, 2026
12 checks passed
@jdrouet
jdrouet deleted the ci/cargo-cache-action branch September 13, 2026 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant