Skip to content

Conversation

@kornelski
Copy link
Member

@kornelski kornelski commented Nov 15, 2025

Excludes more irrelevant/redundant CARGO_ variables based on a blocklist

(Another option could be to remove hashing of the CARGO_ variables completely — #2494)

@codecov-commenter
Copy link

codecov-commenter commented Nov 15, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.05%. Comparing base (1332701) to head (971b4e0).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2495   +/-   ##
=======================================
  Coverage   71.05%   71.05%           
=======================================
  Files          64       64           
  Lines       35359    35364    +5     
=======================================
+ Hits        25124    25129    +5     
  Misses      10235    10235           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator

@Xuanwo Xuanwo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this change!

@sylvestre
Copy link
Collaborator

would it be possible to have a test?

Comment on lines +1521 to +1533
let may_skip = var == "CARGO_MAKEFLAGS" // will have jobserver info which is extremely non-cacheable.
|| var == "CARGO_BUILD_JOBS" // does not affect results
|| var.starts_with("CARGO_REGISTRIES_") // CARGO_REGISTRIES_*_TOKEN contains non-cacheable secrets, and package IDs already uniquely identify the relevant registries.
|| var.starts_with("CARGO_REGISTRY_") // same as CARGO_REGISTRIES_*
|| var == "CARGO_TARGET_DIR" // already included in the file paths
|| var == "CARGO_BUILD_BUILD_DIR"
|| var == "CARGO_BUILD_TARGET_DIR"
|| var.starts_with("CARGO_HTTP_") // not relevant
|| var.starts_with("CARGO_NET_")
|| var.starts_with("CARGO_TERM_")
|| var.starts_with("CARGO_ALIAS_")
|| var == "CARGO_CACHE_AUTO_CLEAN_FREQUENCY";
if may_skip {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe something like:

Suggested change
let may_skip = var == "CARGO_MAKEFLAGS" // will have jobserver info which is extremely non-cacheable.
|| var == "CARGO_BUILD_JOBS" // does not affect results
|| var.starts_with("CARGO_REGISTRIES_") // CARGO_REGISTRIES_*_TOKEN contains non-cacheable secrets, and package IDs already uniquely identify the relevant registries.
|| var.starts_with("CARGO_REGISTRY_") // same as CARGO_REGISTRIES_*
|| var == "CARGO_TARGET_DIR" // already included in the file paths
|| var == "CARGO_BUILD_BUILD_DIR"
|| var == "CARGO_BUILD_TARGET_DIR"
|| var.starts_with("CARGO_HTTP_") // not relevant
|| var.starts_with("CARGO_NET_")
|| var.starts_with("CARGO_TERM_")
|| var.starts_with("CARGO_ALIAS_")
|| var == "CARGO_CACHE_AUTO_CLEAN_FREQUENCY";
if may_skip {
// Skip environment variables that shouldn't affect caching
const CARGO_SKIP_VARS: &[&str] = &[
"CARGO_MAKEFLAGS", // jobserver info which is extremely non-cacheable
"CARGO_BUILD_JOBS", // does not affect results
"CARGO_TARGET_DIR", // already included in the file paths
"CARGO_BUILD_BUILD_DIR",
"CARGO_BUILD_TARGET_DIR",
"CARGO_CACHE_AUTO_CLEAN_FREQUENCY",
];
const CARGO_SKIP_PREFIXES: &[&str] = &[
"CARGO_REGISTRIES_", // contains non-cacheable secrets, package IDs already identify registries
"CARGO_REGISTRY_", // same as CARGO_REGISTRIES_*
"CARGO_HTTP_", // not relevant
"CARGO_NET_",
"CARGO_TERM_",
"CARGO_ALIAS_",
];
let may_skip = CARGO_SKIP_VARS.contains(&var.as_str())
|| CARGO_SKIP_PREFIXES
.iter()
.any(|prefix| var.starts_with(prefix));
if may_skip {

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.

4 participants