Swatinem / rust-cache

A GitHub Action that implements smart caching for rust/cargo projects
GNU Lesser General Public License v3.0
1.32k stars 109 forks source link

Ignore `CARGO_TERM_COLOR` as an env var cache key. #87

Open vorporeal opened 2 years ago

vorporeal commented 2 years ago

This variable, while starting with CARGO_, doesn't have any impact on compilation output, just what cargo prints to stdout/stderr, and as such, shouldn't factor into the cache key at all.

Swatinem commented 2 years ago

You are right. On the other hand, if you just set it once, and never change it, it does not matter at all either 🤷🏻‍♂️

vorporeal commented 2 years ago

True!

The issue I encountered was that I added that environment variable to our CI workflow but not a separate workflow that runs against our main branch to populate the cache (so that the cache is shared across feature branches) and it, unexpectedly, led to our main branch cache having a cache key that didn't get matched by feature branch caches.

The context is that I migrated our CI to use nextest, which recommends setting CARGO_TERM_COLOR: always in your CI jobs for more readable output. Despite being the individual on our team with the most context around our use of the rust-cache action, I did not expect this environment variable to have any effect on cache keys.

Our caching was "broken" for a couple weeks before I got lucky and noticed the issue.

While it won't affect me again in the future, it could certainly catch other users by surprise.

lebensterben commented 1 year ago

I second this request.