Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: rewrite the success job #97

Merged
merged 3 commits into from
Feb 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading