From 2513a9c4bf5d05eb1a7594f3cb7ab9dcde09c4c0 Mon Sep 17 00:00:00 2001 From: Momo Kornher Date: Mon, 29 Jul 2024 16:07:30 +0100 Subject: [PATCH] chore: fix ci PRs might get merged with failing tests (#1210) We had a PR https://github.com/aws/jsii-compiler/pull/1191 that got merged despite a failure in Node22 tests. This happened because on a failure of one of the matrix builds, the job that is unifying them is skipped. This is documented behavior: ![image](https://github.com/user-attachments/assets/c4eb7ae6-1b37-4f5e-91c4-65a5e5661514) The fix is to make sure the combination step always runs and manually check the status of the matrix build. --- By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license]. [Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0 (cherry picked from commit b06c1420041720989cb0ffbe70b6f31783749ece) --- .github/workflows/build.yml | 8 ++++++-- projenrc/build-workflow.ts | 13 ++++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b552802d..30ad8c1d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -141,9 +141,13 @@ jobs: permissions: {} env: CI: "true" + if: always() steps: - - name: Done - run: echo OK + - name: Build result + run: echo ${{needs.matrix-test.result}} + - name: Set status based on matrix build + if: ${{ needs.matrix-test.result != 'success' }} + run: exit 1 package: name: package needs: build diff --git a/projenrc/build-workflow.ts b/projenrc/build-workflow.ts index 4e0681af..5d419007 100644 --- a/projenrc/build-workflow.ts +++ b/projenrc/build-workflow.ts @@ -220,7 +220,18 @@ export class BuildWorkflow { needs: ['matrix-test'], permissions: {}, runsOn: ['ubuntu-latest'], - steps: [{ name: 'Done', run: 'echo OK' }], + if: 'always()', + steps: [ + { + name: 'Build result', + run: 'echo ${{needs.matrix-test.result}}', + }, + { + if: "${{ needs.matrix-test.result != 'success' }}", + name: 'Set status based on matrix build', + run: 'exit 1', + }, + ], }, 'package': { env: { CI: 'true' },