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 8ebd10b commit 9a38109
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
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
4 changes: 2 additions & 2 deletions pkg/patch/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ func NewPatchCmd() *cobra.Command {
flags.StringVarP(&ua.WorkDir, "working-folder", "w", "", "Working folder, defaults to system temp folder")
flags.StringVarP(&ua.BuildkitAddr, "addr", "a", "", "Address of buildkitd service, defaults to local docker daemon with fallback to "+buildkit.DefaultAddr)
flags.DurationVar(&ua.Timeout, "timeout", 5*time.Minute, "Timeout for the operation, defaults to '5m'")
flags.StringSliceVar(&ua.CacheFrom, "cache-from", nil, "Cache import sources")
flags.StringSliceVar(&ua.CacheTo, "cache-to", nil, "Cache export destination")
flags.StringArrayVar(&ua.CacheFrom, "cache-from", []string{}, "Cache import sources")
flags.StringArrayVar(&ua.CacheTo, "cache-to", []string{}, "Cache export destination")

if err := patchCmd.MarkFlagRequired("image"); err != nil {
panic(err)
Expand Down

0 comments on commit 9a38109

Please sign in to comment.