-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Feature request: option to update cache #342
Comments
I'm having this issue when trying to use @actions/cache for reducing update time of the built-in MSYS2 installation on As commented in msys2/setup-msys2#23, I'm trying to save
Then, I tried using the npm package: https://www.npmjs.com/package/@actions/cache. Unfortunately, it fails: https://github.com/eine/setup-msys2/runs/738298072?check_suite_focus=true#step:4:116
As an alternative to updating an existing key, it would be feasible to remove it explicitly (ref #340). |
This would also be super handy for persisting the test cache when using GitHub Actions in go projects. For example, I could download the latest test cache, run my tests then update the existing cache with the results of the tests in the current run. This way, I can have a global test cache across all my workflow runs. |
This also applies to things like webpack loader cache, small, have their own key management, needs to be updated each time |
This would be super valuable for monorepo's where each subproject has its own dependencies it wants to cache and build so that upstream projects have faster build times. I ran into the expectation that this was already the default behavior - so I wrote #392 under that assumption |
Is there any workaround for forcing the update of the cache even on a hit? I can't think of any way... |
Maybe save as |
@Vampire that's brilliant, thanks mate! You are right, forgot about the pattern matching that the cache finding does. Perhaps this is then a non-issue and your solution is the intended way of doing things? |
Nah, that's merely a work-around. |
@HebaruSan It won't save anything at all. |
Duplicate of #171 |
If a given cache key already exists, the cache action will not update the cache, even if the cached files have changed. See actions/cache#342 for discussion. The workaround is to change the cache key every day but to have a restore key which is not date-specific. See actions/cache#342 (comment).
If a given cache key already exists, the cache action will not update the cache, even if the cached files have changed. See actions/cache#342 for discussion. The workaround is to change the cache key every day but to have a restore key which is not date-specific. See actions/cache#342 (comment).
If a given cache key already exists, the cache action will not update the cache, even if the cached files have changed. See actions/cache#342 for discussion. The workaround is to change the cache key every day but to have a restore key which is not date-specific. See actions/cache#342 (comment).
If a given cache key already exists, the cache action will not update the cache, even if the cached files have changed. See actions/cache#342 for discussion. The workaround is to change the cache key every day but to have a restore key which is not date-specific. See actions/cache#342 (comment).
For anyone performing the cache-sha:
# Caches the SHA of the last successful build
runs-on: ubuntu-latest
steps:
- name: Clear cache
continue-on-error: true # Don't fail if the cache doesn't exist
env:
GH_TOKEN: ${{ github.token }} # required by gh
run: |
gh extension install actions/gh-actions-cache
gh actions-cache delete ${{ env.CACHE_NAME }} --confirm -R ${{ github.repository }} |
FYI when using the cache deletion trick and getting |
Hey @bethanyj28, what's the reason such a feature has not been shipped yet? It is built-in in Gitlab, etc. It is the 2nd top most requested. And it seems it is doable (they are workarounds but cumbersome) |
Github does not override our cache, so we instead provide a restore-key prefix, which lets us pick the latest of the caches that were stored Ref: actions/cache#342 (comment)
Github does not override our cache, so we instead provide a restore-key prefix, which lets us pick the latest of the caches that were stored Ref: actions/cache#342 (comment)
Github does not override our cache, so we instead provide a restore-key prefix, which lets us pick the latest of the caches that were stored Ref: actions/cache#342 (comment)
Build times are increasing faster than I expected, so it's clear that to be effective the ccache needs to be kept up to date. This needs to happen automatically so we can forget about it. Github caching behaviour is to fail the save operation if a hit occurred on primary key. In other words, a cache entry will never be overwritten (updated). There is no provision for a cache update as such: actions/cache#342 The workaround is fairly easy though: break into discrete restore/delete/save steps. Only the cache for the current branch is deleted, using the `--branch` option to `gh action-cache delete`. This prevents pull requests from contributors with repo write access from deleting the main `develop` cache. This table shows the intended progression of cache updates, starting from an empty cache: | Event | Branch | Restore | Delete | Save | | ------- | ------------ | -------- | ------- | ------------ | | PR | feature/new | - | - | feature/new | | PR | feature/new | feature/new | - | - | | Merge | develop | - | - | develop | | PR | fix/lwip | develop | - | - | | Merge | develop | develop | develop | develop | So always save if (event.branch == develop) or no cache hit
- Implement workarounds in actions/cache#342 involving overwriting Github Actions cache data - This was, we still have one cache, but it can now be appended with the cache data of all the versions - Concurrency Group added, serializing the main workflow rather than doing parallel jobs, but will lead to faster times long-term thanks to a working cache - Fixed a potential ordering issue, by placing the Gradle Daemon Stopping before Artifact uploading
mutable cache that exists just during single run of workflow would be awesome option. our workaround was: to create one more cache file. |
@romani you can use artifacts for that too, just overwrite the existing one and cache it in the last job to make it permanent across workflows (if desired). |
Nuance is that in our case we do not want to share some files after workflow ended. |
Problem Description
Currently, the cache action either restores an existing cache on cache-hit, or generates a missing cache on cache-miss. It does not update the cache on cache-hit.
This works well for caching static dependencies, but not for caching build artefacts.
Proposed Solution
Add an option allowing the user to enable cache updates.
This should be
false
by default to retain backwards-compatibility.Motivation
Some programming languages benefit greatly from build caching. C++ in conjunction with ccache is the prime example. Using caching commonly decreases compilation times by at least 70%. Medium-sized projects easily take 20 minutes to compile.
ccache also manages the cache size itself and automatically removes obsolete entries, thus the cache won't explode with continuous updates.
It also saves time and money for both user and provider. The environment will be happy too.
The text was updated successfully, but these errors were encountered: