Skip to content

Commit 3581363

Browse files
authored
Various CI improvements (#32)
* Add various CI improvements * Consolidate and reorder jobs * Add `--all-features` flag to `cargo doc`
1 parent 068d007 commit 3581363

File tree

1 file changed

+46
-64
lines changed

1 file changed

+46
-64
lines changed

.github/workflows/ci.yaml

Lines changed: 46 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -6,68 +6,29 @@ on:
66
pull_request:
77
branches: [main]
88

9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
913
env:
1014
CARGO_TERM_COLOR: always
1115
CARGO_INCREMENTAL: 0
1216
CARGO_PROFILE_TEST_DEBUG: 0
1317
CARGO_PROFILE_DEV_DEBUG: 0
1418

1519
jobs:
16-
# Run cargo test --all-features
17-
test:
18-
name: Test Suite
20+
# Check for typos
21+
typos:
22+
name: Spell Check
1923
runs-on: ubuntu-latest
20-
timeout-minutes: 30
21-
env:
22-
RUSTFLAGS: "-C debuginfo=0 -D warnings"
24+
timeout-minutes: 10
2325
steps:
2426
- name: Checkout sources
2527
uses: actions/checkout@v4
26-
- name: Cache
27-
uses: actions/cache@v4
28-
with:
29-
path: |
30-
~/.cargo/bin/
31-
~/.cargo/registry/index/
32-
~/.cargo/registry/cache/
33-
~/.cargo/git/db/
34-
target/
35-
key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.toml') }}
36-
- name: Install stable toolchain
37-
uses: dtolnay/rust-toolchain@stable
38-
- name: Install Dependencies
39-
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev
40-
- name: Run cargo test
41-
run: cargo test --all-features
28+
- name: Check for typos
29+
uses: crate-ci/typos@v1
4230

43-
# Run cargo clippy --all-targets --all-features -- -D warnings
44-
clippy_check:
45-
name: Clippy
46-
runs-on: ubuntu-latest
47-
timeout-minutes: 30
48-
steps:
49-
- name: Checkout sources
50-
uses: actions/checkout@v4
51-
- name: Cache
52-
uses: actions/cache@v4
53-
with:
54-
path: |
55-
~/.cargo/bin/
56-
~/.cargo/registry/index/
57-
~/.cargo/registry/cache/
58-
~/.cargo/git/db/
59-
target/
60-
key: ${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.toml') }}
61-
- name: Install stable toolchain
62-
uses: dtolnay/rust-toolchain@stable
63-
with:
64-
components: clippy
65-
- name: Install Dependencies
66-
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev
67-
- name: Run clippy
68-
run: cargo clippy --all-targets --all-features -- -D warnings
69-
70-
# Run cargo fmt --all -- --check
31+
# Run `cargo fmt`
7132
format:
7233
name: Format
7334
runs-on: ubuntu-latest
@@ -82,29 +43,50 @@ jobs:
8243
- name: Run cargo fmt
8344
run: cargo fmt --all -- --check
8445

85-
# Run RUSTDOCFLAGS="-D warnings" cargo doc --workspace --document-private-items --no-deps
86-
docs:
87-
name: Docs
46+
# Run `cargo test` (with dynamic linking) AND `cargo doc`
47+
# Consolidated into one job to ensure reuse of build artifacts.
48+
test:
49+
name: Test Suite & Docs
50+
needs: [typos, format]
8851
runs-on: ubuntu-latest
8952
timeout-minutes: 30
53+
env:
54+
RUSTFLAGS: "-C debuginfo=0 -D warnings"
9055
steps:
9156
- name: Checkout sources
9257
uses: actions/checkout@v4
93-
- name: Cache
94-
uses: actions/cache@v4
95-
with:
96-
path: |
97-
~/.cargo/bin/
98-
~/.cargo/registry/index/
99-
~/.cargo/registry/cache/
100-
~/.cargo/git/db/
101-
target/
102-
key: ${{ runner.os }}-cargo-doc-${{ hashFiles('**/Cargo.toml') }}
10358
- name: Install stable toolchain
10459
uses: dtolnay/rust-toolchain@stable
10560
- name: Install Dependencies
10661
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev
62+
- name: Rust Cache
63+
uses: Swatinem/rust-cache@v2
64+
- name: Run cargo test
65+
run: cargo test --all-features --features "bevy/dynamic_linking"
10766
- name: Run cargo doc
10867
env:
10968
RUSTDOCFLAGS: "-D warnings"
110-
run: cargo doc --workspace --document-private-items --no-deps
69+
run: cargo doc --workspace --document-private-items --all-features --no-deps
70+
71+
# Run cargo clippy with various feature combinations
72+
clippy_check:
73+
name: Clippy
74+
needs: [typos, format]
75+
runs-on: ubuntu-latest
76+
timeout-minutes: 30
77+
strategy:
78+
matrix:
79+
features: ["--no-default-features", "", "--all-features"]
80+
steps:
81+
- name: Checkout sources
82+
uses: actions/checkout@v4
83+
- name: Install stable toolchain
84+
uses: dtolnay/rust-toolchain@stable
85+
with:
86+
components: clippy
87+
- name: Install Dependencies
88+
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev
89+
- name: Rust Cache
90+
uses: Swatinem/rust-cache@v2
91+
- name: Run clippy
92+
run: cargo clippy --all-targets ${{ matrix.features }} -- -D warnings

0 commit comments

Comments
 (0)