From 3f69d54c9adfd27c4e99d698d6853b68c2e34fe9 Mon Sep 17 00:00:00 2001 From: Tim Kimber Date: Mon, 14 Jul 2025 16:09:20 +0100 Subject: [PATCH] Add docker/build-push-action to workflows for better caching MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Replace docker buildx build in run-test.sh with docker/build-push-action - Add GitHub Actions cache support (type=gha) to all test workflows - Update run-test.sh to use pre-built images when available - Maintain backward compatibility for local testing This should significantly improve CI build times by leveraging GitHub Actions cache instead of less efficient inline caching. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .github/workflows/run-tests-pebble.yml | 117 ++++++++++++++++++ .../workflows/run-tests-staging-acmedns.yml | 11 ++ .../workflows/run-tests-staging-duckdns.yml | 22 ++++ .github/workflows/run-tests-staging-dynu.yml | 22 ++++ test/run-test.sh | 5 +- 5 files changed, 176 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run-tests-pebble.yml b/.github/workflows/run-tests-pebble.yml index 2ecdc8e..151ec88 100644 --- a/.github/workflows/run-tests-pebble.yml +++ b/.github/workflows/run-tests-pebble.yml @@ -20,6 +20,15 @@ jobs: - uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + - name: Build test image + uses: docker/build-push-action@v5 + with: + context: . + file: test/Dockerfile-alpine + tags: getssl-alpine + load: true + cache-from: type=gha + cache-to: type=gha,mode=max - name: Build the docker compose stack run: | export DOCKER_BUILDKIT=1 @@ -34,6 +43,15 @@ jobs: - uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + - name: Build test image + uses: docker/build-push-action@v5 + with: + context: . + file: test/Dockerfile-bash4-0 + tags: getssl-bash4-0 + load: true + cache-from: type=gha + cache-to: type=gha,mode=max - name: Build the docker compose stack run: | export DOCKER_BUILDKIT=1 @@ -48,6 +66,15 @@ jobs: - uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + - name: Build test image + uses: docker/build-push-action@v5 + with: + context: . + file: test/Dockerfile-bash4-2 + tags: getssl-bash4-2 + load: true + cache-from: type=gha + cache-to: type=gha,mode=max - name: Build the docker compose stack run: | export DOCKER_BUILDKIT=1 @@ -62,6 +89,15 @@ jobs: - uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + - name: Build test image + uses: docker/build-push-action@v5 + with: + context: . + file: test/Dockerfile-bash5-0 + tags: getssl-bash5-0 + load: true + cache-from: type=gha + cache-to: type=gha,mode=max - name: Build the docker compose stack run: | export DOCKER_BUILDKIT=1 @@ -76,6 +112,15 @@ jobs: - uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + - name: Build test image + uses: docker/build-push-action@v5 + with: + context: . + file: test/Dockerfile-centos6 + tags: getssl-centos6 + load: true + cache-from: type=gha + cache-to: type=gha,mode=max - name: Build the docker compose stack run: | export DOCKER_BUILDKIT=1 @@ -90,6 +135,15 @@ jobs: - uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + - name: Build test image + uses: docker/build-push-action@v5 + with: + context: . + file: test/Dockerfile-centos7 + tags: getssl-centos7 + load: true + cache-from: type=gha + cache-to: type=gha,mode=max - name: Build the docker compose stack run: | export DOCKER_BUILDKIT=1 @@ -104,6 +158,15 @@ jobs: - uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + - name: Build test image + uses: docker/build-push-action@v5 + with: + context: . + file: test/Dockerfile-centos8 + tags: getssl-centos8 + load: true + cache-from: type=gha + cache-to: type=gha,mode=max - name: Build the docker compose stack run: | export DOCKER_BUILDKIT=1 @@ -118,6 +181,15 @@ jobs: - uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + - name: Build test image + uses: docker/build-push-action@v5 + with: + context: . + file: test/Dockerfile-debian + tags: getssl-debian + load: true + cache-from: type=gha + cache-to: type=gha,mode=max - name: Build the docker compose stack run: | export DOCKER_BUILDKIT=1 @@ -132,6 +204,15 @@ jobs: - uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + - name: Build test image + uses: docker/build-push-action@v5 + with: + context: . + file: test/Dockerfile-rockylinux8 + tags: getssl-rockylinux8 + load: true + cache-from: type=gha + cache-to: type=gha,mode=max - name: Build the docker compose stack run: | export DOCKER_BUILDKIT=1 @@ -146,6 +227,15 @@ jobs: - uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + - name: Build test image + uses: docker/build-push-action@v5 + with: + context: . + file: test/Dockerfile-ubuntu + tags: getssl-ubuntu + load: true + cache-from: type=gha + cache-to: type=gha,mode=max - name: Build the docker compose stack run: | export DOCKER_BUILDKIT=1 @@ -160,6 +250,15 @@ jobs: - uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + - name: Build test image + uses: docker/build-push-action@v5 + with: + context: . + file: test/Dockerfile-ubuntu14 + tags: getssl-ubuntu14 + load: true + cache-from: type=gha + cache-to: type=gha,mode=max - name: Build the docker compose stack run: | export DOCKER_BUILDKIT=1 @@ -174,6 +273,15 @@ jobs: - uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + - name: Build test image + uses: docker/build-push-action@v5 + with: + context: . + file: test/Dockerfile-ubuntu16 + tags: getssl-ubuntu16 + load: true + cache-from: type=gha + cache-to: type=gha,mode=max - name: Build the docker compose stack run: | export DOCKER_BUILDKIT=1 @@ -188,6 +296,15 @@ jobs: - uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + - name: Build test image + uses: docker/build-push-action@v5 + with: + context: . + file: test/Dockerfile-ubuntu18 + tags: getssl-ubuntu18 + load: true + cache-from: type=gha + cache-to: type=gha,mode=max - name: Build the docker compose stack run: | export DOCKER_BUILDKIT=1 diff --git a/.github/workflows/run-tests-staging-acmedns.yml b/.github/workflows/run-tests-staging-acmedns.yml index 17e6810..cf5612d 100644 --- a/.github/workflows/run-tests-staging-acmedns.yml +++ b/.github/workflows/run-tests-staging-acmedns.yml @@ -21,6 +21,17 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Build test image + uses: docker/build-push-action@v5 + with: + context: . + file: test/Dockerfile-ubuntu-acmedns + tags: getssl-ubuntu-acmedns + load: true + cache-from: type=gha + cache-to: type=gha,mode=max - name: Build the docker compose stack run: docker compose up -d --build - name: Run test suite on Ubuntu against Staging using acmedns diff --git a/.github/workflows/run-tests-staging-duckdns.yml b/.github/workflows/run-tests-staging-duckdns.yml index a599830..a888f31 100644 --- a/.github/workflows/run-tests-staging-duckdns.yml +++ b/.github/workflows/run-tests-staging-duckdns.yml @@ -8,6 +8,17 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Build test image + uses: docker/build-push-action@v5 + with: + context: . + file: test/Dockerfile-centos7-duckdns + tags: getssl-centos7-duckdns + load: true + cache-from: type=gha + cache-to: type=gha,mode=max - name: Build the docker compose stack run: docker compose up -d --build - name: Run test suite on CentOS7 against Staging using DuckDNS @@ -18,6 +29,17 @@ jobs: needs: test-centos7-duckdns steps: - uses: actions/checkout@v4 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Build test image + uses: docker/build-push-action@v5 + with: + context: . + file: test/Dockerfile-ubuntu-duckdns + tags: getssl-ubuntu-duckdns + load: true + cache-from: type=gha + cache-to: type=gha,mode=max - name: Build the docker compose stack run: docker compose up -d --build - name: Run test suite on Ubuntu against Staging using DuckDNS diff --git a/.github/workflows/run-tests-staging-dynu.yml b/.github/workflows/run-tests-staging-dynu.yml index 7d935c5..76ec8ea 100644 --- a/.github/workflows/run-tests-staging-dynu.yml +++ b/.github/workflows/run-tests-staging-dynu.yml @@ -8,6 +8,17 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Build test image + uses: docker/build-push-action@v5 + with: + context: . + file: test/Dockerfile-centos7-dynu + tags: getssl-centos7-dynu + load: true + cache-from: type=gha + cache-to: type=gha,mode=max - name: Build the docker compose stack run: docker compose up -d --build - name: Run test suite on CentOS7 against Staging using Dynu @@ -18,6 +29,17 @@ jobs: needs: test-centos7-dynu steps: - uses: actions/checkout@v4 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Build test image + uses: docker/build-push-action@v5 + with: + context: . + file: test/Dockerfile-ubuntu-dynu + tags: getssl-ubuntu-dynu + load: true + cache-from: type=gha + cache-to: type=gha,mode=max - name: Build the docker compose stack run: docker compose up -d --build - name: Run test suite on Ubuntu against Staging using Dynu diff --git a/test/run-test.sh b/test/run-test.sh index 814ec99..d9be619 100755 --- a/test/run-test.sh +++ b/test/run-test.sh @@ -68,7 +68,10 @@ else INT="" fi -docker buildx build --load --rm -f "test/Dockerfile-$OS" -t "getssl-$OS" --cache-from=type=gha --cache-to=type=gha,mode=max . +# Check if image already exists (built by GitHub Action), otherwise build it +if ! docker image inspect "getssl-$OS" >/dev/null 2>&1; then + docker buildx build --load --rm -f "test/Dockerfile-$OS" -t "getssl-$OS" --cache-from=type=gha --cache-to=type=gha,mode=max . +fi # shellcheck disable=SC2086 docker run $INT\ --env GETSSL_HOST=$ALIAS $STAGING \