From 048e6ac1f76a8128ba880e41b471a18fb31ed63c Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Mon, 26 Sep 2022 13:31:44 +0200 Subject: [PATCH] bake(e2e): simple test for sync-output flag Signed-off-by: CrazyMax --- .github/workflows/e2e.yml | 33 +++++++++++++++++++++++++++ test/bake-sync-output/.gitignore | 1 + test/bake-sync-output/bar.Dockerfile | 5 ++++ test/bake-sync-output/docker-bake.hcl | 13 +++++++++++ test/bake-sync-output/foo.Dockerfile | 5 ++++ test/bake-sync-output/test.sh | 13 +++++++++++ 6 files changed, 70 insertions(+) create mode 100644 test/bake-sync-output/.gitignore create mode 100644 test/bake-sync-output/bar.Dockerfile create mode 100644 test/bake-sync-output/docker-bake.hcl create mode 100644 test/bake-sync-output/foo.Dockerfile create mode 100755 test/bake-sync-output/test.sh diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index a9fee690..b0f6f108 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -168,3 +168,36 @@ jobs: DRIVER_OPT: ${{ matrix.driver-opt }} ENDPOINT: ${{ matrix.endpoint }} PLATFORMS: ${{ matrix.platforms }} + + cases: + runs-on: ubuntu-20.04 + needs: + - build + strategy: + fail-fast: false + matrix: + case: + - bake-sync-output + steps: + - + name: Checkout + uses: actions/checkout@v3 + - + name: Install buildx + uses: actions/download-artifact@v3 + with: + name: binary + path: /home/runner/.docker/cli-plugins + - + name: Fix perms and check + run: | + chmod +x /home/runner/.docker/cli-plugins/docker-buildx + docker buildx version + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - + name: Test + working-directory: ./test/${{ matrix.case }} + run: | + ./test.sh diff --git a/test/bake-sync-output/.gitignore b/test/bake-sync-output/.gitignore new file mode 100644 index 00000000..e2e7327c --- /dev/null +++ b/test/bake-sync-output/.gitignore @@ -0,0 +1 @@ +/out diff --git a/test/bake-sync-output/bar.Dockerfile b/test/bake-sync-output/bar.Dockerfile new file mode 100644 index 00000000..ac342679 --- /dev/null +++ b/test/bake-sync-output/bar.Dockerfile @@ -0,0 +1,5 @@ +FROM busybox +RUN echo bar > /bar + +FROM scratch +COPY --from=0 /bar /bar diff --git a/test/bake-sync-output/docker-bake.hcl b/test/bake-sync-output/docker-bake.hcl new file mode 100644 index 00000000..acdabeea --- /dev/null +++ b/test/bake-sync-output/docker-bake.hcl @@ -0,0 +1,13 @@ +group "default" { + targets = ["foo", "bar"] +} + +target "foo" { + dockerfile = "foo.Dockerfile" + output = ["out"] +} + +target "bar" { + dockerfile = "bar.Dockerfile" + output = ["out"] +} diff --git a/test/bake-sync-output/foo.Dockerfile b/test/bake-sync-output/foo.Dockerfile new file mode 100644 index 00000000..b0143c36 --- /dev/null +++ b/test/bake-sync-output/foo.Dockerfile @@ -0,0 +1,5 @@ +FROM busybox +RUN echo foo > /foo + +FROM scratch +COPY --from=0 /foo /foo diff --git a/test/bake-sync-output/test.sh b/test/bake-sync-output/test.sh new file mode 100755 index 00000000..81016518 --- /dev/null +++ b/test/bake-sync-output/test.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +set -ex + +rm -rf ./out + +docker buildx bake --print +docker buildx bake --sync-output + +if [[ ! -f ./out/foo || ! -f ./out/bar ]]; then + echo >&2 "error: missing output files" + exit 1 +fi