From 4ef971402a7c3c646c74f7f2060bf47e2ba02f6d Mon Sep 17 00:00:00 2001 From: Marcus Young Date: Tue, 10 Sep 2024 13:02:36 -0500 Subject: [PATCH] Wrap all tests and docker/build-push-action into nick-fields/retry --- .github/workflows/base.yml | 152 +++++++++++--------- .github/workflows/deploy.yml | 257 +++++++++++++++++++--------------- .github/workflows/release.yml | 76 ++++++---- .github/workflows/test.yml | 180 +++++++++++++----------- 4 files changed, 372 insertions(+), 293 deletions(-) diff --git a/.github/workflows/base.yml b/.github/workflows/base.yml index 1b29677d..0c6a9e15 100644 --- a/.github/workflows/base.yml +++ b/.github/workflows/base.yml @@ -45,24 +45,31 @@ jobs: with: username: ${{ secrets.DOCKER_USER }} password: ${{ secrets.DOCKER_TOKEN }} - - name: Build - uses: docker/build-push-action@v6 + - name: Retry build and load + uses: nick-fields/retry@v3 with: - context: . - file: Dockerfile.base.ubuntu-${{ matrix.release }} - pull: true - push: false - load: true - tags: ${{ env.GH_RUNNER_IMAGE }} - platforms: linux/${{ matrix.platform }} - cache-from: type=gha - cache-to: type=gha,mode=max + timeout_minutes: 60 + max_attempts: 3 + command: | + docker buildx build \ + --file Dockerfile \ + --platform linux/${{ matrix.platform }} \ + --tag ${{ env.GH_RUNNER_IMAGE }} \ + --load \ + --pull \ + --cache-from type=gha \ + --cache-to type=gha,mode=max \ + . - name: Run goss tests - run: | - echo "os: ubuntu" >goss_vars_${GH_RUNNER_IMAGE}.yaml - echo "oscodename: ${{ matrix.release }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml - echo "arch: ${{ matrix.platform }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml - GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_base.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep -e RUNNER_NAME=test -e DEBUG_ONLY=true ${GH_RUNNER_IMAGE} 10 + uses: nick-fields/retry@v3 + with: + timeout_minutes: 60 + max_attempts: 3 + command: | + echo "os: ubuntu" >goss_vars_${GH_RUNNER_IMAGE}.yaml + echo "oscodename: ${{ matrix.release }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml + echo "arch: ${{ matrix.platform }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml + GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_base.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep -e RUNNER_NAME=test -e DEBUG_ONLY=true ${GH_RUNNER_IMAGE} 10 debian_base_tests: runs-on: ubuntu-latest @@ -97,24 +104,31 @@ jobs: with: username: ${{ secrets.DOCKER_USER }} password: ${{ secrets.DOCKER_TOKEN }} - - name: Build - uses: docker/build-push-action@v6 + - name: Retry build + uses: nick-fields/retry@v3 with: - context: . - file: Dockerfile.base.debian-${{ matrix.release }} - pull: true - push: false - load: true - tags: ${{ env.GH_RUNNER_IMAGE }} - platforms: linux/${{ matrix.platform }} - cache-from: type=gha - cache-to: type=gha,mode=max + timeout_minutes: 60 + max_attempts: 3 + command: | + docker buildx build \ + --file Dockerfile.base.debian-${{ matrix.release }} \ + --platform linux/${{ matrix.platform }} \ + --tag ${{ env.GH_RUNNER_IMAGE }} \ + --load \ + --pull \ + --cache-from type=gha \ + --cache-to type=gha,mode=max \ + . - name: Run goss tests - run: | - echo "os: debian" >goss_vars_${GH_RUNNER_IMAGE}.yaml - echo "oscodename: ${{ matrix.release }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml - echo "arch: ${{ matrix.platform }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml - GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_base.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep -e RUNNER_NAME=test -e DEBUG_ONLY=true ${GH_RUNNER_IMAGE} 10 + uses: nick-fields/retry@v3 + with: + timeout_minutes: 60 + max_attempts: 3 + command: | + echo "os: debian" >goss_vars_${GH_RUNNER_IMAGE}.yaml + echo "oscodename: ${{ matrix.release }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml + echo "arch: ${{ matrix.platform }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml + GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_base.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep -e RUNNER_NAME=test -e DEBUG_ONLY=true ${GH_RUNNER_IMAGE} 10 ubuntu_base_latest_deploy: @@ -134,18 +148,21 @@ jobs: with: username: ${{ secrets.DOCKER_USER }} password: ${{ secrets.DOCKER_TOKEN }} - - name: Build and push - uses: docker/build-push-action@v6 + - name: Retry build and push + uses: nick-fields/retry@v3 with: - context: . - file: Dockerfile.base - pull: true - push: true - tags: ${{ env.ORG }}/github-runner-base:latest - platforms: linux/amd64,linux/arm64 - cache-from: type=gha - cache-to: type=gha,mode=max - + timeout_minutes: 60 + max_attempts: 3 + command: | + docker buildx build \ + --file Dockerfile.base \ + --platform linux/amd64,linux/arm64 \ + --tag ${{ env.ORG }}/github-runner-base:latest \ + --push \ + --pull \ + --cache-from type=gha \ + --cache-to type=gha,mode=max \ + . ubuntu_base_deploy: runs-on: ubuntu-latest needs: ubuntu_base_tests @@ -169,18 +186,21 @@ jobs: with: username: ${{ secrets.DOCKER_USER }} password: ${{ secrets.DOCKER_TOKEN }} - - name: Build and push - uses: docker/build-push-action@v6 + - name: Retry build and push + uses: nick-fields/retry@v3 with: - context: . - file: Dockerfile.base.ubuntu-${{ matrix.release }} - pull: true - push: true - tags: ${{ env.ORG }}/github-runner-base:ubuntu-${{ matrix.release }} - platforms: linux/amd64,linux/arm64 - cache-from: type=gha - cache-to: type=gha,mode=max - + timeout_minutes: 60 + max_attempts: 3 + command: | + docker buildx build \ + --file Dockerfile.base.ubuntu-${{ matrix.release }} \ + --platform linux/amd64,linux/arm64 \ + --tag ${{ env.ORG }}/github-runner-base:ubuntu-${{ matrix.release }} \ + --push \ + --pull \ + --cache-from type=gha \ + --cache-to type=gha,mode=max \ + . debian_base_deploy: runs-on: ubuntu-latest needs: debian_base_tests @@ -204,14 +224,18 @@ jobs: with: username: ${{ secrets.DOCKER_USER }} password: ${{ secrets.DOCKER_TOKEN }} - - name: Build and push - uses: docker/build-push-action@v6 + - name: Retry build and push + uses: nick-fields/retry@v3 with: - context: . - file: Dockerfile.base.debian-${{ matrix.release }} - pull: true - push: true - tags: ${{ env.ORG }}/github-runner-base:debian-${{ matrix.release }} - platforms: linux/amd64,linux/arm64 - cache-from: type=gha - cache-to: type=gha,mode=max + timeout_minutes: 60 + max_attempts: 3 + command: | + docker buildx build \ + --file Dockerfile.base.debian-${{ matrix.release }} \ + --platform linux/amd64,linux/arm64 \ + --tag ${{ env.ORG }}/github-runner-base:debian-${{ matrix.release }} \ + --push \ + --pull \ + --cache-from type=gha \ + --cache-to type=gha,mode=max \ + . diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 44feb9e5..0120a130 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -48,51 +48,58 @@ jobs: with: username: ${{ secrets.DOCKER_USER }} password: ${{ secrets.DOCKER_TOKEN }} - - name: Build - uses: docker/build-push-action@v6 + - name: Retry build and load + uses: nick-fields/retry@v3 with: - context: . - file: Dockerfile.ubuntu-${{ matrix.release }} - pull: true - push: false - load: true - tags: ${{ env.GH_RUNNER_IMAGE }} - platforms: linux/${{ matrix.platform }} - cache-from: type=gha - cache-to: type=gha,mode=max + timeout_minutes: 60 + max_attempts: 3 + command: | + docker buildx build \ + --file Dockerfile.ubuntu-${{ matrix.release }} \ + --platform linux/${{ matrix.platform }} \ + --tag ${{ env.GH_RUNNER_IMAGE }} \ + --load \ + --pull \ + --cache-from type=gha \ + --cache-to type=gha,mode=max \ + . # Tests will run against the final `${GH_RUNNER_IMAGE}` laid on top of `base-${GH_RUNNER_IMAGE}` - name: Run goss tests - run: | - echo "os: ubuntu" >goss_vars_${GH_RUNNER_IMAGE}.yaml - echo "oscodename: ${{ matrix.release }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml - echo "arch: ${{ matrix.platform }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml - # test the base - GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_base.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep -e RUNNER_NAME=test -e DEBUG_ONLY=true ${GH_RUNNER_IMAGE} 10 - # test the final image but with all defaults - GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_full_defaults.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep -e RUNNER_NAME=test -e DEBUG_ONLY=true ${GH_RUNNER_IMAGE} 10 - # test the final image but with non-default values - GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_full.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep \ - -e DEBUG_ONLY=true \ - -e RUNNER_NAME=huzzah \ - -e REPO_URL=https://github.com/myoung34/docker-github-actions-runner \ - -e RUN_AS_ROOT=true \ - -e RUNNER_NAME_PREFIX=asdf \ - -e ACCESS_TOKEN=1234 \ - -e APP_ID=5678 \ - -e APP_PRIVATE_KEY=2345 \ - -e APP_LOGIN=SOMETHING \ - -e RUNNER_SCOPE=org \ - -e ORG_NAME=myoung34 \ - -e ENTERPRISE_NAME=emyoung34 \ - -e LABELS=blue,green \ - -e RUNNER_TOKEN=3456 \ - -e RUNNER_WORKDIR=/tmp/a \ - -e RUNNER_GROUP=wat \ - -e GITHUB_HOST=github.example.com \ - -e DISABLE_AUTOMATIC_DEREGISTRATION=true \ - -e EPHEMERAL=true \ - -e DISABLE_AUTO_UPDATE=true \ - ${GH_RUNNER_IMAGE} 10 + uses: nick-fields/retry@v3 + with: + timeout_minutes: 60 + max_attempts: 3 + command: | + echo "os: ubuntu" >goss_vars_${GH_RUNNER_IMAGE}.yaml + echo "oscodename: ${{ matrix.release }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml + echo "arch: ${{ matrix.platform }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml + # test the base + GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_base.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep -e RUNNER_NAME=test -e DEBUG_ONLY=true ${GH_RUNNER_IMAGE} 10 + # test the final image but with all defaults + GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_full_defaults.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep -e RUNNER_NAME=test -e DEBUG_ONLY=true ${GH_RUNNER_IMAGE} 10 + # test the final image but with non-default values + GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_full.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep \ + -e DEBUG_ONLY=true \ + -e RUNNER_NAME=huzzah \ + -e REPO_URL=https://github.com/myoung34/docker-github-actions-runner \ + -e RUN_AS_ROOT=true \ + -e RUNNER_NAME_PREFIX=asdf \ + -e ACCESS_TOKEN=1234 \ + -e APP_ID=5678 \ + -e APP_PRIVATE_KEY=2345 \ + -e APP_LOGIN=SOMETHING \ + -e RUNNER_SCOPE=org \ + -e ORG_NAME=myoung34 \ + -e ENTERPRISE_NAME=emyoung34 \ + -e LABELS=blue,green \ + -e RUNNER_TOKEN=3456 \ + -e RUNNER_WORKDIR=/tmp/a \ + -e RUNNER_GROUP=wat \ + -e GITHUB_HOST=github.example.com \ + -e DISABLE_AUTOMATIC_DEREGISTRATION=true \ + -e EPHEMERAL=true \ + -e DISABLE_AUTO_UPDATE=true \ + ${GH_RUNNER_IMAGE} 10 debian_tests: runs-on: ubuntu-latest @@ -127,51 +134,58 @@ jobs: with: username: ${{ secrets.DOCKER_USER }} password: ${{ secrets.DOCKER_TOKEN }} - - name: Build - uses: docker/build-push-action@v6 + - name: Retry build and load + uses: nick-fields/retry@v3 with: - context: . - file: Dockerfile.debian-${{ matrix.release }} - pull: true - push: false - load: true - tags: ${{ env.GH_RUNNER_IMAGE }} - platforms: linux/${{ matrix.platform }} - cache-from: type=gha - cache-to: type=gha,mode=max + timeout_minutes: 60 + max_attempts: 3 + command: | + docker buildx build \ + --file Dockerfile.debian-${{ matrix.release }} \ + --platform linux/${{ matrix.platform }} \ + --tag ${{ env.GH_RUNNER_IMAGE }} \ + --load \ + --pull \ + --cache-from type=gha \ + --cache-to type=gha,mode=max \ + . # Tests will run against the final `${GH_RUNNER_IMAGE}` laid on top of `base-${GH_RUNNER_IMAGE}` - name: Run goss tests - run: | - echo "os: debian" >goss_vars_${GH_RUNNER_IMAGE}.yaml - echo "oscodename: ${{ matrix.release }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml - echo "arch: ${{ matrix.platform }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml - # test the base - GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_base.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep -e RUNNER_NAME=test -e DEBUG_ONLY=true ${GH_RUNNER_IMAGE} 10 - # test the final image but with all defaults - GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_full_defaults.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep -e RUNNER_NAME=test -e DEBUG_ONLY=true ${GH_RUNNER_IMAGE} 10 - # test the final image but with non-default values - GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_full.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep \ - -e DEBUG_ONLY=true \ - -e RUNNER_NAME=huzzah \ - -e REPO_URL=https://github.com/myoung34/docker-github-actions-runner \ - -e RUN_AS_ROOT=true \ - -e RUNNER_NAME_PREFIX=asdf \ - -e ACCESS_TOKEN=1234 \ - -e APP_ID=5678 \ - -e APP_PRIVATE_KEY=2345 \ - -e APP_LOGIN=SOMETHING \ - -e RUNNER_SCOPE=org \ - -e ORG_NAME=myoung34 \ - -e ENTERPRISE_NAME=emyoung34 \ - -e LABELS=blue,green \ - -e RUNNER_TOKEN=3456 \ - -e RUNNER_WORKDIR=/tmp/a \ - -e RUNNER_GROUP=wat \ - -e GITHUB_HOST=github.example.com \ - -e DISABLE_AUTOMATIC_DEREGISTRATION=true \ - -e EPHEMERAL=true \ - -e DISABLE_AUTO_UPDATE=true \ - ${GH_RUNNER_IMAGE} 10 + uses: nick-fields/retry@v3 + with: + timeout_minutes: 60 + max_attempts: 3 + command: | + echo "os: debian" >goss_vars_${GH_RUNNER_IMAGE}.yaml + echo "oscodename: ${{ matrix.release }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml + echo "arch: ${{ matrix.platform }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml + # test the base + GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_base.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep -e RUNNER_NAME=test -e DEBUG_ONLY=true ${GH_RUNNER_IMAGE} 10 + # test the final image but with all defaults + GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_full_defaults.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep -e RUNNER_NAME=test -e DEBUG_ONLY=true ${GH_RUNNER_IMAGE} 10 + # test the final image but with non-default values + GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_full.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep \ + -e DEBUG_ONLY=true \ + -e RUNNER_NAME=huzzah \ + -e REPO_URL=https://github.com/myoung34/docker-github-actions-runner \ + -e RUN_AS_ROOT=true \ + -e RUNNER_NAME_PREFIX=asdf \ + -e ACCESS_TOKEN=1234 \ + -e APP_ID=5678 \ + -e APP_PRIVATE_KEY=2345 \ + -e APP_LOGIN=SOMETHING \ + -e RUNNER_SCOPE=org \ + -e ORG_NAME=myoung34 \ + -e ENTERPRISE_NAME=emyoung34 \ + -e LABELS=blue,green \ + -e RUNNER_TOKEN=3456 \ + -e RUNNER_WORKDIR=/tmp/a \ + -e RUNNER_GROUP=wat \ + -e GITHUB_HOST=github.example.com \ + -e DISABLE_AUTOMATIC_DEREGISTRATION=true \ + -e EPHEMERAL=true \ + -e DISABLE_AUTO_UPDATE=true \ + ${GH_RUNNER_IMAGE} 10 ubuntu_latest_deploy: runs-on: ubuntu-latest @@ -198,17 +212,22 @@ jobs: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and push - uses: docker/build-push-action@v6 + - name: Retry build and push + uses: nick-fields/retry@v3 with: - context: . - file: Dockerfile - pull: true - push: true - tags: ${{ env.ORG }}/github-runner:latest,ghcr.io/${{ github.repository }}:latest - platforms: linux/amd64,linux/arm64 - cache-from: type=gha - cache-to: type=gha,mode=max + timeout_minutes: 60 + max_attempts: 3 + command: | + docker buildx build \ + --file Dockerfile \ + --platform linux/amd64,linux/arm64 \ + --tag ${{ env.ORG }}/github-runner:latest \ + --tag ghcr.io/${{ github.repository }}:latest \ + --push \ + --pull \ + --cache-from type=gha \ + --cache-to type=gha,mode=max \ + . ubuntu_deploy: runs-on: ubuntu-latest @@ -239,17 +258,22 @@ jobs: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and push - uses: docker/build-push-action@v6 + - name: Retry build and push + uses: nick-fields/retry@v3 with: - context: . - file: Dockerfile.ubuntu-${{ matrix.release }} - pull: true - push: true - tags: ${{env.ORG}}/github-runner:ubuntu-${{ matrix.release }},ghcr.io/${{ github.repository }}:ubuntu-${{ matrix.release }} - platforms: linux/amd64,linux/arm64 - cache-from: type=gha - cache-to: type=gha,mode=max + timeout_minutes: 60 + max_attempts: 3 + command: | + docker buildx build \ + --file Dockerfile.ubuntu-${{ matrix.release }} \ + --platform linux/amd64,linux/arm64 \ + --tag ${{ env.ORG }}/github-runner:ubuntu-${{ matrix.release }} \ + --tag ghcr.io/${{ github.repository }}:ubuntu-${{ matrix.release }} \ + --push \ + --pull \ + --cache-from type=gha \ + --cache-to type=gha,mode=max \ + . debian_deploy: runs-on: ubuntu-latest @@ -280,14 +304,19 @@ jobs: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and push - uses: docker/build-push-action@v6 + - name: Retry build and push + uses: nick-fields/retry@v3 with: - context: . - file: Dockerfile.debian-${{ matrix.release }} - pull: true - push: true - tags: ${{ env.ORG }}/github-runner:debian-${{ matrix.release }},ghcr.io/${{ github.repository }}:debian-${{ matrix.release }} - platforms: linux/amd64,linux/arm64 - cache-from: type=gha - cache-to: type=gha,mode=max + timeout_minutes: 60 + max_attempts: 3 + command: | + docker buildx build \ + --file Dockerfile.debian-${{ matrix.release }} \ + --platform linux/amd64,linux/arm64 \ + --tag ${{ env.ORG }}/github-runner:debian-${{ matrix.release }} \ + --tag ghcr.io/${{ github.repository }}:debian-${{ matrix.release }} \ + --push \ + --pull \ + --cache-from type=gha \ + --cache-to type=gha,mode=max \ + . diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0dccd9f2..efc40862 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -53,17 +53,22 @@ jobs: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and push - uses: docker/build-push-action@v6 + - name: Retry build and push + uses: nick-fields/retry@v3 with: - context: . - file: Dockerfile - pull: true - push: true - tags: ${{ env.ORG }}/github-runner:${{ env.TAG }},ghcr.io/${{ github.repository }}:${{ env.TAG }} - platforms: linux/amd64,linux/arm64 - cache-from: type=gha - cache-to: type=gha,mode=max + timeout_minutes: 60 + max_attempts: 3 + command: | + docker buildx build \ + --file Dockerfile \ + --platform linux/amd64,linux/arm64 \ + --tag ${{ env.ORG }}/github-runner:${{ env.TAG }} \ + --tag ghcr.io/${{ github.repository }}:${{ env.TAG }} \ + --push \ + --pull \ + --cache-from type=gha \ + --cache-to type=gha,mode=max \ + . ubuntu_tag: runs-on: ubuntu-latest @@ -96,18 +101,22 @@ jobs: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and push - uses: docker/build-push-action@v6 + - name: Retry build and push + uses: nick-fields/retry@v3 with: - context: . - file: Dockerfile.ubuntu-${{ matrix.release }} - pull: true - push: true - tags: ${{ env.ORG }}/github-runner:${{ env.TAG }}-ubuntu-${{ matrix.release }},ghcr.io/${{ github.repository }}:${{ env.TAG }}-ubuntu-${{ matrix.release }} - platforms: linux/amd64,linux/arm64 - cache-from: type=gha - cache-to: type=gha,mode=max - + timeout_minutes: 60 + max_attempts: 3 + command: | + docker buildx build \ + --file Dockerfile.ubuntu-${{ matrix.release }} \ + --platform linux/amd64,linux/arm64 \ + --tag ${{ env.ORG }}/github-runner:${{ env.TAG }}-ubuntu-${{ matrix.release }} \ + --tag ghcr.io/${{ github.repository }}:${{ env.TAG }}-ubuntu-${{ matrix.release }} \ + --push \ + --pull \ + --cache-from type=gha \ + --cache-to type=gha,mode=max \ + . debian_tag: runs-on: ubuntu-latest strategy: @@ -139,14 +148,19 @@ jobs: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and push - uses: docker/build-push-action@v6 + - name: Retry build and push + uses: nick-fields/retry@v3 with: - context: . - file: Dockerfile.debian-${{ matrix.release }} - pull: true - push: true - tags: ${{ env.ORG }}/github-runner:${{ env.TAG }}-debian-${{ matrix.release }},ghcr.io/${{ github.repository }}:${{ env.TAG }}-debian-${{ matrix.release }} - platforms: linux/amd64,linux/arm64 - cache-from: type=gha - cache-to: type=gha,mode=max + timeout_minutes: 60 + max_attempts: 3 + command: | + docker buildx build \ + --file Dockerfile.debian-${{ matrix.release }} \ + --platform linux/amd64,linux/arm64 \ + --tag ${{ env.ORG }}/github-runner:${{ env.TAG }}-debian-${{ matrix.release }} \ + --tag ghcr.io/${{ github.repository }}:${{ env.TAG }}-debian-${{ matrix.release }} \ + --push \ + --pull \ + --cache-from type=gha \ + --cache-to type=gha,mode=max \ + . diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cd70af70..15d75a54 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -51,51 +51,57 @@ jobs: # Sanity check grep FROM Dockerfile.final.ubuntu-${{ matrix.release }} - - name: Build final image - uses: docker/build-push-action@v6 + - name: Retry build final image + uses: nick-fields/retry@v3 with: - context: . - file: Dockerfile.final.ubuntu-${{ matrix.release }} - pull: true - push: false - load: true - tags: ${{ env.GH_RUNNER_IMAGE }} - platforms: linux/${{ matrix.platform }} - cache-from: type=gha - cache-to: type=gha,mode=max + timeout_minutes: 60 + max_attempts: 3 + command: | + docker buildx build \ + --file Dockerfile.final.ubuntu-${{ matrix.release }} \ + --platform linux/${{ matrix.platform }} \ + --tag ${{ env.GH_RUNNER_IMAGE }} \ + --load \ + --cache-from type=gha \ + --cache-to type=gha,mode=max \ + . # Tests will run against the final `${GH_RUNNER_IMAGE}` laid on top of `base-${GH_RUNNER_IMAGE}` - name: Run goss tests - run: | - echo "os: ubuntu" >goss_vars_${GH_RUNNER_IMAGE}.yaml - echo "oscodename: ${{ matrix.release }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml - echo "arch: ${{ matrix.platform }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml - # test the base - GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_base.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep -e RUNNER_NAME=test -e DEBUG_ONLY=true ${GH_RUNNER_IMAGE} 10 - # test the final image but with all defaults - GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_full_defaults.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep -e RUNNER_NAME=test -e DEBUG_ONLY=true ${GH_RUNNER_IMAGE} 10 - # test the final image but with non-default values - GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_full.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep \ - -e DEBUG_ONLY=true \ - -e RUNNER_NAME=huzzah \ - -e REPO_URL=https://github.com/myoung34/docker-github-actions-runner \ - -e RUN_AS_ROOT=true \ - -e RUNNER_NAME_PREFIX=asdf \ - -e ACCESS_TOKEN=1234 \ - -e APP_ID=5678 \ - -e APP_PRIVATE_KEY=2345 \ - -e APP_LOGIN=SOMETHING \ - -e RUNNER_SCOPE=org \ - -e ORG_NAME=myoung34 \ - -e ENTERPRISE_NAME=emyoung34 \ - -e LABELS=blue,green \ - -e RUNNER_TOKEN=3456 \ - -e RUNNER_WORKDIR=/tmp/a \ - -e RUNNER_GROUP=wat \ - -e GITHUB_HOST=github.example.com \ - -e DISABLE_AUTOMATIC_DEREGISTRATION=true \ - -e EPHEMERAL=true \ - -e DISABLE_AUTO_UPDATE=true \ - ${GH_RUNNER_IMAGE} 10 + uses: nick-fields/retry@v3 + with: + timeout_minutes: 60 + max_attempts: 3 + command: | + echo "os: ubuntu" >goss_vars_${GH_RUNNER_IMAGE}.yaml + echo "oscodename: ${{ matrix.release }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml + echo "arch: ${{ matrix.platform }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml + # test the base + GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_base.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep -e RUNNER_NAME=test -e DEBUG_ONLY=true ${GH_RUNNER_IMAGE} 10 + # test the final image but with all defaults + GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_full_defaults.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep -e RUNNER_NAME=test -e DEBUG_ONLY=true ${GH_RUNNER_IMAGE} 10 + # test the final image but with non-default values + GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_full.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep \ + -e DEBUG_ONLY=true \ + -e RUNNER_NAME=huzzah \ + -e REPO_URL=https://github.com/myoung34/docker-github-actions-runner \ + -e RUN_AS_ROOT=true \ + -e RUNNER_NAME_PREFIX=asdf \ + -e ACCESS_TOKEN=1234 \ + -e APP_ID=5678 \ + -e APP_PRIVATE_KEY=2345 \ + -e APP_LOGIN=SOMETHING \ + -e RUNNER_SCOPE=org \ + -e ORG_NAME=myoung34 \ + -e ENTERPRISE_NAME=emyoung34 \ + -e LABELS=blue,green \ + -e RUNNER_TOKEN=3456 \ + -e RUNNER_WORKDIR=/tmp/a \ + -e RUNNER_GROUP=wat \ + -e GITHUB_HOST=github.example.com \ + -e DISABLE_AUTOMATIC_DEREGISTRATION=true \ + -e EPHEMERAL=true \ + -e DISABLE_AUTO_UPDATE=true \ + ${GH_RUNNER_IMAGE} 10 debian_tests: runs-on: ubuntu-latest @@ -134,48 +140,54 @@ jobs: # Sanity check grep FROM Dockerfile.final.debian-${{ matrix.release }} - - name: Build final image - uses: docker/build-push-action@v6 + - name: Retry build final image + uses: nick-fields/retry@v3 with: - context: . - file: Dockerfile.final.debian-${{ matrix.release }} - pull: true - push: false - load: true - tags: ${{ env.GH_RUNNER_IMAGE }} - platforms: linux/${{ matrix.platform }} - cache-from: type=gha - cache-to: type=gha,mode=max + timeout_minutes: 60 + max_attempts: 3 + command: | + docker buildx build \ + --file Dockerfile.final.debian-${{ matrix.release }} \ + --platform linux/${{ matrix.platform }} \ + --tag ${{ env.GH_RUNNER_IMAGE }} \ + --load \ + --cache-from type=gha \ + --cache-to type=gha,mode=max \ + . # Tests will run against the final `${GH_RUNNER_IMAGE}` laid on top of `base-${GH_RUNNER_IMAGE}` - name: Run goss tests - run: | - echo "os: debian" >goss_vars_${GH_RUNNER_IMAGE}.yaml - echo "oscodename: ${{ matrix.release }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml - echo "arch: ${{ matrix.platform }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml - # test the base - GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_base.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep -e RUNNER_NAME=test -e DEBUG_ONLY=true ${GH_RUNNER_IMAGE} 10 - # test the final image but with all defaults - GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_full_defaults.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep -e RUNNER_NAME=test -e DEBUG_ONLY=true ${GH_RUNNER_IMAGE} 10 - # test the final image but with non-default values - GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_full.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep \ - -e DEBUG_ONLY=true \ - -e RUNNER_NAME=huzzah \ - -e REPO_URL=https://github.com/myoung34/docker-github-actions-runner \ - -e RUN_AS_ROOT=true \ - -e RUNNER_NAME_PREFIX=asdf \ - -e ACCESS_TOKEN=1234 \ - -e APP_ID=5678 \ - -e APP_PRIVATE_KEY=2345 \ - -e APP_LOGIN=SOMETHING \ - -e RUNNER_SCOPE=org \ - -e ORG_NAME=myoung34 \ - -e ENTERPRISE_NAME=emyoung34 \ - -e LABELS=blue,green \ - -e RUNNER_TOKEN=3456 \ - -e RUNNER_WORKDIR=/tmp/a \ - -e RUNNER_GROUP=wat \ - -e GITHUB_HOST=github.example.com \ - -e DISABLE_AUTOMATIC_DEREGISTRATION=true \ - -e EPHEMERAL=true \ - -e DISABLE_AUTO_UPDATE=true \ - ${GH_RUNNER_IMAGE} 10 + uses: nick-fields/retry@v3 + with: + timeout_minutes: 60 + max_attempts: 3 + command: | + echo "os: debian" >goss_vars_${GH_RUNNER_IMAGE}.yaml + echo "oscodename: ${{ matrix.release }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml + echo "arch: ${{ matrix.platform }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml + # test the base + GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_base.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep -e RUNNER_NAME=test -e DEBUG_ONLY=true ${GH_RUNNER_IMAGE} 10 + # test the final image but with all defaults + GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_full_defaults.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep -e RUNNER_NAME=test -e DEBUG_ONLY=true ${GH_RUNNER_IMAGE} 10 + # test the final image but with non-default values + GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_full.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep \ + -e DEBUG_ONLY=true \ + -e RUNNER_NAME=huzzah \ + -e REPO_URL=https://github.com/myoung34/docker-github-actions-runner \ + -e RUN_AS_ROOT=true \ + -e RUNNER_NAME_PREFIX=asdf \ + -e ACCESS_TOKEN=1234 \ + -e APP_ID=5678 \ + -e APP_PRIVATE_KEY=2345 \ + -e APP_LOGIN=SOMETHING \ + -e RUNNER_SCOPE=org \ + -e ORG_NAME=myoung34 \ + -e ENTERPRISE_NAME=emyoung34 \ + -e LABELS=blue,green \ + -e RUNNER_TOKEN=3456 \ + -e RUNNER_WORKDIR=/tmp/a \ + -e RUNNER_GROUP=wat \ + -e GITHUB_HOST=github.example.com \ + -e DISABLE_AUTOMATIC_DEREGISTRATION=true \ + -e EPHEMERAL=true \ + -e DISABLE_AUTO_UPDATE=true \ + ${GH_RUNNER_IMAGE} 10