-
Notifications
You must be signed in to change notification settings - Fork 534
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
Cache go install
-ed binaries
#483
Comments
Hello @SirSova |
I don't know what |
So if I run go install github.com/mfridman/[email protected]
go test -json ./... | tparse -all It will download and build |
I have been experimenting using https://github.com/actions/cache and got some good performance results by caching |
Even through I would love to have this feature build in into this action, I honestly think it's not the responsibility of this action to cache such things. This action is designed to install go, not more. What you're doing with go is not really part of this action. Is it? 🤔 |
|
I tend to agree that caching should not be in scope of I think the most important thing is that only safe things should be cached and I don't know how safe it is to cache these go directories. There could always be undiscovered cache invalidation bugs in golang. |
I too would appreciate this feature. Even if it just cached the dependencies for something that was I'm a bit confused/ignorant as to why this isn't happening already. I have multiple workflows that run at the same time on the same commit, is it that the first run that completes doesn't contain the cached modules in |
@silverwind can you share your solution in the mean time, while this issue is being decided/worked on ? |
Here is what I have been experimenting with and it seemed to work. The cache key surely is too aggressive and GOVERSION and go.mod hash can likely be removed. - uses: actions/setup-go@v5
with:
go-version-file: go.mod
check-latest: true
- id: vars
run: |
echo "GOCACHE=$(go env GOCACHE)" >> "$GITHUB_OUTPUT"
echo "GOMODCACHE=$(go env GOMODCACHE)" >> "$GITHUB_OUTPUT"
echo "GOVERSION=$(go env GOVERSION)" >> "$GITHUB_OUTPUT"
- uses: actions/cache/restore@v4
with:
path: |
${{ steps.vars.outputs.GOCACHE }}
${{ steps.vars.outputs.GOMODCACHE }}
key: golint-v1-${{ github.job }}-${{ runner.os }}-${{ runner.arch }}-${{ steps.vars.outputs.GOVERSION }}-${{ hashFiles('go.mod') }}
- run: make lint
- uses: actions/cache/save@v4
with:
path: |
${{ steps.vars.outputs.GOCACHE }}
${{ steps.vars.outputs.GOMODCACHE }}
key: golint-v1-${{ github.job }}-${{ runner.os }}-${{ runner.arch }}-${{ steps.vars.outputs.GOVERSION }}-${{ hashFiles('go.mod') }} |
@silverwind thanks for sharing! That seems to work for me, although the I was able to achieve similar results by adding my
|
Running
will create a binary named |
The trick there is to allow the user to define a cache key that is generated from the script that contain |
I suppose Go install verify the version of the binary using My working workflow with cache binaries:
Also good to notice. P.S: I want to replace
|
|
The first run of P.S: I see also significant difference if I use "latest" vs specific version. |
Since go 1.16, you can use |
yes, you can specify version, but after the install no way to get that. |
Description:
Cache
go install
-ed binaries (optionally I suppose) along with go mod dependencies. Store$GOBIN
folder with all installed during workflow execution binaries on post step (cache save).Justification:
In my scenario, I use
tparse
tool to prettify tests results. I can imagine other cases such as code generator tools. Basically pre-run/post-run scripts. For now, I turned off the cache option of this action and wrote my own usingaction/cache
, but it adds significant complexity to keep it around multiple workflows the same way.Are you willing to submit a PR?
Sure, as soon as the feature is approved.
The text was updated successfully, but these errors were encountered: