-
Notifications
You must be signed in to change notification settings - Fork 621
Avoid hashing CARGO_ variables that are redundant/unrelated #2495
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
Xuanwo
left a comment
There was a problem hiding this 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!
|
would it be possible to have a test? |
| 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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe something like:
| 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 { |
Excludes more irrelevant/redundant
CARGO_variables based on a blocklist(Another option could be to remove hashing of the
CARGO_variables completely — #2494)