-
-
Notifications
You must be signed in to change notification settings - Fork 15
Caching tracking issue #21
Comments
In rust-analyzer, we remove artifacts for the workspace-local files before the cache stores. While this isn't required to reduce cache churn like it does on auto-keyed caching (e.g. Travis) (as a matching key will not store the cache), it does still reduce cache sizes. If actions-rs ever provides a "best practice" caching wrapper, it should probably allow scrubbing these files, so only dependencies' artifacts are cached. (Specifically, scrubbing files directly in |
@CAD97 noted, thank you! I do want to create some kind of |
Lucky timing, but looks like a few hours before I came across this issue someone posted a possible workaround to the upstream issue: actions/cache#55 (comment). Also worth noting that in addition to the target/ directory examples, currently I have these cache keys set up in my jobs: - name: cache cargo index
uses: actions/cache@v1
with:
path: ~/.cargo/git
key: cargo-index-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
cargo-index-
- name: cache cargo registry
uses: actions/cache@v1
with:
path: ~/.cargo/registry
key: cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
cargo-registry- |
There is an initial version of |
One problem with using a hash of I have developed a workflow solution that maintains a |
This is true, but I both do and don't understand why it's the case. If you're caching the build anyway, you're (probably) going to be caching a Cargo.lock anyway. Committing a Cargo.lock for a library is good for libraries imho for the exact same reasons it would be good for binaries.
You probably want So I think there are two useful "simple enough" behaviors here:
And the idealized verison of the second case, which I don't think is (or will be in the near future) possible:
Personally, I think checking in lockfiles is the better plan, even for libraries, because it makes CI builds more deterministic, and less likely to break because of the outside world. I never want to be in a situation where CI passed on the head, but a PR fails due to no fault of its own, just because a library updated in a minorly breaking way. Rather, I think the better model is to put the |
That command needs at least
A full restoration including the repository index is long and getting longer as the index is growing.
With a close enough state of the registry restored from the cache, there is not much to synchronize. A job in the workflow can perform
One current problem with this is the lack of an easy way to prune the outdated dependencies. There is a
It may be good for reproducible CI builds, but for regular developer working copies of library code a version-controlled Checking the baseline lockfile into a CI-managed branch away from the branch(es) that get checked out by developers could be a way to get the best of both worlds. |
For reference, here's a workflow using two stages of caching. First, a job runs Some follow-up on my earlier comments:
The |
More observations on
|
Looks like the npm package for making use of the cache actions from other actions has released: https://github.blog/changelog/2020-05-27-github-actions-v2-cache-actions/. |
👋 Reaching out here, since I have created https://github.com/Swatinem/rust-cache and we have been successfully test-driving it for a few sentry projects. So far its very opinionated with regards to how I think caching should ideally work, but I’m open to ideas. |
For tools specifically, https://github.com/actions/toolkit/tree/main/packages/tool-cache exists now and seems useful. |
This will (eventually) give us a huge build time boost when actions-rs/meta#21 is implemented.
There are two things that can be improved with caching added:
target/
and Cargo folders (see an example)cargo install {pkgid}
commandRight now this affects the following workflows:
actions-rs/cargo
withuse-cross: true
input enabled (cross
is compiled on each call)This issue can be solved by a proper implementation of the
actions-rs/core/Cargo.installCached
function, see actions-rs/core#31, but it is blocked by actions/cache#55Right now this issue acts only as a tracking issue for a possibility of proper caching implementation.
The text was updated successfully, but these errors were encountered: