Skip to content

Commit

Permalink
Merge pull request #1125 from cuviper/ci-success
Browse files Browse the repository at this point in the history
ci: Use a single action to collect final status
  • Loading branch information
cuviper authored Feb 6, 2024
2 parents 5876c80 + 08162d3 commit aafcc8a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
21 changes: 11 additions & 10 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,17 @@ jobs:
components: rustfmt
- run: cargo fmt --all --check

ci-success:
name: Complete
# One job that "summarizes" the success state of this pipeline. This can then be added to branch
# protection, rather than having to add each job separately.
success:
name: Success
runs-on: ubuntu-latest
needs: [check, test, demo, i686, wasm, wasi, fmt]
# Github branch protection is exceedingly silly and treats "jobs skipped because a dependency
# failed" as success. So we have to do some contortions to ensure the job fails if any of its
# dependencies fails.
if: always() # make sure this is never "skipped"
steps:
- run: exit 0
ci-failed:
name: Complete
runs-on: ubuntu-latest
needs: [check, test, demo, i686, wasm, wasi, fmt]
if: failure()
steps:
- run: exit 1
# Manually check the status of all dependencies. `if: failure()` does not work.
- name: check if any dependency failed
run: jq --exit-status 'all(.result == "success")' <<< '${{ toJson(needs) }}'
21 changes: 11 additions & 10 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,17 @@ jobs:
components: rustfmt
- run: cargo fmt --all --check

ci-success:
name: Complete
# One job that "summarizes" the success state of this pipeline. This can then be added to branch
# protection, rather than having to add each job separately.
success:
name: Success
runs-on: ubuntu-latest
needs: [check, test, fmt]
# Github branch protection is exceedingly silly and treats "jobs skipped because a dependency
# failed" as success. So we have to do some contortions to ensure the job fails if any of its
# dependencies fails.
if: always() # make sure this is never "skipped"
steps:
- run: exit 0
ci-failed:
name: Complete
runs-on: ubuntu-latest
needs: [check, test, fmt]
if: failure()
steps:
- run: exit 1
# Manually check the status of all dependencies. `if: failure()` does not work.
- name: check if any dependency failed
run: jq --exit-status 'all(.result == "success")' <<< '${{ toJson(needs) }}'

0 comments on commit aafcc8a

Please sign in to comment.