Skip to content

Commit 1b19446

Browse files
authored
Merge pull request #432 from cuviper/ci
ci: merge queue and registry caching
2 parents 7ce2990 + 8773888 commit 1b19446

File tree

5 files changed

+58
-23
lines changed

5 files changed

+58
-23
lines changed

.github/workflows/ci.yaml

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
name: CI
2-
on:
3-
push:
4-
branches:
5-
- staging
6-
- trying
2+
on: merge_group
73

84
jobs:
95

@@ -20,7 +16,12 @@ jobs:
2016
nightly
2117
]
2218
steps:
23-
- uses: actions/checkout@v3
19+
- uses: actions/checkout@v4
20+
- uses: actions/cache@v4
21+
if: startsWith(matrix.rust, '1')
22+
with:
23+
path: ~/.cargo/registry/index
24+
key: cargo-${{ matrix.rust }}-git-index
2425
- uses: dtolnay/rust-toolchain@master
2526
with:
2627
toolchain: ${{ matrix.rust }}
@@ -32,7 +33,7 @@ jobs:
3233
name: No Std (stable)
3334
runs-on: ubuntu-latest
3435
steps:
35-
- uses: actions/checkout@v3
36+
- uses: actions/checkout@v4
3637
- uses: dtolnay/rust-toolchain@stable
3738
with:
3839
target: thumbv6m-none-eabi
@@ -43,7 +44,11 @@ jobs:
4344
name: No Std (1.31.0)
4445
runs-on: ubuntu-latest
4546
steps:
46-
- uses: actions/checkout@v3
47+
- uses: actions/checkout@v4
48+
- uses: actions/cache@v4
49+
with:
50+
path: ~/.cargo/registry/index
51+
key: cargo-1.31.0-git-index
4752
- uses: dtolnay/rust-toolchain@1.31.0
4853
with:
4954
target: thumbv6m-none-eabi
@@ -54,8 +59,23 @@ jobs:
5459
name: Format
5560
runs-on: ubuntu-latest
5661
steps:
57-
- uses: actions/checkout@v3
62+
- uses: actions/checkout@v4
5863
- uses: dtolnay/rust-toolchain@1.62.0
5964
with:
6065
components: rustfmt
6166
- run: cargo fmt --all --check
67+
68+
# One job that "summarizes" the success state of this pipeline. This can then be added to branch
69+
# protection, rather than having to add each job separately.
70+
success:
71+
name: Success
72+
runs-on: ubuntu-latest
73+
needs: [test, no_std_131, no_std_stable, fmt]
74+
# Github branch protection is exceedingly silly and treats "jobs skipped because a dependency
75+
# failed" as success. So we have to do some contortions to ensure the job fails if any of its
76+
# dependencies fails.
77+
if: always() # make sure this is never "skipped"
78+
steps:
79+
# Manually check the status of all dependencies. `if: failure()` does not work.
80+
- name: check if any dependency failed
81+
run: jq --exit-status 'all(.result == "success")' <<< '${{ toJson(needs) }}'

.github/workflows/master.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ jobs:
1515
matrix:
1616
rust: [1.31.0, stable]
1717
steps:
18-
- uses: actions/checkout@v3
18+
- 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: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ jobs:
1111
matrix:
1212
rust: [1.31.0, stable]
1313
steps:
14-
- uses: actions/checkout@v3
14+
- 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 }}
@@ -22,8 +27,23 @@ jobs:
2227
name: Format
2328
runs-on: ubuntu-latest
2429
steps:
25-
- uses: actions/checkout@v3
30+
- uses: actions/checkout@v4
2631
- uses: dtolnay/rust-toolchain@1.62.0
2732
with:
2833
components: rustfmt
2934
- run: cargo fmt --all --check
35+
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
40+
runs-on: ubuntu-latest
41+
needs: [test, fmt]
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"
46+
steps:
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) }}'

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ repository = "https://github.com/rust-num/num"
1010
name = "num"
1111
version = "0.4.1"
1212
readme = "README.md"
13-
exclude = ["/bors.toml", "/ci/*", "/.github/*"]
13+
exclude = ["/ci/*", "/.github/*"]
1414
edition = "2018"
1515

1616
[package.metadata.docs.rs]

bors.toml

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)