Skip to content
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

Why can't I re-use cache created by actions/setup-go for actions/cache? #480

Closed
2 of 5 tasks
sswastioyono18 opened this issue May 18, 2024 · 3 comments
Closed
2 of 5 tasks
Assignees
Labels
bug Something isn't working

Comments

@sswastioyono18
Copy link

sswastioyono18 commented May 18, 2024

Description:
Hi, we are using ARC self hosted runner.
Currently we are evaluating whether we should cache from actions/setup-go or actions/cache by using restore and save.

actions/setup-go seems very good after the first build but we wanted to use the fallback to default option set from actions/cache.
We prefer the cache to be created by setup-go because we noticed during go test command, we realized if we use cache from setup-go, unit test seems run very fast while if we use cache from actions/cache, somehow we have to wait 1.5 mins for the test to start.

So our idea to combine setup-go and actions/cache was to have daily job using setup-go for populating the cache while for usual task, we use actions/cache to only restore the cache and fallback to whatever cache it has.

Now the problem we faced is that it seems like cache key created in master branch by setup-go cannot be reused by actions/cache in feature branch.
image

but when I run the feature branch action, it said it cannot find the cache with key created by actions/setup-go in master
image

it looks like both actions/cache and actions/setup-go have hidden identifier key even though it looks the same (?)
looking at the source code of setup-go, the underlying cache creation seems to use actions/cache.so this should work as expected.

Action version:
v5

Platform:

  • Ubuntu
  • macOS
  • Windows

Runner type:

  • Hosted
  • Self-hosted

Tools version:

Repro steps:

  • Run setup-go with cache in master
  • create feature branch and run the job that involve actions/cache
  • cache key cannot be found

Expected behavior:
cache key can be found

Actual behavior:
cache key cannot be found even with same cache key

@sswastioyono18 sswastioyono18 added bug Something isn't working needs triage labels May 18, 2024
@aparnajyothi-y
Copy link

Hello @sswastioyono18, Thank you for creating this issue and we will get back to you once we have some feedback on this :)

@gowridurgad gowridurgad self-assigned this Jun 11, 2024
@gowridurgad
Copy link

Hi @sswastioyono18, The actions/setup-go does not inherently create a cache that can be reused by other actions. The cache option in actions/setup-go is specifically for speeding up the setup process by reusing a previously installed version of Go, if available. The actions/cache action, which is a separate entity, is designed for caching dependencies and build outputs to enhance the speed of the workflow. These two actions serve different functions and are used independently.

To cache Go dependencies or build outputs, actions/cache is typically employed directly in the workflow configuration. The cache created by actions/setup-go is not designed to be reused by actions/cache as it doesn't cache Go dependencies or build outputs. And It's possible to utilize the cache created by actions/cache in the main branch within a feature branch.

I hope this helps clarify the roles of these two different actions and how they can be utilized in GitHub Actions workflows.

@sswastioyono18
Copy link
Author

Hi @sswastioyono18, The actions/setup-go does not inherently create a cache that can be reused by other actions. The cache option in actions/setup-go is specifically for speeding up the setup process by reusing a previously installed version of Go, if available. The actions/cache action, which is a separate entity, is designed for caching dependencies and build outputs to enhance the speed of the workflow. These two actions serve different functions and are used independently.

To cache Go dependencies or build outputs, actions/cache is typically employed directly in the workflow configuration. The cache created by actions/setup-go is not designed to be reused by actions/cache as it doesn't cache Go dependencies or build outputs. And It's possible to utilize the cache created by actions/cache in the main branch within a feature branch.

I hope this helps clarify the roles of these two different actions and how they can be utilized in GitHub Actions workflows.

Hi @gowridurgad thanks for the explanation. We decided to use the action cache since it fits our use case. This issue can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants