Conversation
Adds caching of the dependency crates Cargo downloads each time it would do a first compile on a new platform. Includes crates.io index. This also ensures the exact same crate versions are used in each job since cargo.lock is only generated once per workflow. Since we don't currently cache the target/ directory we also set CARGO_INCREMENTAL to 0. This gives a small compile speed boost.
|
Investigating why clippy is failing. Didn't during testing. Edit: |
|
I found during some testing that it might still download some crates in the main jobs. But it seems to only happen on windows. Edit: Also we now update to latest rust before fetching deps. |
Temporary workaround for cache miss on Windows because of the different compression algorithm. When Zstd gets fixed on windows this can be run just on ubuntu. Also we now update to latest rust before fetching deps.
|
Having second thoughts on caching only the download dependency crates this way. I do think the approach of generating Cargo.lock in one job and then sharing that in the other jobs has some value tho. |
This PR picks up from #1086.
Credit to @justinmoon for inspiring me to look into github caching and the workings of cargo. Learned a lot 😁
This adds caching of the dependency crates and crates.io index that are currently downloaded each time a job starts.
A separate update-deps job have been added where the crates will be cached and shared between the rest of the jobs.
If the dependencies change then the cache will be updated.
This has the extra benefit that we ensure each job in a workflow use the exact same dependency versions even if an update got pushed while the CI was setting up the different jobs.
The cache hit might miss on windows currently since it uses a different compression algorithm due to a bug. Will hopefully get fixed on it's own.
Since we currently don't cache the build target we can also get a small compile speed boost by setting CARGO_INCREMENTAL to 0.
Caching of the build target will be a separate PR since it is a bit more complicated to do properly with the large build sizes and the need to clean old build artifacts.
The code is heavily inspired from the Testing a library example in this PR. So also credit to @mzabaluev
Tho i have decided against having a separate cache for the crates.io index as shown in the example.
I don't think the double digit savings in seconds by not downloading the full index each workflow is worth the extra lines of code it would add.