From e64fff8ef5af1bc944d47f2871ddcdb9a075c679 Mon Sep 17 00:00:00 2001 From: Ernest Lotter Date: Fri, 6 Dec 2024 16:19:45 +0200 Subject: [PATCH] .github/{workflows,actions}: expect branch static check skipped on master (#14809) --- .github/actions/combine-results/action.yaml | 1 + .github/workflows/test.yaml | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/.github/actions/combine-results/action.yaml b/.github/actions/combine-results/action.yaml index 35eb5dfe217..6326bd26db2 100644 --- a/.github/actions/combine-results/action.yaml +++ b/.github/actions/combine-results/action.yaml @@ -16,6 +16,7 @@ runs: - name: Summarise and combine results shell: bash run: | + # Possible results are success, failed, cancelled, and skipped needs_results=$(echo '${{ inputs.needs-json }}' | jq -r 'to_entries[] | "\(.key) \(.value.result)"') echo "Summary:" diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index c36811f9750..34040783595 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -128,13 +128,30 @@ jobs: - branch-static-checks if: always() steps: + - name: Filter out branch-static-checks from needs + run: | + # The branch-static-checks job is skipped when testing on the master + # branch. The combine-results action treats skipped jobs as failed + # because a failure earlier in the chain (e.g., in cache-build-deps) + # would also cause branch-static-checks to be skipped, which + # constitutes a legitimate failure. To handle this, when + # branch-static-checks is skipped during testing on the master branch + # we remove it from the list of dependencies whose results are checked. + if [[ "${GITHUB_REF}" == "refs/heads/master" ]]; then + filtered_needs=$(echo '${{ toJSON(needs) }}' | jq 'del(.["branch-static-checks"])') + echo "NEEDS_FILTERED=$(echo $filtered_needs | jq -c)" >> $GITHUB_ENV + else + echo "NEEDS_FILTERED=$(echo '${{ toJSON(needs) }}' | jq -c)" >> $GITHUB_ENV + fi + shell: bash + - name: Checkout code uses: actions/checkout@v4 - name: Confirm required static checks passed uses: ./.github/actions/combine-results with: - needs-json: ${{ toJSON(needs) }} + needs-json: ${{ env.NEEDS_FILTERED }} unit-tests: uses: ./.github/workflows/unit-tests.yaml