Skip to content

Commit

Permalink
.github/{workflows,actions}: expect branch static check skipped on ma…
Browse files Browse the repository at this point in the history
…ster (#14809)
  • Loading branch information
ernestl authored Dec 6, 2024
1 parent 04b1bcd commit e64fff8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/actions/combine-results/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:"
Expand Down
19 changes: 18 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e64fff8

Please sign in to comment.