Skip to content

Commit 04047f4

Browse files
authored
Merge pull request #26 from cuviper/ci
More CI updates
2 parents e582ad4 + 7f9ff72 commit 04047f4

File tree

3 files changed

+37
-20
lines changed

3 files changed

+37
-20
lines changed

.github/workflows/ci.yaml

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ jobs:
1111
rust: [1.31.0, stable, beta, nightly]
1212
steps:
1313
- uses: actions/checkout@v4
14+
- uses: actions/cache@v4
15+
if: startsWith(matrix.rust, '1')
16+
with:
17+
path: ~/.cargo/registry/index
18+
key: cargo-${{ matrix.rust }}-git-index
1419
- uses: dtolnay/rust-toolchain@master
1520
with:
1621
toolchain: ${{ matrix.rust }}
@@ -38,16 +43,17 @@ jobs:
3843
components: rustfmt
3944
- run: cargo fmt --all --check
4045

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

.github/workflows/master.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ jobs:
1616
rust: [1.31.0, stable]
1717
steps:
1818
- uses: actions/checkout@v4
19+
- uses: actions/cache@v4
20+
if: startsWith(matrix.rust, '1')
21+
with:
22+
path: ~/.cargo/registry/index
23+
key: cargo-${{ matrix.rust }}-git-index
1924
- uses: dtolnay/rust-toolchain@master
2025
with:
2126
toolchain: ${{ matrix.rust }}

.github/workflows/pr.yaml

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ jobs:
1212
rust: [1.31.0, stable]
1313
steps:
1414
- uses: actions/checkout@v4
15+
- uses: actions/cache@v4
16+
if: startsWith(matrix.rust, '1')
17+
with:
18+
path: ~/.cargo/registry/index
19+
key: cargo-${{ matrix.rust }}-git-index
1520
- uses: dtolnay/rust-toolchain@master
1621
with:
1722
toolchain: ${{ matrix.rust }}
@@ -28,16 +33,17 @@ jobs:
2833
components: rustfmt
2934
- run: cargo fmt --all --check
3035

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

0 commit comments

Comments
 (0)