diff --git a/.github/workflows/buildkit.yml b/.github/workflows/buildkit.yml index b4f56b3b6007..65794971f418 100644 --- a/.github/workflows/buildkit.yml +++ b/.github/workflows/buildkit.yml @@ -143,6 +143,10 @@ jobs: tags: nydus skip-integration-tests: 1 typ: integration + - pkg: ./client + worker: oci + tags: ghacache + typ: integration govulncheck: runs-on: ubuntu-24.04 diff --git a/client/client_ghacache_test.go b/client/client_ghacache_test.go new file mode 100644 index 000000000000..2c38d2fc167b --- /dev/null +++ b/client/client_ghacache_test.go @@ -0,0 +1,61 @@ +//go:build ghacache + +package client + +import ( + "os" + "strings" + "testing" + + "github.com/moby/buildkit/util/testutil/integration" + "github.com/moby/buildkit/util/testutil/workers" +) + +func init() { + allTests = []func(t *testing.T, sb integration.Sandbox){ + testBasicGhaCacheImportExportExtraTimeout, + } +} + +func testBasicGhaCacheImportExportExtraTimeout(t *testing.T, sb integration.Sandbox) { + workers.CheckFeatureCompat(t, sb, + workers.FeatureCacheExport, + workers.FeatureCacheImport, + workers.FeatureCacheBackendGha, + ) + runtimeToken := os.Getenv("ACTIONS_RUNTIME_TOKEN") + cacheURL := os.Getenv("ACTIONS_CACHE_URL") + if runtimeToken == "" || cacheURL == "" { + t.Skip("ACTIONS_RUNTIME_TOKEN and ACTIONS_CACHE_URL must be set") + } + + scope := "buildkit-" + t.Name() + if ref := os.Getenv("GITHUB_REF"); ref != "" { + if strings.HasPrefix(ref, "refs/heads/") { + scope += "-" + strings.TrimPrefix(ref, "refs/heads/") + } else if strings.HasPrefix(ref, "refs/tags/") { + scope += "-" + strings.TrimPrefix(ref, "refs/tags/") + } else if strings.HasPrefix(ref, "refs/pull/") { + scope += "-pr" + strings.TrimPrefix(strings.TrimSuffix(strings.TrimSuffix(ref, "/head"), "/merge"), "refs/pull/") + } + } + + im := CacheOptionsEntry{ + Type: "gha", + Attrs: map[string]string{ + "url": cacheURL, + "token": runtimeToken, + "scope": scope, + }, + } + ex := CacheOptionsEntry{ + Type: "gha", + Attrs: map[string]string{ + "url": cacheURL, + "token": runtimeToken, + "scope": scope, + "mode": "max", + }, + } + testBasicCacheImportExport(t, sb, []CacheOptionsEntry{im}, []CacheOptionsEntry{ex}) +} diff --git a/client/client_test.go b/client/client_test.go index ace0060aa142..eaf3daf446d1 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -148,7 +148,6 @@ var allTests = []func(t *testing.T, sb integration.Sandbox){ testHostnameSpecifying, testPushByDigest, testBasicInlineCacheImportExport, - testBasicGhaCacheImportExportExtraTimeout, testExportBusyboxLocal, testBridgeNetworking, testCacheMountNoCache, @@ -6176,49 +6175,6 @@ func testBasicInlineCacheImportExport(t *testing.T, sb integration.Sandbox) { require.EqualValues(t, unique, unique3) } -func testBasicGhaCacheImportExportExtraTimeout(t *testing.T, sb integration.Sandbox) { - workers.CheckFeatureCompat(t, sb, - workers.FeatureCacheExport, - workers.FeatureCacheImport, - workers.FeatureCacheBackendGha, - ) - runtimeToken := os.Getenv("ACTIONS_RUNTIME_TOKEN") - cacheURL := os.Getenv("ACTIONS_CACHE_URL") - if runtimeToken == "" || cacheURL == "" { - t.Skip("ACTIONS_RUNTIME_TOKEN and ACTIONS_CACHE_URL must be set") - } - - scope := "buildkit-" + t.Name() - if ref := os.Getenv("GITHUB_REF"); ref != "" { - if strings.HasPrefix(ref, "refs/heads/") { - scope += "-" + strings.TrimPrefix(ref, "refs/heads/") - } else if strings.HasPrefix(ref, "refs/tags/") { - scope += "-" + strings.TrimPrefix(ref, "refs/tags/") - } else if strings.HasPrefix(ref, "refs/pull/") { - scope += "-pr" + strings.TrimPrefix(strings.TrimSuffix(strings.TrimSuffix(ref, "/head"), "/merge"), "refs/pull/") - } - } - - im := CacheOptionsEntry{ - Type: "gha", - Attrs: map[string]string{ - "url": cacheURL, - "token": runtimeToken, - "scope": scope, - }, - } - ex := CacheOptionsEntry{ - Type: "gha", - Attrs: map[string]string{ - "url": cacheURL, - "token": runtimeToken, - "scope": scope, - "mode": "max", - }, - } - testBasicCacheImportExport(t, sb, []CacheOptionsEntry{im}, []CacheOptionsEntry{ex}) -} - func testRegistryEmptyCacheExport(t *testing.T, sb integration.Sandbox) { workers.CheckFeatureCompat(t, sb, workers.FeatureCacheExport, @@ -7480,7 +7436,7 @@ func testMergeOp(t *testing.T, sb integration.Sandbox) { File(llb.Mkfile("bar/D", 0644, []byte("D"))). File(llb.Mkfile("bar/E", 0755, nil)). File(llb.Mkfile("qaz", 0644, nil)), - // /foo from stateE is not here because it is deleted in stateB, which is part of a submerge of mergeD + // /foo from stateE is not here because it is deleted in stateB, which is part of a submerge of mergeD ) }