Skip to content

Commit 6cad2f9

Browse files
authored
Merge pull request moby#5755 from crazy-max/0.20_backport_rc3
[v0.20] cherry-picks 0.20.0-rc3
2 parents c45cd57 + b0f75aa commit 6cad2f9

31 files changed

+628
-136
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# syntax=docker/dockerfile-upstream:master
22

3-
ARG RUNC_VERSION=v1.2.4
3+
ARG RUNC_VERSION=v1.2.5
44
ARG CONTAINERD_VERSION=v2.0.2
55
# CONTAINERD_ALT_VERSION_... defines fallback containerd version for integration tests
66
ARG CONTAINERD_ALT_VERSION_17=v1.7.25

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,8 @@ GitHub Actions cache saves both cache metadata and layers to GitHub's Cache serv
516516
Similarly to using [actions/cache](https://github.com/actions/cache), caches are [scoped by branch](https://docs.github.com/en/actions/advanced-guides/caching-dependencies-to-speed-up-workflows#restrictions-for-accessing-a-cache), with the default and target branches being available to every branch.
517517

518518
Following attributes are required to authenticate against the [GitHub Actions Cache service API](https://github.com/tonistiigi/go-actions-cache/blob/master/api.md#authentication):
519-
* `url`: Cache server URL (default `$ACTIONS_CACHE_URL`)
519+
* `url`: Cache server URL (default `$ACTIONS_CACHE_URL` or fallback to `$ACTIONS_RESULTS_URL`)
520+
* `url_v2`: Cache v2 server URL if `$ACTIONS_CACHE_SERVICE_V2` set on the runner (default `$ACTIONS_RESULTS_URL`)
520521
* `token`: Access token (default `$ACTIONS_RUNTIME_TOKEN`)
521522

522523
:information_source: This type of cache can be used with [Docker Build Push Action](https://github.com/docker/build-push-action)

cache/remotecache/gha/gha.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,6 @@ func getConfig(attrs map[string]string) (*Config, error) {
6363
if !ok {
6464
scope = "buildkit"
6565
}
66-
url, ok := attrs[attrURL]
67-
if !ok {
68-
return nil, errors.Errorf("url not set for github actions cache")
69-
}
7066
token, ok := attrs[attrToken]
7167
if !ok {
7268
return nil, errors.Errorf("token not set for github actions cache")
@@ -80,12 +76,19 @@ func getConfig(attrs map[string]string) (*Config, error) {
8076
}
8177
apiVersionInt = int(i)
8278
}
79+
var url string
8380
if apiVersionInt != 1 {
8481
if v, ok := attrs[attrURLV2]; ok {
8582
url = v
8683
apiVersionInt = 2
8784
}
8885
}
86+
if v, ok := attrs[attrURL]; ok && url == "" {
87+
url = v
88+
}
89+
if url == "" {
90+
return nil, errors.Errorf("url not set for github actions cache")
91+
}
8992
// best effort on old clients
9093
if apiVersionInt == 0 {
9194
if strings.Contains(url, "results-receiver.actions.githubusercontent.com") {

cache/remotecache/gha/gha_test.go

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package gha
22

33
import (
4+
"maps"
45
"os"
56
"path/filepath"
7+
"strconv"
68
"strings"
79
"testing"
810
"time"
@@ -57,10 +59,25 @@ func testBasicGhaCacheImportExportExtraTimeout(t *testing.T, sb integration.Sand
5759

5860
destDir := t.TempDir()
5961

60-
runtimeToken := os.Getenv("ACTIONS_RUNTIME_TOKEN")
61-
cacheURL := os.Getenv("ACTIONS_CACHE_URL")
62-
if runtimeToken == "" || cacheURL == "" {
63-
t.Skip("ACTIONS_RUNTIME_TOKEN and ACTIONS_CACHE_URL must be set")
62+
var cacheVersion string
63+
if v, ok := os.LookupEnv("ACTIONS_CACHE_SERVICE_V2"); ok {
64+
if b, err := strconv.ParseBool(v); err == nil && b {
65+
cacheVersion = "2"
66+
}
67+
}
68+
69+
cacheAttrs := map[string]string{}
70+
if cacheVersion == "2" {
71+
cacheAttrs["url_v2"] = os.Getenv("ACTIONS_RESULTS_URL")
72+
}
73+
cacheAttrs["url"] = os.Getenv("ACTIONS_CACHE_URL")
74+
if cacheAttrs["url"] == "" {
75+
cacheAttrs["url"] = os.Getenv("ACTIONS_RESULTS_URL")
76+
}
77+
cacheAttrs["token"] = os.Getenv("ACTIONS_RUNTIME_TOKEN")
78+
79+
if cacheAttrs["token"] == "" || (cacheAttrs["url"] == "" && cacheAttrs["url_v2"] == "") {
80+
t.Skip("actions runtime token and cache url must be set")
6481
}
6582

6683
scope := "buildkit-" + t.Name()
@@ -74,6 +91,12 @@ func testBasicGhaCacheImportExportExtraTimeout(t *testing.T, sb integration.Sand
7491
}
7592
}
7693

94+
cacheExportAttrs := map[string]string{
95+
"scope": scope,
96+
"mode": "max",
97+
}
98+
maps.Copy(cacheExportAttrs, cacheAttrs)
99+
77100
_, err = c.Solve(sb.Context(), def, client.SolveOpt{
78101
Exports: []client.ExportEntry{
79102
{
@@ -82,13 +105,8 @@ func testBasicGhaCacheImportExportExtraTimeout(t *testing.T, sb integration.Sand
82105
},
83106
},
84107
CacheExports: []client.CacheOptionsEntry{{
85-
Type: "gha",
86-
Attrs: map[string]string{
87-
"url": cacheURL,
88-
"token": runtimeToken,
89-
"scope": scope,
90-
"mode": "max",
91-
},
108+
Type: "gha",
109+
Attrs: cacheExportAttrs,
92110
}},
93111
}, nil)
94112
require.NoError(t, err)
@@ -104,6 +122,11 @@ func testBasicGhaCacheImportExportExtraTimeout(t *testing.T, sb integration.Sand
104122

105123
destDir = t.TempDir()
106124

125+
cacheImportAttrs := map[string]string{
126+
"scope": scope,
127+
}
128+
maps.Copy(cacheImportAttrs, cacheAttrs)
129+
107130
_, err = c.Solve(sb.Context(), def, client.SolveOpt{
108131
Exports: []client.ExportEntry{
109132
{
@@ -112,12 +135,8 @@ func testBasicGhaCacheImportExportExtraTimeout(t *testing.T, sb integration.Sand
112135
},
113136
},
114137
CacheImports: []client.CacheOptionsEntry{{
115-
Type: "gha",
116-
Attrs: map[string]string{
117-
"url": cacheURL,
118-
"token": runtimeToken,
119-
"scope": scope,
120-
},
138+
Type: "gha",
139+
Attrs: cacheImportAttrs,
121140
}},
122141
}, nil)
123142
require.NoError(t, err)

client/build_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1838,7 +1838,7 @@ func testClientGatewayContainerSecurityMode(t *testing.T, sb integration.Sandbox
18381838

18391839
command := []string{"sh", "-c", `cat /proc/self/status | grep CapEff | cut -f 2`}
18401840
mode := llb.SecurityModeSandbox
1841-
var allowedEntitlements []entitlements.Entitlement
1841+
var allowedEntitlements []string
18421842
var assertCaps func(caps uint64)
18431843
secMode := sb.Value("secmode")
18441844
if secMode == securitySandbox {
@@ -1850,7 +1850,7 @@ func testClientGatewayContainerSecurityMode(t *testing.T, sb integration.Sandbox
18501850
*/
18511851
require.Equal(t, uint64(0xa80425fb), caps)
18521852
}
1853-
allowedEntitlements = []entitlements.Entitlement{}
1853+
allowedEntitlements = []string{}
18541854
if expectFail {
18551855
return
18561856
}
@@ -1869,9 +1869,9 @@ func testClientGatewayContainerSecurityMode(t *testing.T, sb integration.Sandbox
18691869
require.Equal(t, uint64(0x3fffffffff), caps&0x3fffffffff)
18701870
}
18711871
mode = llb.SecurityModeInsecure
1872-
allowedEntitlements = []entitlements.Entitlement{entitlements.EntitlementSecurityInsecure}
1872+
allowedEntitlements = []string{entitlements.EntitlementSecurityInsecure.String()}
18731873
if expectFail {
1874-
allowedEntitlements = []entitlements.Entitlement{}
1874+
allowedEntitlements = []string{}
18751875
}
18761876
}
18771877

@@ -2046,13 +2046,13 @@ func testClientGatewayContainerHostNetworking(t *testing.T, sb integration.Sandb
20462046
ctx := sb.Context()
20472047
product := "buildkit_test"
20482048

2049-
var allowedEntitlements []entitlements.Entitlement
2049+
var allowedEntitlements []string
20502050
netMode := pb.NetMode_UNSET
20512051
if sb.Value("netmode") == hostNetwork {
20522052
netMode = pb.NetMode_HOST
2053-
allowedEntitlements = []entitlements.Entitlement{entitlements.EntitlementNetworkHost}
2053+
allowedEntitlements = []string{entitlements.EntitlementNetworkHost.String()}
20542054
if expectFail {
2055-
allowedEntitlements = []entitlements.Entitlement{}
2055+
allowedEntitlements = []string{}
20562056
}
20572057
}
20582058
c, err := New(sb.Context(), sb.Address())

0 commit comments

Comments
 (0)