From 767df53376a7141fb30b99dad7b507ac7b32499e Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Fri, 9 Jun 2023 13:04:01 +0200 Subject: [PATCH 1/4] e2e: test buildx and buildkit edge Signed-off-by: CrazyMax --- .github/workflows/e2e.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 22b906e..bb218dd 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -23,8 +23,6 @@ on: - 'v*' env: - BUILDX_VERSION: latest - BUILDKIT_IMAGE: moby/buildkit:buildx-stable-1 HARBOR_VERSION: v2.7.0 NEXUS_VERSION: 3.47.1 DISTRIBUTION_VERSION: 2.8.1 @@ -35,6 +33,12 @@ jobs: strategy: fail-fast: false matrix: + buildx_version: + - latest + - https://github.com/docker/buildx.git#master + buildkit_image: + - moby/buildkit:buildx-stable-1 + - moby/buildkit:master include: - name: Distribution @@ -166,11 +170,11 @@ jobs: name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 with: - version: ${{ inputs.buildx-version || env.BUILDX_VERSION }} + version: ${{ inputs.buildx-version || matrix.buildx_version }} config: /tmp/buildkitd.toml buildkitd-flags: --debug --allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host driver-opts: | - image=${{ inputs.buildkit-image || env.BUILDKIT_IMAGE }} + image=${{ inputs.buildkit-image || matrix.buildkit_image }} network=host - name: Login to Registry From 9006f617402be1d639996b6763b26015efba3e53 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Fri, 9 Jun 2023 13:20:19 +0200 Subject: [PATCH 2/4] e2e: test buildx and buildkit edge Signed-off-by: CrazyMax --- .github/workflows/e2e.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index bb218dd..2177473 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -39,11 +39,13 @@ jobs: buildkit_image: - moby/buildkit:buildx-stable-1 - moby/buildkit:master + _merge: dummy include: - name: Distribution id: distribution type: local + _merge: dummy - name: Docker Hub registry: '' @@ -51,6 +53,7 @@ jobs: username_secret: DOCKERHUB_USERNAME password_secret: DOCKERHUB_TOKEN type: remote + _merge: dummy - name: GitHub registry: ghcr.io @@ -58,6 +61,7 @@ jobs: username_secret: GHCR_USERNAME password_secret: GHCR_PAT type: remote + _merge: dummy - name: GitLab registry: registry.gitlab.com @@ -65,6 +69,7 @@ jobs: username_secret: GITLAB_USERNAME password_secret: GITLAB_TOKEN type: remote + _merge: dummy - name: AWS ECR registry: 175142243308.dkr.ecr.us-east-2.amazonaws.com @@ -72,6 +77,7 @@ jobs: username_secret: AWS_ACCESS_KEY_ID password_secret: AWS_SECRET_ACCESS_KEY type: remote + _merge: dummy - name: AWS ECR Public registry: public.ecr.aws @@ -79,6 +85,7 @@ jobs: username_secret: AWS_ACCESS_KEY_ID password_secret: AWS_SECRET_ACCESS_KEY type: remote + _merge: dummy - name: Google Artifact Registry registry: us-east4-docker.pkg.dev @@ -86,6 +93,7 @@ jobs: username_secret: GAR_USERNAME password_secret: GAR_JSON_KEY type: remote + _merge: dummy - name: Google Container Registry registry: gcr.io @@ -93,6 +101,7 @@ jobs: username_secret: GCR_USERNAME password_secret: GCR_JSON_KEY type: remote + _merge: dummy - name: Azure Container Registry registry: officialgithubactions.azurecr.io @@ -100,6 +109,7 @@ jobs: username_secret: AZURE_CLIENT_ID password_secret: AZURE_CLIENT_SECRET type: remote + _merge: dummy - name: Quay registry: quay.io @@ -107,6 +117,7 @@ jobs: username_secret: QUAY_USERNAME password_secret: QUAY_TOKEN type: remote + _merge: dummy - name: Artifactory registry: buildkitghactiontests.jfrog.io @@ -114,14 +125,17 @@ jobs: username_secret: ARTIFACTORY_USERNAME password_secret: ARTIFACTORY_TOKEN type: remote + _merge: dummy - name: Harbor id: harbor type: local + _merge: dummy - name: Nexus id: nexus type: local + _merge: dummy steps: - name: Checkout From 311cfdadd6706cef444314c03493fa5cb3e0968f Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Fri, 9 Jun 2023 13:21:19 +0200 Subject: [PATCH 3/4] e2e: test buildx and buildkit edge Signed-off-by: CrazyMax --- .github/workflows/e2e.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 2177473..410ff88 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -39,7 +39,8 @@ jobs: buildkit_image: - moby/buildkit:buildx-stable-1 - moby/buildkit:master - _merge: dummy + _merge: + - dummy include: - name: Distribution From 356f5313f1b327c2ae68d7ed440395fc1e21ea44 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Fri, 9 Jun 2023 13:38:11 +0200 Subject: [PATCH 4/4] e2e: test buildx and buildkit edge Signed-off-by: CrazyMax --- .github/workflows/.e2e-run.yml | 127 +++++++++++++++++++++++++++++++++ .github/workflows/e2e.yml | 103 ++------------------------ 2 files changed, 132 insertions(+), 98 deletions(-) create mode 100644 .github/workflows/.e2e-run.yml diff --git a/.github/workflows/.e2e-run.yml b/.github/workflows/.e2e-run.yml new file mode 100644 index 0000000..1c324b6 --- /dev/null +++ b/.github/workflows/.e2e-run.yml @@ -0,0 +1,127 @@ +# reusable workflow +name: .e2e-run + +on: + workflow_call: + inputs: + id: + required: false + type: string + type: + required: true + type: string + name: + required: true + type: string + registry: + required: false + type: string + slug: + required: false + type: string + secrets: + username: + required: false + password: + required: false + +env: + HARBOR_VERSION: v2.7.0 + NEXUS_VERSION: 3.47.1 + DISTRIBUTION_VERSION: 2.8.1 + +jobs: + run: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + buildx_version: + - latest + - https://github.com/docker/buildx.git#master + buildkit_image: + - moby/buildkit:buildx-stable-1 + - moby/buildkit:master + steps: + - + name: Checkout + uses: actions/checkout@v3 + - + name: Set up env + if: inputs.type == 'local' + run: | + cat ./.github/e2e/${{ inputs.id }}/env >> $GITHUB_ENV + - + name: Set up BuildKit config + run: | + touch /tmp/buildkitd.toml + if [ "${{ inputs.type }}" = "local" ]; then + echo -e "[registry.\"${{ env.REGISTRY_FQDN }}\"]\nhttp = true\ninsecure = true" > /tmp/buildkitd.toml + fi + - + name: Set up Docker daemon + if: inputs.type == 'local' + run: | + if [ ! -e /etc/docker/daemon.json ]; then + echo '{}' | tee /etc/docker/daemon.json >/dev/null + fi + DOCKERD_CONFIG=$(jq '.+{"insecure-registries":["http://${{ env.REGISTRY_FQDN }}"]}' /etc/docker/daemon.json) + sudo tee /etc/docker/daemon.json <<<"$DOCKERD_CONFIG" >/dev/null + sudo service docker restart + - + name: Install ${{ inputs.name }} + if: inputs.type == 'local' + run: | + sudo -E bash ./.github/e2e/${{ inputs.id }}/install.sh + - + name: Docker meta + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ inputs.slug }} + tags: | + type=ref,event=branch + type=ref,event=tag + type=raw,value=${{ inputs.tag }},enable=${{ inputs.tag != '' }} + - + name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + with: + version: ${{ inputs.buildx-version || matrix.buildx_version }} + config: /tmp/buildkitd.toml + buildkitd-flags: --debug --allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host + driver-opts: | + image=${{ inputs.buildkit-image || matrix.buildkit_image }} + network=host + - + name: Login to Registry + if: github.event_name != 'pull_request' && secrets.username != '' + uses: docker/login-action@v2 + with: + registry: ${{ inputs.registry }} + username: ${{ secrets.username }} + password: ${{ secrets.password }} + - + name: Build and push + uses: ./ + with: + context: ./test + file: ./test/multi.Dockerfile + platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=registry,ref=${{ inputs.slug }}:master + cache-to: type=inline + - + name: Inspect image + run: | + docker pull ${{ inputs.slug }}:${{ steps.meta.outputs.version }} + docker image inspect ${{ inputs.slug }}:${{ steps.meta.outputs.version }} + - + name: Check manifest + run: | + docker buildx imagetools inspect ${{ inputs.slug }}:${{ steps.meta.outputs.version }} --format '{{json .}}' diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 410ff88..b606436 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -22,31 +22,17 @@ on: tags: - 'v*' -env: - HARBOR_VERSION: v2.7.0 - NEXUS_VERSION: 3.47.1 - DISTRIBUTION_VERSION: 2.8.1 - jobs: build: runs-on: ubuntu-latest strategy: fail-fast: false matrix: - buildx_version: - - latest - - https://github.com/docker/buildx.git#master - buildkit_image: - - moby/buildkit:buildx-stable-1 - - moby/buildkit:master - _merge: - - dummy include: - name: Distribution id: distribution type: local - _merge: dummy - name: Docker Hub registry: '' @@ -54,7 +40,6 @@ jobs: username_secret: DOCKERHUB_USERNAME password_secret: DOCKERHUB_TOKEN type: remote - _merge: dummy - name: GitHub registry: ghcr.io @@ -62,7 +47,6 @@ jobs: username_secret: GHCR_USERNAME password_secret: GHCR_PAT type: remote - _merge: dummy - name: GitLab registry: registry.gitlab.com @@ -70,7 +54,6 @@ jobs: username_secret: GITLAB_USERNAME password_secret: GITLAB_TOKEN type: remote - _merge: dummy - name: AWS ECR registry: 175142243308.dkr.ecr.us-east-2.amazonaws.com @@ -78,7 +61,6 @@ jobs: username_secret: AWS_ACCESS_KEY_ID password_secret: AWS_SECRET_ACCESS_KEY type: remote - _merge: dummy - name: AWS ECR Public registry: public.ecr.aws @@ -86,7 +68,6 @@ jobs: username_secret: AWS_ACCESS_KEY_ID password_secret: AWS_SECRET_ACCESS_KEY type: remote - _merge: dummy - name: Google Artifact Registry registry: us-east4-docker.pkg.dev @@ -94,7 +75,6 @@ jobs: username_secret: GAR_USERNAME password_secret: GAR_JSON_KEY type: remote - _merge: dummy - name: Google Container Registry registry: gcr.io @@ -102,7 +82,6 @@ jobs: username_secret: GCR_USERNAME password_secret: GCR_JSON_KEY type: remote - _merge: dummy - name: Azure Container Registry registry: officialgithubactions.azurecr.io @@ -110,7 +89,6 @@ jobs: username_secret: AZURE_CLIENT_ID password_secret: AZURE_CLIENT_SECRET type: remote - _merge: dummy - name: Quay registry: quay.io @@ -118,7 +96,6 @@ jobs: username_secret: QUAY_USERNAME password_secret: QUAY_TOKEN type: remote - _merge: dummy - name: Artifactory registry: buildkitghactiontests.jfrog.io @@ -126,97 +103,27 @@ jobs: username_secret: ARTIFACTORY_USERNAME password_secret: ARTIFACTORY_TOKEN type: remote - _merge: dummy - name: Harbor id: harbor type: local - _merge: dummy - name: Nexus id: nexus type: local - _merge: dummy steps: - - - name: Checkout - uses: actions/checkout@v3 - name: Set up env if: matrix.type == 'local' run: | cat ./.github/e2e/${{ matrix.id }}/env >> $GITHUB_ENV - - name: Set up BuildKit config - run: | - touch /tmp/buildkitd.toml - if [ "${{ matrix.type }}" = "local" ]; then - echo -e "[registry.\"${{ env.REGISTRY_FQDN }}\"]\nhttp = true\ninsecure = true" > /tmp/buildkitd.toml - fi - - - name: Set up Docker daemon - if: matrix.type == 'local' - run: | - if [ ! -e /etc/docker/daemon.json ]; then - echo '{}' | tee /etc/docker/daemon.json >/dev/null - fi - DOCKERD_CONFIG=$(jq '.+{"insecure-registries":["http://${{ env.REGISTRY_FQDN }}"]}' /etc/docker/daemon.json) - sudo tee /etc/docker/daemon.json <<<"$DOCKERD_CONFIG" >/dev/null - sudo service docker restart - - - name: Install ${{ matrix.name }} - if: matrix.type == 'local' - run: | - sudo -E bash ./.github/e2e/${{ matrix.id }}/install.sh - - - name: Docker meta - id: meta - uses: docker/metadata-action@v4 - with: - images: ${{ env.REGISTRY_SLUG || matrix.slug }} - tags: | - type=ref,event=branch - type=ref,event=tag - type=raw,value=${{ inputs.tag }},enable=${{ inputs.tag != '' }} - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - with: - version: ${{ inputs.buildx-version || matrix.buildx_version }} - config: /tmp/buildkitd.toml - buildkitd-flags: --debug --allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host - driver-opts: | - image=${{ inputs.buildkit-image || matrix.buildkit_image }} - network=host - - - name: Login to Registry - if: github.event_name != 'pull_request' && (env.REGISTRY_USER || matrix.username_secret) != '' - uses: docker/login-action@v2 + uses: ./.github/workflows/.e2e-run.yml with: + id: ${{ matrix.id }} + type: ${{ matrix.type }} + name: ${{ matrix.name }} registry: ${{ env.REGISTRY_FQDN || matrix.registry }} + slug: ${{ env.REGISTRY_SLUG || matrix.slug }} username: ${{ env.REGISTRY_USER || secrets[matrix.username_secret] }} password: ${{ env.REGISTRY_PASSWORD || secrets[matrix.password_secret] }} - - - name: Build and push - uses: ./ - with: - context: ./test - file: ./test/multi.Dockerfile - platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - cache-from: type=registry,ref=${{ env.REGISTRY_SLUG || matrix.slug }}:master - cache-to: type=inline - - - name: Inspect image - run: | - docker pull ${{ env.REGISTRY_SLUG || matrix.slug }}:${{ steps.meta.outputs.version }} - docker image inspect ${{ env.REGISTRY_SLUG || matrix.slug }}:${{ steps.meta.outputs.version }} - - - name: Check manifest - run: | - docker buildx imagetools inspect ${{ env.REGISTRY_SLUG || matrix.slug }}:${{ steps.meta.outputs.version }} --format '{{json .}}'