|
| 1 | +env: |
| 2 | + # We aim to always test with the latest stable Rust toolchain, however we pin to a specific |
| 3 | + # version like 1.70. Note that we only specify MAJOR.MINOR and not PATCH so that bugfixes still |
| 4 | + # come automatically. If the version specified here is no longer the latest stable version, |
| 5 | + # then please feel free to submit a PR that adjusts it along with the potential clippy fixes. |
| 6 | + RUST_STABLE_VER: "1.79" # In quotes because otherwise (e.g.) 1.70 would be interpreted as 1.7 |
| 7 | + # The purpose of checking with the minimum supported Rust toolchain is to detect its staleness. |
| 8 | + # If the compilation fails, then the version specified here needs to be bumped up to reality. |
| 9 | + # Be sure to also update the rust-version property in the workspace Cargo.toml file, |
| 10 | + # plus all the README.md files of the affected packages. |
| 11 | + RUST_MIN_VER: "1.65" |
| 12 | + # List of packages that will be checked with the minimum supported Rust version. |
| 13 | + # This should be limited to packages that are intended for publishing. |
| 14 | + RUST_MIN_VER_PKGS: "-p kurbo" |
| 15 | + # List of features that depend on the standard library and will be excluded from no_std checks. |
| 16 | + FEATURES_DEPENDING_ON_STD: "std,default,schemars" |
| 17 | + |
| 18 | + |
| 19 | +# Rationale |
| 20 | +# |
| 21 | +# We don't run clippy with --all-targets because then even --lib and --bins are compiled with |
| 22 | +# dev dependencies enabled, which does not match how they would be compiled by users. |
| 23 | +# A dev dependency might enable a feature that we need for a regular dependency, |
| 24 | +# and checking with --all-targets would not find our feature requirements lacking. |
| 25 | +# This problem still applies to cargo resolver version 2. |
| 26 | +# Thus we split all the targets into two steps, one with --lib --bins |
| 27 | +# and another with --tests --benches --examples. |
| 28 | +# Also, we can't give --lib --bins explicitly because then cargo will error on binary-only packages. |
| 29 | +# Luckily the default behavior of cargo with no explicit targets is the same but without the error. |
| 30 | +# |
| 31 | +# We use cargo-hack for a similar reason. Cargo's --workspace will do feature unification across |
| 32 | +# the whole workspace. While cargo-hack will instead check each workspace package separately. |
| 33 | +# |
| 34 | +# Using cargo-hack also allows us to more easily test the feature matrix of our packages. |
| 35 | +# We use --each-feature & --optional-deps which will run a separate check for every feature. |
| 36 | +# |
| 37 | +# The MSRV jobs run only cargo check because different clippy versions can disagree on goals and |
| 38 | +# running tests introduces dev dependencies which may require a higher MSRV than the bare package. |
| 39 | +# |
| 40 | +# For no_std checks we target x86_64-unknown-none, because this target doesn't support std |
| 41 | +# and as such will error out if our dependency tree accidentally tries to use std. |
| 42 | +# https://doc.rust-lang.org/stable/rustc/platform-support/x86_64-unknown-none.html |
| 43 | +# |
| 44 | +# We don't save caches in the merge-group cases, because those caches will never be re-used (apart |
| 45 | +# from the very rare cases where there are multiple PRs in the merge queue). |
| 46 | +# This is because GitHub doesn't share caches between merge queues and `main`. |
| 47 | + |
1 | 48 | name: CI
|
2 | 49 |
|
3 | 50 | on:
|
| 51 | + pull_request: |
| 52 | + merge_group: |
| 53 | + # We run on push, even though the commit is the same as when we ran in merge_group. |
| 54 | + # This allows the cache to be primed. |
| 55 | + # See https://github.com/orgs/community/discussions/66430 |
4 | 56 | push:
|
5 | 57 | branches:
|
6 | 58 | - main
|
7 |
| - pull_request: |
8 | 59 |
|
9 | 60 | jobs:
|
10 |
| - rustfmt: |
11 |
| - runs-on: ubuntu-latest |
| 61 | + fmt: |
12 | 62 | name: cargo fmt
|
| 63 | + runs-on: ubuntu-latest |
13 | 64 | steps:
|
14 |
| - - uses: actions/checkout@v3 |
| 65 | + - uses: actions/checkout@v4 |
15 | 66 |
|
16 | 67 | - name: install stable toolchain
|
17 | 68 | uses: dtolnay/rust-toolchain@master
|
18 | 69 | with:
|
19 |
| - toolchain: "stable" |
| 70 | + toolchain: ${{ env.RUST_STABLE_VER }} |
20 | 71 | components: rustfmt
|
21 | 72 |
|
22 | 73 | - name: cargo fmt
|
23 |
| - run: cargo fmt --all -- --check |
| 74 | + run: cargo fmt --all --check |
24 | 75 |
|
25 |
| - test-stable: |
| 76 | + - name: install ripgrep |
| 77 | + run: | |
| 78 | + sudo apt update |
| 79 | + sudo apt install ripgrep |
| 80 | +
|
| 81 | + - name: check copyright headers |
| 82 | + run: bash .github/copyright.sh |
| 83 | + |
| 84 | + clippy-stable: |
| 85 | + name: cargo clippy |
26 | 86 | runs-on: ${{ matrix.os }}
|
27 | 87 | strategy:
|
28 | 88 | matrix:
|
29 |
| - os: [macOS-latest, windows-2019, ubuntu-latest] |
30 |
| - name: cargo clippy+test |
| 89 | + os: [windows-latest, macos-latest, ubuntu-latest] |
31 | 90 | steps:
|
32 |
| - - uses: actions/checkout@v3 |
| 91 | + - uses: actions/checkout@v4 |
| 92 | + |
| 93 | + - name: restore cache |
| 94 | + uses: Swatinem/rust-cache@v2 |
| 95 | + with: |
| 96 | + save-if: ${{ github.event_name != 'merge_group' }} |
33 | 97 |
|
34 | 98 | - name: install stable toolchain
|
35 | 99 | uses: dtolnay/rust-toolchain@master
|
36 | 100 | with:
|
37 |
| - toolchain: "stable" |
| 101 | + toolchain: ${{ env.RUST_STABLE_VER }} |
| 102 | + targets: x86_64-unknown-none |
38 | 103 | components: clippy
|
39 | 104 |
|
40 |
| - - run: rustup target add thumbv7m-none-eabi |
| 105 | + - name: install cargo-hack |
| 106 | + uses: taiki-e/install-action@v2 |
| 107 | + with: |
| 108 | + tool: cargo-hack |
| 109 | + |
| 110 | + - name: cargo clippy (no_std) |
| 111 | + run: cargo hack clippy --workspace --locked --optional-deps --each-feature --features libm --exclude-features ${{ env.FEATURES_DEPENDING_ON_STD }} --target x86_64-unknown-none -- -D warnings |
41 | 112 |
|
42 | 113 | - name: cargo clippy
|
43 |
| - run: cargo clippy --all-features --all-targets -- -D warnings |
| 114 | + run: cargo hack clippy --workspace --locked --optional-deps --each-feature --features std -- -D warnings |
44 | 115 |
|
45 |
| - - name: cargo test |
46 |
| - run: cargo test --all-features |
| 116 | + - name: cargo clippy (auxiliary) |
| 117 | + run: cargo hack clippy --workspace --locked --optional-deps --each-feature --features std --tests --benches --examples -- -D warnings |
47 | 118 |
|
48 |
| - - name: Build with no default features |
49 |
| - # Use no-std target to ensure we don't link to std. |
50 |
| - run: cargo build --no-default-features --features libm --target thumbv7m-none-eabi |
| 119 | + clippy-stable-wasm: |
| 120 | + name: cargo clippy (wasm32) |
| 121 | + runs-on: ubuntu-latest |
| 122 | + steps: |
| 123 | + - uses: actions/checkout@v4 |
51 | 124 |
|
52 |
| - - name: cargo test --features=serde |
53 |
| - run: cargo test --features=serde |
| 125 | + - name: restore cache |
| 126 | + uses: Swatinem/rust-cache@v2 |
| 127 | + with: |
| 128 | + save-if: ${{ github.event_name != 'merge_group' }} |
54 | 129 |
|
55 |
| - test-stable-wasm: |
| 130 | + - name: install stable toolchain |
| 131 | + uses: dtolnay/rust-toolchain@master |
| 132 | + with: |
| 133 | + toolchain: ${{ env.RUST_STABLE_VER }} |
| 134 | + targets: wasm32-unknown-unknown |
| 135 | + components: clippy |
| 136 | + |
| 137 | + - name: install cargo-hack |
| 138 | + uses: taiki-e/install-action@v2 |
| 139 | + with: |
| 140 | + tool: cargo-hack |
| 141 | + |
| 142 | + - name: cargo clippy |
| 143 | + run: cargo hack clippy --workspace --locked --target wasm32-unknown-unknown --optional-deps --each-feature --features std -- -D warnings |
| 144 | + |
| 145 | + - name: cargo clippy (auxiliary) |
| 146 | + run: cargo hack clippy --workspace --locked --target wasm32-unknown-unknown --optional-deps --each-feature --features std --tests --benches --examples -- -D warnings |
| 147 | + |
| 148 | + test-stable: |
| 149 | + name: cargo test |
56 | 150 | runs-on: ${{ matrix.os }}
|
57 | 151 | strategy:
|
58 | 152 | matrix:
|
59 |
| - os: [macOS-latest, windows-2019, ubuntu-latest] |
60 |
| - |
61 |
| - name: cargo clippy+test (wasm32) |
| 153 | + os: [windows-latest, macos-latest, ubuntu-latest] |
62 | 154 | steps:
|
63 |
| - - uses: actions/checkout@v3 |
| 155 | + - uses: actions/checkout@v4 |
| 156 | + |
| 157 | + - name: restore cache |
| 158 | + uses: Swatinem/rust-cache@v2 |
| 159 | + with: |
| 160 | + save-if: ${{ github.event_name != 'merge_group' }} |
64 | 161 |
|
65 | 162 | - name: install stable toolchain
|
66 | 163 | uses: dtolnay/rust-toolchain@master
|
67 | 164 | with:
|
68 |
| - toolchain: "stable" |
69 |
| - target: wasm32-unknown-unknown |
70 |
| - components: clippy |
| 165 | + toolchain: ${{ env.RUST_STABLE_VER }} |
71 | 166 |
|
72 |
| - - name: cargo clippy |
73 |
| - run: cargo clippy --all-features --all-targets --target wasm32-unknown-unknown -- -D warnings |
74 |
| - |
75 |
| - # TODO: Find a way to make tests work. Until then the tests are merely compiled. |
76 |
| - - name: cargo test compile |
77 |
| - run: cargo test --all-features --no-run --target wasm32-unknown-unknown |
| 167 | + - name: cargo test |
| 168 | + run: cargo test --workspace --locked --all-features |
78 | 169 |
|
79 |
| - test-msrv: |
| 170 | + test-stable-wasm: |
| 171 | + name: cargo test (wasm32) |
80 | 172 | runs-on: ubuntu-latest
|
81 |
| - name: cargo test msrv |
82 | 173 | steps:
|
83 |
| - - uses: actions/checkout@v3 |
| 174 | + - uses: actions/checkout@v4 |
84 | 175 |
|
85 |
| - - name: install msrv toolchain |
| 176 | + - name: restore cache |
| 177 | + uses: Swatinem/rust-cache@v2 |
| 178 | + with: |
| 179 | + save-if: ${{ github.event_name != 'merge_group' }} |
| 180 | + |
| 181 | + - name: install stable toolchain |
86 | 182 | uses: dtolnay/rust-toolchain@master
|
87 | 183 | with:
|
88 |
| - toolchain: "1.65" |
| 184 | + toolchain: ${{ env.RUST_STABLE_VER }} |
| 185 | + targets: wasm32-unknown-unknown |
89 | 186 |
|
90 |
| - - name: cargo test |
91 |
| - run: cargo test --all-features |
| 187 | + # TODO: Find a way to make tests work. Until then the tests are merely compiled. |
| 188 | + - name: cargo test compile |
| 189 | + run: cargo test --workspace --locked --target wasm32-unknown-unknown --all-features --no-run |
92 | 190 |
|
93 |
| - test-nightly: |
| 191 | + check-msrv: |
| 192 | + name: cargo check (msrv) |
94 | 193 | runs-on: ${{ matrix.os }}
|
95 | 194 | strategy:
|
96 | 195 | matrix:
|
97 |
| - os: [macOS-latest, windows-2019, ubuntu-latest] |
98 |
| - name: cargo test nightly |
| 196 | + os: [windows-latest, macos-latest, ubuntu-latest] |
99 | 197 | steps:
|
100 |
| - - uses: actions/checkout@v3 |
| 198 | + - uses: actions/checkout@v4 |
101 | 199 |
|
102 |
| - - name: install nightly toolchain |
| 200 | + - name: restore cache |
| 201 | + uses: Swatinem/rust-cache@v2 |
| 202 | + with: |
| 203 | + save-if: ${{ github.event_name != 'merge_group' }} |
| 204 | + |
| 205 | + - name: install msrv toolchain |
103 | 206 | uses: dtolnay/rust-toolchain@master
|
104 | 207 | with:
|
105 |
| - toolchain: "nightly" |
| 208 | + toolchain: ${{ env.RUST_MIN_VER }} |
| 209 | + targets: x86_64-unknown-none |
106 | 210 |
|
107 |
| - - name: cargo test |
108 |
| - run: cargo test --all-features |
| 211 | + - name: install cargo-hack |
| 212 | + uses: taiki-e/install-action@v2 |
| 213 | + with: |
| 214 | + tool: cargo-hack |
109 | 215 |
|
110 |
| - check-docs: |
111 |
| - name: Docs |
112 |
| - runs-on: ${{ matrix.os }} |
113 |
| - strategy: |
114 |
| - matrix: |
115 |
| - os: [macOS-latest, windows-2019, ubuntu-latest] |
| 216 | + - name: cargo check (no_std) |
| 217 | + run: cargo hack check ${{ env.RUST_MIN_VER_PKGS }} --locked --optional-deps --each-feature --features libm --exclude-features ${{ env.FEATURES_DEPENDING_ON_STD }} --target x86_64-unknown-none |
| 218 | + |
| 219 | + - name: cargo check |
| 220 | + run: cargo hack check ${{ env.RUST_MIN_VER_PKGS }} --locked --optional-deps --each-feature --features std |
| 221 | + |
| 222 | + check-msrv-wasm: |
| 223 | + name: cargo check (msrv) (wasm32) |
| 224 | + runs-on: ubuntu-latest |
116 | 225 | steps:
|
117 |
| - - uses: actions/checkout@v3 |
| 226 | + - uses: actions/checkout@v4 |
118 | 227 |
|
119 |
| - - name: install stable toolchain |
| 228 | + - name: restore cache |
| 229 | + uses: Swatinem/rust-cache@v2 |
| 230 | + with: |
| 231 | + save-if: ${{ github.event_name != 'merge_group' }} |
| 232 | + |
| 233 | + - name: install msrv toolchain |
120 | 234 | uses: dtolnay/rust-toolchain@master
|
121 | 235 | with:
|
122 |
| - toolchain: "stable" |
| 236 | + toolchain: ${{ env.RUST_MIN_VER }} |
| 237 | + targets: wasm32-unknown-unknown |
| 238 | + |
| 239 | + - name: install cargo-hack |
| 240 | + uses: taiki-e/install-action@v2 |
| 241 | + with: |
| 242 | + tool: cargo-hack |
| 243 | + |
| 244 | + - name: cargo check |
| 245 | + run: cargo hack check ${{ env.RUST_MIN_VER_PKGS }} --locked --target wasm32-unknown-unknown --optional-deps --each-feature --features std |
| 246 | + |
| 247 | + doc: |
| 248 | + name: cargo doc |
| 249 | + # NOTE: We don't have any platform specific docs in this workspace, so we only run on Ubuntu. |
| 250 | + # If we get per-platform docs (win/macos/linux/wasm32/..) then doc jobs should match that. |
| 251 | + runs-on: ubuntu-latest |
| 252 | + steps: |
| 253 | + - uses: actions/checkout@v4 |
| 254 | + |
| 255 | + - name: restore cache |
| 256 | + uses: Swatinem/rust-cache@v2 |
| 257 | + with: |
| 258 | + save-if: ${{ github.event_name != 'merge_group' }} |
| 259 | + |
| 260 | + - name: install nightly toolchain |
| 261 | + uses: dtolnay/rust-toolchain@nightly |
123 | 262 |
|
| 263 | + # We test documentation using nightly to match docs.rs. This prevents potential breakages |
124 | 264 | - name: cargo doc
|
125 |
| - run: cargo doc --all-features --document-private-items |
| 265 | + run: cargo doc --workspace --locked --all-features --no-deps --document-private-items -Zunstable-options -Zrustdoc-scrape-examples |
126 | 266 |
|
127 | 267 | # If this fails, consider changing your text or adding something to .typos.toml
|
128 | 268 | typos:
|
|
0 commit comments