Skip to content

Commit

Permalink
tests: Add github actions cache
Browse files Browse the repository at this point in the history
Signed-off-by: Brian Goff <[email protected]>
  • Loading branch information
cpuguy83 committed Dec 12, 2023
1 parent 961fe88 commit f037f86
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/testenv/buildkit.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package testenv

import (
"os"
"strconv"
"strings"
"testing"

"github.com/moby/buildkit/client"
)
Expand Down Expand Up @@ -61,3 +63,24 @@ func isSupported(info *client.Info) bool {

return minor >= minVersion.Minor
}

func withGHCache(t *testing.T, so *client.SolveOpt) {
if os.Getenv("GITHUB_ACTIONS") != "true" {
return
}

scope := "test-integration-" + t.Name()
so.CacheExports = append(so.CacheExports, client.CacheOptionsEntry{
Type: "gha",
Attrs: map[string]string{
"scope": scope,
"mode": "max",
},
})
so.CacheImports = append(so.CacheImports, client.CacheOptionsEntry{
Type: "gha",
Attrs: map[string]string{
"scope": scope,
},
})
}
1 change: 1 addition & 0 deletions test/testenv/buildx.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ func (b *BuildxEnv) RunTest(ctx context.Context, t *testing.T, f gwclient.BuildF

var so client.SolveOpt
withProjectRoot(t, &so)
withGHCache(t, &so)

_, err = c.Build(ctx, so, "", func(ctx context.Context, gwc gwclient.Client) (*gwclient.Result, error) {
gwc = &clientForceDalecWithInput{gwc}
Expand Down

0 comments on commit f037f86

Please sign in to comment.