diff --git a/integration/run_test.go b/integration/run_test.go index d6d20c82945..5a6400b591e 100644 --- a/integration/run_test.go +++ b/integration/run_test.go @@ -313,8 +313,17 @@ func TestFix(t *testing.T) { runCmd := exec.Command("skaffold", "run", "--namespace", ns.Name, "-f", "-") runCmd.Dir = "testdata/fix" runCmd.Stdin = bytes.NewReader(out) - err = util.RunCmd(runCmd) - if err != nil { + + if err := util.RunCmd(runCmd); err != nil { + t.Fatalf("testing error: %v", err) + } +} + +func TestBuild(t *testing.T) { + buildCmd := exec.Command("skaffold", "build") + buildCmd.Dir = "testdata/build" + + if err := util.RunCmd(buildCmd); err != nil { t.Fatalf("testing error: %v", err) } } diff --git a/integration/testdata/build/Dockerfile b/integration/testdata/build/Dockerfile new file mode 100644 index 00000000000..4652feec056 --- /dev/null +++ b/integration/testdata/build/Dockerfile @@ -0,0 +1,3 @@ +FROM busybox + +COPY . /data diff --git a/integration/testdata/build/multi-env/Dockerfile b/integration/testdata/build/multi-env/Dockerfile new file mode 100644 index 00000000000..cfa889d4a9c --- /dev/null +++ b/integration/testdata/build/multi-env/Dockerfile @@ -0,0 +1,7 @@ +FROM busybox + +ENV file1=file1 \ + file2=file2 + +COPY $file1 $file2 /data/ +RUN [ "$(find /data -type f | wc -l | xargs)" == "2" ] \ No newline at end of file diff --git a/integration/testdata/build/multi-env/file1 b/integration/testdata/build/multi-env/file1 new file mode 100644 index 00000000000..08219db9b09 --- /dev/null +++ b/integration/testdata/build/multi-env/file1 @@ -0,0 +1 @@ +file1 \ No newline at end of file diff --git a/integration/testdata/build/multi-env/file2 b/integration/testdata/build/multi-env/file2 new file mode 100644 index 00000000000..30d67d4672d --- /dev/null +++ b/integration/testdata/build/multi-env/file2 @@ -0,0 +1 @@ +file2 \ No newline at end of file diff --git a/integration/testdata/build/skaffold.yaml b/integration/testdata/build/skaffold.yaml new file mode 100644 index 00000000000..b0538a1688c --- /dev/null +++ b/integration/testdata/build/skaffold.yaml @@ -0,0 +1,33 @@ +apiVersion: skaffold/v1beta5 +kind: Config +build: + artifacts: + # A simple Docker build + - image: simple-build + + # Building from a sub-directory + - image: sub-directory + context: sub-directory + + # Testing multiline env variables in Dockerfiles + # Would have caught #1624 + - image: multi-env + context: multi-env + + # Testing Dockerfiles with targets + - image: targets + context: target + + # Providing a target + # Would have caught #1605 + - image: target1 + context: target + docker: + target: target1 + + # Providing another target + # Would have caught #1605 + - image: target2 + context: target + docker: + target: target2 diff --git a/integration/testdata/build/sub-directory/Dockerfile b/integration/testdata/build/sub-directory/Dockerfile new file mode 100644 index 00000000000..3830aaed78e --- /dev/null +++ b/integration/testdata/build/sub-directory/Dockerfile @@ -0,0 +1,4 @@ +FROM busybox + +COPY file1 file2 /data/ +RUN [ "$(find /data -type f | wc -l | xargs)" == "2" ] \ No newline at end of file diff --git a/integration/testdata/build/sub-directory/file1 b/integration/testdata/build/sub-directory/file1 new file mode 100644 index 00000000000..08219db9b09 --- /dev/null +++ b/integration/testdata/build/sub-directory/file1 @@ -0,0 +1 @@ +file1 \ No newline at end of file diff --git a/integration/testdata/build/sub-directory/file2 b/integration/testdata/build/sub-directory/file2 new file mode 100644 index 00000000000..30d67d4672d --- /dev/null +++ b/integration/testdata/build/sub-directory/file2 @@ -0,0 +1 @@ +file2 \ No newline at end of file