Skip to content

Commit

Permalink
buildx integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
reingart committed Jan 19, 2025
1 parent fd74681 commit a2369b2
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
35 changes: 35 additions & 0 deletions integration/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ func TestBuild(t *testing.T) {
description: "docker build",
dir: "testdata/build",
},
{
setup: setupBuildX,
description: "docker buildx",
dir: "testdata/buildx",
},
{
description: "git tagger",
dir: "testdata/tagPolicy",
Expand Down Expand Up @@ -314,6 +319,36 @@ func setupGitRepo(t *testing.T, dir string) {
}
}

// setupBuildX sets up a docker buildx builder using buildkit
func setupBuildX(t *testing.T, dir string) {
t.Cleanup(func() {
dockerArgs := [][]string{
{"buildx", "uninstall"},
{"buildx", "rm", "buildkit"},
}
for _, args := range dockerArgs {
cmd := exec.Command("docker", args...)
if buf, err := util.RunCmdOut(context.Background(), cmd); err != nil {
t.Log(string(buf))
t.Fatal(err)
}
}

})

Check failure on line 337 in integration/build_test.go

View workflow job for this annotation

GitHub Actions / PR linters, checks

unnecessary trailing newline (whitespace)

dockerArgs := [][]string{
{"buildx", "install"},
{"buildx", "create", "--driver", "docker-container", "--name", "buildkit"},
}
for _, args := range dockerArgs {
cmd := exec.Command("docker", args...)
if buf, err := util.RunCmdOut(context.Background(), cmd); err != nil {
t.Log(string(buf))
t.Fatal(err)
}
}
}

// nowInChicago returns the dateTime string as generated by the dateTime tagger
func nowInChicago() string {
loc, _ := tz.LoadLocation("America/Chicago")
Expand Down
12 changes: 12 additions & 0 deletions integration/testdata/buildx/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# syntax=docker/dockerfile:1

FROM busybox as base

RUN cat <<< "echo hello world" > app.sh
RUN chmod 755 app.sh

FROM alpine:3

COPY --from base app.sh

CMD ./app.sh
13 changes: 13 additions & 0 deletions integration/testdata/buildx/skaffold.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: skaffold/v4beta12
kind: Config
build:
artifacts:
- image: my-app
docker:
dockerfile: Dockerfile
cacheFrom:
- "my-app"
local:
useBuildkit: true
useDockerCLI: true
tryImportMissing: true

0 comments on commit a2369b2

Please sign in to comment.