coursier / cache-action Goto Github PK
View Code? Open in Web Editor NEWGitHub action to save / restore the coursier cache of your build
License: MIT License
GitHub action to save / restore the coursier cache of your build
License: MIT License
Currently actions/cache
doesn't support manual cache invalidation from GitHub's UI: actions/cache#2
Before the GitHub team implement this feature, coursier/cache-action
could implement a workaround trick described in
actions/cache#2 (comment)
It looks that after upgrading from coursier/cache-action@v3
to v4
there is some problem that makes cache restore failure.
With v4 lot of dependencies are always downloaded and sbt-ivy2-cache cache not found
error is produced
coursier/cache-action@v4
output:
Run coursier/cache-action@v4
/bin/uname -s
Linux
Received 60583331 of 60583331 (100.0%), 122.4 MBs/sec
Cache Size: ~58 MB (60583331 B)
/bin/tar --use-compress-program zstd -d -xf /home/runner/work/_temp/1e9e417e-d565-433d-8aad-b175b1c3e3eb/cache.tzst -P -C /home/runner/work/project/project
coursier cache restored from key Linux-coursier-4de5856a70311a16d18c97754ced62ce52e589c7
sbt-ivy2-cache cache not found
...
[sbt logs shows here lot of dependecies downloads]
...
Post Run coursier/cache-action@v4
Post job cleanup.
Cache hit occurred on key Linux-coursier-4de5856a70311a16d18c97754ced62ce52e589c7, not saving coursier cache.
With v3 everything seems to work as expected
coursier/cache-action@v3
output:
Run coursier/cache-action@v3
/bin/uname -s
Linux
Received 60583331 of 60583331 (100.0%), 112.2 MBs/sec
Cache Size: ~58 MB (60583331 B)
/bin/tar --use-compress-program zstd -d -xf /home/runner/work/_temp/7fe01672-eac7-493a-8d58-cebd8850d80a/cache.tzst -P -C /home/runner/work/project/project
coursier cache restored from key Linux-coursier-4de5856a70311a16d18c97754ced62ce52e589c7
Received 54312530 of 54312530 (100.0%), 105.9 MBs/sec
Cache Size: ~52 MB (54312530 B)
/bin/tar --use-compress-program zstd -d -xf /home/runner/work/_temp/e6d4c9de-0e6b-49e1-b4d3-7d26ab113c71/cache.tzst -P -C /home/runner/work/project/project
sbt cache restored from key Linux-sbt-4de5856a70311a16d18c97754ced62ce52e589c7
...
[sbt logs shows here no dependecies downloads]
...
Post Run coursier/cache-action@v3
Cache hit occurred on key Linux-sbt-4de5856a70311a16d18c97754ced62ce52e589c7, not saving sbt cache.
Post job cleanup.
Cache hit occurred on key Linux-coursier-4de5856a70311a16d18c97754ced62ce52e589c7, not saving coursier cache.
Cache hit occurred on key Linux-sbt-4de5856a70311a16d18c97754ced62ce52e589c7, not saving sbt cache.
Could it be key sbt
key has changed and it's not found anymore or something related?
Thanks for the great project! I'm using it for all my projects.
Currently, on the actions page GitHub shows the following warning:
Node.js 16 actions are deprecated. Please update the following actions to use Node.js 20: coursier/cache-action@v6. For more information see: https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/.
The current behaviour of the cache is to fallback to a different cache key on cache miss. It would be good if this behaviour could be disabled, or if the user could define a cache key prefix which applies to all cache keys.
The main driver behind this is avoiding unnecessary downloads / uploads for repos that have multiple builds, with some having only a handful of dependencies or different scala versions
coursier cache keys:
coursier-lint-scala-code-475cd933d4d254d8267377454164c8ad6db554de
coursier-lint-scala-code-
coursier-
< Cache download logs >
Cache restored successfully
coursier cache miss, fell back on coursier-build-b930455d2f9b4f12b182a5c0f86b8680b4479aed.
coursier cache will be saved in post run job.
I'm happy to contribute if you agree with adding this feature but don't have the capacity to work on it at the moment - might need a nudge in the right direction though
Actions using Node 12 are considered deprecated and encouraged to upgrade to Node 16.
For reference: https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/
I wonder if all that is needed is just changing this line.
runs:
- using: 'node12'
+ using: 'node16'
main: 'dist/restore/index.js'
post: 'dist/save/index.js'
post-if: 'success()'
And refreshing the package-lock.json
using Node 16.
If so, I am more than happy to help.
But, if something else is required I would need assistance / guidance.
See also: coursier/setup-action#281
actions/cache
does set the output cache-hit
if the cache was hit. Have a look at the docs: https://github.com/actions/cache#skipping-steps-based-on-cache-hit
Can we have the same here?
Looking at the implementation of actions/cache
that shouldn't be too hard:
We would need an output for each cache however:
cache-hit-coursier
cache-hit-sbt-ivy2-cache
cache-hit-mill
cache-hit-ammonite
Based on the referenced example, we could for example:
...
if: steps.cache.outputs.cache-hit-coursier != 'true'
...
scalameta/metals#2608 (comment)
Post job cleanup.
coursier cache key:
coursier-unit-matrix-c72830702e1d2b18a132b9d6e3742571e19e9466-33aa363d8c15033b2a8ed0d8c299d77f17660736
Saving coursier cache
C:\windows\System32\tar.exe --posix -z -cf cache.tgz -P -C D:/a/metals/metals --files-from manifest.txt
Warning: Cache service responded with 429 during upload chunk.
sbt-ivy2-cache cache key:
sbt-ivy2-cache-unit-matrix-c72830702e1d2b18a132b9d6e3742571e19e9466-57ca911780629f6d13612b672c8a32e66547f7b0
Saving sbt-ivy2-cache cache
D:\a\_actions\coursier\cache-action\v6\dist\node_modules\@actions\cache\lib\internal\cacheHttpClient.js:177
autoClose: false
^
Error: Cache upload failed because file read failed with EBADF: bad file descriptor, read
at ReadStream.<anonymous> (D:\a\_actions\coursier\cache-action\v6\dist\node_modules\@actions\cache\lib\internal\cacheHttpClient.js:177:1)
at ReadStream.emit (events.js:210:5)
at internal/fs/streams.js:167:12
at FSReqCallback.wrapper [as oncomplete] (fs.js:470:5)
We're using coursier/cache-action@v5
: https://github.com/zio/zio-telemetry/blob/master/.github/workflows/ci.yml#L46
In the Post Cache scala dependencies
step, we're seeing suspicious warnings:
Post job cleanup.
Saving coursier cache
Warning: reserveCache failed: Cache already exists. Scope: refs/heads/master, Key: Linux-coursier-3079bd8f16e7a25e57b7c35b9b13090eb7092b1f, Version: 1e08b80f3462916ac2d5654f6b399c900980cc0f9b928b367a6df70ad7ddd959
Saving sbt-ivy2-cache cache
Warning: reserveCache failed: Cache already exists. Scope: refs/heads/master, Key: Linux-sbt-ivy2-cache-91f8e0fa8ca1f9c6c77811374a8bcb945b2387c8, Version: 9635c9698008b57d9157eed8e70fa13373c2bf90a51d9edde39fe4b528f54439
https://github.com/zio/zio-telemetry/runs/1797302607?check_suite_focus=true#step:9:3
Is this an expected behavior? The fact that it's a warning makes us not 100% sure that we're using coursier/cache-action
correctly.
/cc @mijicd
According to the GitHub Actions toolkit versioning recommendations (https://github.com/actions/toolkit/blob/master/docs/action-versioning.md#recommendations), major version tags should be moved to point to the ref of the current release. This would allow anyone binding to v6 to get the latest fixes, while others could bind to something like 6.1
if they need a specific commit.
For this repo, this would also require what is currently v6
to be renamed to v6.0
so that v6
can move to the latest version.
Both mill script in mill repository and millw use ~/.cache/mill
instead of ~/.mill
to save their binaries these days.
I think the action should reflect that.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.