Open lopopolo opened 4 years ago
I feel like at this point it would be easier to use https://github.com/actions/cache (see an example), but yes, adding the sccache
support would be nice.
But, same to #15, this thing is blocked by #21.
actions/cache
doesn't support sharing build cache between multiple Cargo workspaces: https://doc.rust-lang.org/cargo/guide/build-cache.html#shared-cache
Persisting an on-disk sccache cache directory via GitHub Actions' caching mechanism mostly defeats the purpose of using sccache. For CI, sccache can be pointed at a cloud storage bucket as the cache location, and it will fetch cached outputs as needed, as well as upload build outputs for cache misses. This bucket can be shared across branches and build configurations, since sccache is careful to include all build inputs when calculating a cache key.
An on-disk cache directory can be size-limited, but to get a reasonable hit rate that still means you're likely to accumulate a large number of object files which your CI will waste time downloading and uploading, instead of allowing sccache to fetch and store only the build outputs required for the current build.
On CircleCI I make use of sccache on Debian and Windows and it speeds up my builds significantly.
sccache is a
RUSTC_WRAPPER
that supports caching crates across builds to a on-disk cache that can be limited in size.I install it on Linux like: https://github.com/artichoke/artichoke/blob/95a94f82326561914e27aac9c14f606aed01c8b1/.circleci/config.yml#L18-L26
and on Windows like: https://github.com/artichoke/artichoke/blob/95a94f82326561914e27aac9c14f606aed01c8b1/.circleci/config.yml#L56-L63
The cache is restored at the beginning of a build like: https://github.com/artichoke/artichoke/blob/95a94f82326561914e27aac9c14f606aed01c8b1/.circleci/config.yml#L137-L139
and saved at the end of a build like: https://github.com/artichoke/artichoke/blob/95a94f82326561914e27aac9c14f606aed01c8b1/.circleci/config.yml#L158-L162