Skip to content

Commit 9fbf1f2

Browse files
authored
Merge pull request #61 from cuviper/ci
ci: merge queue and registry caching
2 parents 50ecdb1 + 7e1321a commit 9fbf1f2

File tree

5 files changed

+53
-20
lines changed

5 files changed

+53
-20
lines changed

.github/workflows/ci.yaml

+24-8
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

@@ -14,7 +10,12 @@ jobs:
1410
matrix:
1511
rust: [1.56.0, stable, beta, nightly]
1612
steps:
17-
- uses: actions/checkout@v3
13+
- 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
1819
- uses: dtolnay/rust-toolchain@master
1920
with:
2021
toolchain: ${{ matrix.rust }}
@@ -26,7 +27,7 @@ jobs:
2627
name: No Std
2728
runs-on: ubuntu-latest
2829
steps:
29-
- uses: actions/checkout@v3
30+
- uses: actions/checkout@v4
3031
- uses: dtolnay/rust-toolchain@stable
3132
with:
3233
target: thumbv6m-none-eabi
@@ -38,8 +39,23 @@ jobs:
3839
name: Format
3940
runs-on: ubuntu-latest
4041
steps:
41-
- uses: actions/checkout@v3
42+
- uses: actions/checkout@v4
4243
- uses: dtolnay/[email protected]
4344
with:
4445
components: rustfmt
4546
- run: cargo fmt --all --check
47+
48+
# One job that "summarizes" the success state of this pipeline. This can then be added to branch
49+
# protection, rather than having to add each job separately.
50+
success:
51+
name: Success
52+
runs-on: ubuntu-latest
53+
needs: [test, no_std, fmt]
54+
# Github branch protection is exceedingly silly and treats "jobs skipped because a dependency
55+
# failed" as success. So we have to do some contortions to ensure the job fails if any of its
56+
# dependencies fails.
57+
if: always() # make sure this is never "skipped"
58+
steps:
59+
# Manually check the status of all dependencies. `if: failure()` does not work.
60+
- name: check if any dependency failed
61+
run: jq --exit-status 'all(.result == "success")' <<< '${{ toJson(needs) }}'

.github/workflows/master.yaml

+6-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ jobs:
1515
matrix:
1616
rust: [1.56.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

+22-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ jobs:
1111
matrix:
1212
rust: [1.56.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/[email protected]
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

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

bors.toml

-8
This file was deleted.

0 commit comments

Comments
 (0)