From d483030a1476ace7a5efcb9d2b206c2ac0d02ee4 Mon Sep 17 00:00:00 2001 From: leo Date: Sun, 5 Mar 2023 08:20:05 +0000 Subject: [PATCH] Fix (ci): Ensure `test-build` jobs precede `test-update` jobs to correctly test incremental builds (#112) Previously, the `test-update` job ran independently of the `test-build` job. The `test-update` job was not an incremental build based on the `test-build` job. Now, the two independent jobs are combined as one job, with `test-build` preceeding `test-update`. This properly tests incremental builds using the local docker cache. In order to prevent `test-update` from pulling a remote `:latest` image, but to use the `:latest` from the preceeding `test-build` step's build cache, `NO_PULL` is added for `PIPELINE=update`. Co-authored-by: leo Co-authored-by: joe --- .github/workflows/ci-master-pr.yml | 23 ++++++----------------- build.sh | 6 +++++- test/update-hlds-cstrike.env | 1 + test/update-srcds-hl2mp.env | 1 + 4 files changed, 13 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci-master-pr.yml b/.github/workflows/ci-master-pr.yml index 0c7aa181..4c52877c 100644 --- a/.github/workflows/ci-master-pr.yml +++ b/.github/workflows/ci-master-pr.yml @@ -16,7 +16,7 @@ jobs: if: github.event_name != 'pull_request' || github.repository_owner != 'startersclan' steps: - uses: actions/checkout@v3 - - name: Test + - name: Test build run: | set -a . ./test/build-hlds-cstrike.env @@ -24,13 +24,7 @@ jobs: env: STEAM_USERNAME: ${{ secrets.STEAM_USERNAME }} STEAM_PASSWORD: ${{ secrets.STEAM_PASSWORD }} - - test-update-hlds: - runs-on: ubuntu-20.04 - if: github.event_name != 'pull_request' || github.repository_owner != 'startersclan' - steps: - - uses: actions/checkout@v3 - - name: Test + - name: Test update run: | set -a . ./test/update-hlds-cstrike.env @@ -43,7 +37,7 @@ jobs: runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v3 - - name: Test + - name: Test build run: | set -a . ./test/build-srcds-hl2mp.env @@ -51,12 +45,7 @@ jobs: env: STEAM_USERNAME: ${{ secrets.STEAM_USERNAME }} STEAM_PASSWORD: ${{ secrets.STEAM_PASSWORD }} - - test-update-srcds: - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v3 - - name: Test + - name: Test update run: | set -a . ./test/update-srcds-hl2mp.env @@ -67,7 +56,7 @@ jobs: dockerhub-description-hlds: runs-on: ubuntu-20.04 - needs: [test-build-hlds, test-update-hlds] + needs: [test-build-hlds] if: github.ref == 'refs/heads/master' strategy: matrix: @@ -110,7 +99,7 @@ jobs: dockerhub-description-srcds: runs-on: ubuntu-20.04 - needs: [test-build-srcds, test-update-srcds] + needs: [test-build-srcds] if: github.ref == 'refs/heads/master' strategy: matrix: diff --git a/build.sh b/build.sh index 57bd6fde..a9599250 100755 --- a/build.sh +++ b/build.sh @@ -26,6 +26,7 @@ # FIX_APPMANIFEST= # bool - optional and only applicable to APPID=90 # LATEST=true # bool - optional # CACHE= # bool - optional +# NO_PULL= # bool - optional # NO_TEST= # bool - optional # NO_PUSH= # bool - optional # STEAM_LOGIN= # bool - optional @@ -66,6 +67,7 @@ elif [ "$PIPELINE" = 'update' ]; then APPID=${APPID:?err} GAME=${GAME:?err} GAME_UPDATE_COUNT=${GAME_UPDATE_COUNT:?err} + NO_PULL=${NO_PULL:-} NO_TEST=${NO_TEST:-} NO_PUSH=${NO_PUSH:-} STEAM_LOGIN=${STEAM_LOGIN:-} @@ -154,7 +156,9 @@ if [ "$PIPELINE" = 'build' ]; then elif [ "$PIPELINE" = 'update' ]; then GAME_IMAGE="$GAME_IMAGE_LATEST" date - time docker pull "$GAME_IMAGE" + if [ ! "$NO_PULL" = 'true' ]; then + time docker pull "$GAME_IMAGE" + fi date time docker build \ --secret id=STEAM_USERNAME,env=STEAM_USERNAME \ diff --git a/test/update-hlds-cstrike.env b/test/update-hlds-cstrike.env index cb0d7def..93f815c3 100644 --- a/test/update-hlds-cstrike.env +++ b/test/update-hlds-cstrike.env @@ -9,6 +9,7 @@ GAME_VERSION=1127 APPID=90 GAME=cstrike GAME_UPDATE_COUNT=1 +NO_PULL=true NO_TEST= NO_PUSH=true STEAM_LOGIN=true diff --git a/test/update-srcds-hl2mp.env b/test/update-srcds-hl2mp.env index 37f8fd66..cd86b7e2 100644 --- a/test/update-srcds-hl2mp.env +++ b/test/update-srcds-hl2mp.env @@ -9,6 +9,7 @@ GAME_VERSION=6630498 APPID=232370 GAME=hl2mp GAME_UPDATE_COUNT=1 +NO_PULL=true NO_TEST= NO_PUSH=true STEAM_LOGIN=