Skip to content

Commit

Permalink
Merge pull request #97 from cuviper/ci
Browse files Browse the repository at this point in the history
ci: rewrite the success job
  • Loading branch information
cuviper committed Feb 10, 2024
2 parents af9f5fb + 6659d0c commit 361af9e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
24 changes: 19 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
on:
push:
branches: [ master ]
branches: [ main ]
pull_request:
branches: [ master ]
merge_group:

name: CI
Expand All @@ -26,6 +25,13 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Cache the registry
uses: actions/cache@v4
if: startsWith(matrix.rust, '1')
with:
path: ~/.cargo/registry/index
key: cargo-${{ matrix.rust }}-git-index

- name: Set up Rust
uses: dtolnay/rust-toolchain@master
with:
Expand Down Expand Up @@ -70,9 +76,17 @@ jobs:
- name: Clippy
run: cargo clippy # -- -D warnings

done:
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: [ci, clippy]
# 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
# 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) }}'
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ __ https://docs.rs/either/

|build_status|_ |crates|_

.. |build_status| image:: https://github.com/rayon-rs/either/workflows/CI/badge.svg?branch=master
.. |build_status| image:: https://github.com/rayon-rs/either/workflows/CI/badge.svg?branch=main
.. _build_status: https://github.com/rayon-rs/either/actions

.. |crates| image:: https://img.shields.io/crates/v/either.svg
Expand Down

0 comments on commit 361af9e

Please sign in to comment.