From bf96217849a2044856e362d1cd1be5e9e96280d5 Mon Sep 17 00:00:00 2001 From: Sergi Castro Date: Mon, 11 Nov 2024 21:51:08 +0100 Subject: [PATCH] Cancel in progress builds when pushing new commits to the same PR (#28) It also adds a final test job to be able to make it `required` regardless the values of the matrix --- .github/workflows/build.yaml | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 09454ac..0fc2c88 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,5 +1,9 @@ name: Build +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + on: push: tags: [ 'v[0-9]+.[0-9]+-tetrate-v[0-9]+' ] # v1.16-tetrate-v7 @@ -14,7 +18,7 @@ env: jobs: # All test running sequentially take around ~2h. # Sppliting them in groups that take more or less the same time makes PR's readiness faster - test: + test-group: strategy: matrix: label: @@ -33,3 +37,20 @@ jobs: with: go-version-file: go.mod - run: make test + + # Have a fixed test to run once matrix tests are completed so we can make this required + test: + runs-on: ubuntu-latest + # We need this to run always to force-fail (and not skip) if any needed + # job has failed. Otherwise, a skipped job will not fail the workflow. + if: always() + steps: + - run: | + echo "tests completed" + [ "${{ + contains(needs.*.result, 'failure') || + contains(needs.*.result, 'cancelled') || + contains(needs.*.result, 'skipped') + }}" == "false" ] || exit 1 + needs: + - test-group