Repository navigation
ci: extract the cargo cache block into a composite action - #692
Merged
Merged
Conversation
Signed-off-by: Jeremie Drouet <jeremie.drouet@gmail.com>
Contributor
|
📈 This is how your metrics evolved 📉 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The same
actions/cache@v6block — 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-cachewith anameinput 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
nameinput into the action's template, and comparing against the key string onmain. All nine match character for character.That includes
exampl-axum-testingin 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@stableand code-checking.yml wants@nightlywithcomponents: rustfmt,clippy; parameterizing that would mean pinning@masterand 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.