Skip to content

Commit

Permalink
feat: Passthrough for cache-{from,to} from integration tests to copa
Browse files Browse the repository at this point in the history
Signed-off-by: Brian Goff <[email protected]>
  • Loading branch information
cpuguy83 committed Aug 15, 2023
1 parent 8359629 commit 62fec12
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,13 @@ jobs:
./copa --version
- name: Set up QEMU
uses: docker/setup-qemu-action@2b82ce82d56a2a04d2637cd93a637ae1b359c0a7 # v2.2.0
- name: Setup gha cache vars
uses: crazy-max/ghaction-github-runtime@v2
- name: Run functional test
shell: bash
run: |
set -eu -o pipefail
. .github/workflows/scripts/buildkitenvs/${{ matrix.buildkit_mode}}
go test -v ./integration --addr="${COPA_BUILDKIT_ADDR}" --copa="$(pwd)/copa"
go test -v ./integration --addr="${COPA_BUILDKIT_ADDR}" --copa="$(pwd)/copa" --cache-from=type=gha,scope=${{matrix.buildkit_mode}} --cache-to=type=gha,scope=${{ matrix.buildkit_mode }}
4 changes: 4 additions & 0 deletions integration/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@ import (
var (
buildkitAddr string
copaPath string
cacheFrom string
cacheTo string
)

func TestMain(m *testing.M) {
flag.StringVar(&buildkitAddr, "addr", "", "buildkit address to pass through to copa binary")
flag.StringVar(&copaPath, "copa", "./copa", "path to copa binary")
flag.StringVar(&cacheFrom, "cache-from", "", "pass through cache-from to copa binary")
flag.StringVar(&cacheTo, "cache-to", "", "pass through cache-to to copa binary")
flag.Parse()

if copaPath == "" {
Expand Down
12 changes: 12 additions & 0 deletions integration/patch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,18 @@ func patch(t *testing.T, ref, patchedTag, scan string) {
"-t="+patchedTag,
"-r="+scan,
"--timeout=20m",
func() string {
if cacheFrom == "" {
return ""
}
return "--cache-from=" + cacheFrom
}(),
func() string {
if cacheTo == "" {
return ""
}
return "--cache-to=" + cacheTo
}(),
addrFl,
)
out, err := cmd.CombinedOutput()
Expand Down

0 comments on commit 62fec12

Please sign in to comment.