-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
buildctl: set fallback url for gha cache #5754
Conversation
ca875b0
to
d270bc0
Compare
d270bc0
to
a81bb08
Compare
* `url`: Cache server URL (default `$ACTIONS_CACHE_URL` or fallback to `$ACTIONS_RESULTS_URL`) | ||
* `url_v2`: Cache v2 server URL if `$ACTIONS_CACHE_SERVICE_V2` set on the runner (default `$ACTIONS_RESULTS_URL`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated docs as well for new attribute. Not sure if we should also add version
?
a81bb08
to
f9917ce
Compare
return cache, errors.New("cache with type gha requires url parameter or $ACTIONS_RESULTS_URL") | ||
// https://github.com/actions/toolkit/blob/2b08dc18f261b9fdd978b70279b85cbef81af8bc/packages/cache/src/internal/config.ts#L34-L35 | ||
if v, ok := os.LookupEnv("ACTIONS_RESULTS_URL"); ok { | ||
cache.Attrs["url_v2"] = v |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why skip the error if ACTIONS_CACHE_SERVICE_V2
is set but ACTIONS_RESULTS_URL
is not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This relates to #5754 (comment) so error would be handled from daemon side instead. Seems better to me for old daemon.
cmd/buildctl/build/util.go
Outdated
if !ok { | ||
return cache, errors.New("cache with type gha requires token parameter or $ACTIONS_RUNTIME_TOKEN") | ||
if v, ok := os.LookupEnv("ACTIONS_RUNTIME_TOKEN"); ok { | ||
cache.Attrs["token"] = v | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding is that daemon will error anyway if you don't send the token. So why skip error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was to be aligned with buildx where we don't do this https://github.com/docker/buildx/blob/52f503e8068d4a09e7c1b17e4b88ae75b1f64651/util/buildflags/cache.go#L208-L231 but I can put that back if you prefer
f9917ce
to
4bbac8a
Compare
Signed-off-by: CrazyMax <[email protected]>
Signed-off-by: CrazyMax <[email protected]>
4bbac8a
to
1c917b4
Compare
relates to docker/buildx#3001 (comment)
We should always set
url
attr (if possible) when gha cache is used otherwise it will fail on BuildKit < 0.20 that doesn't supporturl_v2
.Also updates gha cache tests to support cache service v2.