|
1 |
| ---- |
2 |
| -name: Rust |
| 1 | +# Maintained in https://github.com/coreos/repo-templates |
| 2 | +# Do not edit downstream. |
3 | 3 |
|
| 4 | +name: Rust |
4 | 5 | on:
|
5 | 6 | push:
|
6 | 7 | branches: [main]
|
7 | 8 | pull_request:
|
8 | 9 | branches: [main]
|
9 |
| - |
10 | 10 | permissions:
|
11 | 11 | contents: read
|
12 | 12 |
|
| 13 | +# don't waste job slots on superseded code |
| 14 | +concurrency: |
| 15 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 16 | + cancel-in-progress: true |
| 17 | + |
13 | 18 | env:
|
14 | 19 | CARGO_TERM_COLOR: always
|
15 | 20 | # Pinned toolchain for linting
|
16 | 21 | ACTIONS_LINTS_TOOLCHAIN: 1.69.0
|
17 | 22 |
|
18 | 23 | jobs:
|
19 | 24 | tests-stable:
|
20 |
| - name: "Tests, stable toolchain" |
| 25 | + name: Tests, stable toolchain |
21 | 26 | runs-on: ubuntu-latest
|
22 | 27 | steps:
|
23 |
| - - name: Checkout repository |
| 28 | + - name: Check out repository |
24 | 29 | uses: actions/checkout@v3
|
25 | 30 | - name: Install toolchain
|
26 | 31 | uses: dtolnay/rust-toolchain@v1
|
27 | 32 | with:
|
28 | 33 | toolchain: stable
|
| 34 | + - name: Cache build artifacts |
| 35 | + uses: Swatinem/rust-cache@v2 |
29 | 36 | - name: cargo build
|
30 |
| - run: cargo build |
| 37 | + run: cargo build --all-targets |
31 | 38 | - name: cargo test
|
32 |
| - run: cargo test |
33 |
| - tests-msrv: |
34 |
| - name: "Tests, minimum supported toolchain" |
| 39 | + run: cargo test --all-targets |
| 40 | + tests-release-stable: |
| 41 | + name: Tests (release), stable toolchain |
| 42 | + runs-on: ubuntu-latest |
| 43 | + steps: |
| 44 | + - name: Check out repository |
| 45 | + uses: actions/checkout@v3 |
| 46 | + - name: Install toolchain |
| 47 | + uses: dtolnay/rust-toolchain@v1 |
| 48 | + with: |
| 49 | + toolchain: stable |
| 50 | + - name: Cache build artifacts |
| 51 | + uses: Swatinem/rust-cache@v2 |
| 52 | + - name: cargo build (release) |
| 53 | + run: cargo build --all-targets --release |
| 54 | + - name: cargo test (release) |
| 55 | + run: cargo test --all-targets --release |
| 56 | + tests-release-msrv: |
| 57 | + name: Tests (release), minimum supported toolchain |
35 | 58 | runs-on: ubuntu-latest
|
36 | 59 | steps:
|
37 |
| - - name: Checkout repository |
| 60 | + - name: Check out repository |
38 | 61 | uses: actions/checkout@v3
|
39 | 62 | - name: Detect crate MSRV
|
40 |
| - shell: bash |
41 | 63 | run: |
|
42 | 64 | msrv=$(cargo metadata --format-version 1 --no-deps | \
|
43 |
| - jq -r '.packages | .[].rust_version') |
| 65 | + jq -r '.packages[0].rust_version') |
44 | 66 | echo "Crate MSRV: $msrv"
|
45 | 67 | echo "MSRV=$msrv" >> $GITHUB_ENV
|
46 | 68 | - name: Install toolchain
|
47 | 69 | uses: dtolnay/rust-toolchain@v1
|
48 | 70 | with:
|
49 | 71 | toolchain: ${{ env.MSRV }}
|
50 |
| - - name: cargo build |
51 |
| - run: cargo build |
52 |
| - - name: cargo test |
53 |
| - run: cargo test |
54 |
| - lints: |
55 |
| - name: "Lints, pinned toolchain" |
| 72 | + - name: Cache build artifacts |
| 73 | + uses: Swatinem/rust-cache@v2 |
| 74 | + - name: cargo build (release) |
| 75 | + run: cargo build --all-targets --release |
| 76 | + - name: cargo test (release) |
| 77 | + run: cargo test --all-targets --release |
| 78 | + linting: |
| 79 | + name: Lints, pinned toolchain |
56 | 80 | runs-on: ubuntu-latest
|
57 | 81 | steps:
|
58 |
| - - name: Checkout repository |
| 82 | + - name: Check out repository |
59 | 83 | uses: actions/checkout@v3
|
60 | 84 | - name: Install toolchain
|
61 | 85 | uses: dtolnay/rust-toolchain@v1
|
62 | 86 | with:
|
63 |
| - toolchain: ${{ env['ACTIONS_LINTS_TOOLCHAIN'] }} |
| 87 | + toolchain: ${{ env.ACTIONS_LINTS_TOOLCHAIN }} |
64 | 88 | components: rustfmt, clippy
|
| 89 | + - name: Cache build artifacts |
| 90 | + uses: Swatinem/rust-cache@v2 |
65 | 91 | - name: cargo fmt (check)
|
66 | 92 | run: cargo fmt -- --check -l
|
67 | 93 | - name: cargo clippy (warnings)
|
68 |
| - run: cargo clippy -- -D warnings |
69 |
| - - name: cargo build |
70 |
| - run: cargo build |
| 94 | + run: cargo clippy --all-targets -- -D warnings |
71 | 95 | tests-other-channels:
|
72 |
| - name: "Tests, unstable toolchain" |
| 96 | + name: Tests, unstable toolchain |
73 | 97 | runs-on: ubuntu-latest
|
74 | 98 | continue-on-error: true
|
75 | 99 | strategy:
|
76 | 100 | matrix:
|
77 |
| - channel: |
78 |
| - - beta |
79 |
| - - nightly |
| 101 | + channel: [beta, nightly] |
80 | 102 | steps:
|
81 |
| - - name: Checkout repository |
| 103 | + - name: Check out repository |
82 | 104 | uses: actions/checkout@v3
|
83 | 105 | - name: Install toolchain
|
84 | 106 | uses: dtolnay/rust-toolchain@v1
|
85 | 107 | with:
|
86 | 108 | toolchain: ${{ matrix.channel }}
|
| 109 | + - name: Cache build artifacts |
| 110 | + uses: Swatinem/rust-cache@v2 |
87 | 111 | - name: cargo build
|
88 |
| - run: cargo build |
| 112 | + run: cargo build --all-targets |
89 | 113 | - name: cargo test
|
90 |
| - run: cargo test |
| 114 | + run: cargo test --all-targets |
0 commit comments