Skip to content

Commit 2595441

Browse files
committed
ci: track test coverage
1 parent 140ba9f commit 2595441

File tree

2 files changed

+66
-10
lines changed

2 files changed

+66
-10
lines changed

.config/nextest.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[profile.default]
2+
failure-output = "final"
3+
4+
[profile.ci]
5+
fail-fast = false
6+
junit.path = "junit.xml"

.github/workflows/ci.yml

Lines changed: 60 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ jobs:
3030
uses: actions/checkout@v4
3131

3232
- name: Set up Rust toolchain
33-
uses: dtolnay/rust-toolchain@stable
34-
with:
35-
components: clippy
33+
run: rustup install --profile minimal --component clippy
3634

3735
- name: Cache build artifacts
3836
uses: Swatinem/rust-cache@v2
37+
with:
38+
cache-on-failure: true
3939

4040
- name: Lint Rust code
4141
run: cargo clippy --all-targets --workspace --locked
@@ -74,12 +74,12 @@ jobs:
7474
uses: actions/checkout@v4
7575

7676
- name: Set up Rust toolchain
77-
uses: dtolnay/rust-toolchain@stable
78-
with:
79-
components: rustfmt
77+
run: rustup install --profile minimal --component rustfmt
8078

8179
- name: Cache build artifacts
8280
uses: Swatinem/rust-cache@v2
81+
with:
82+
cache-on-failure: true
8383

8484
- name: Check formatting
8585
run: cargo fmt --check --all
@@ -92,13 +92,61 @@ jobs:
9292
uses: actions/checkout@v4
9393

9494
- name: Set up Rust toolchain
95-
uses: dtolnay/rust-toolchain@stable
95+
run: rustup install --profile minimal --component llvm-tools
9696

9797
- name: Cache build artifacts
9898
uses: Swatinem/rust-cache@v2
99+
with:
100+
cache-on-failure: true
101+
102+
- name: Install nextest (if not cached)
103+
run: cargo nextest --version || cargo install --locked cargo-nextest
104+
105+
- name: Install llvm-cov (if not cached)
106+
run: cargo llvm-cov --version || cargo install --locked cargo-llvm-cov
107+
108+
- name: Run tests
109+
run: >-
110+
cargo llvm-cov nextest
111+
--no-report
112+
--no-fail-fast
113+
--locked
114+
--workspace
115+
--all-targets
116+
--all-features
117+
--profile ci
118+
119+
- name: Generate coverage reports
120+
if: (!cancelled()) # Generate reports even if tests failed
121+
shell: bash
122+
run: |
123+
cargo llvm-cov report --html
124+
cargo llvm-cov report --codecov --output-path target/llvm-cov/codecov.json
99125
100-
- name: Run default tests
101-
run: cargo test --workspace --all-targets --no-fail-fast --locked
126+
- name: Publish test results
127+
uses: EnricoMi/publish-unit-test-result-action@v2
128+
if: (!cancelled()) # Upload reports even if tests failed
129+
with:
130+
check_run: false
131+
comment_mode: ${{ (github.event_name == 'pull_request') && 'always' || 'off' }}
132+
files: |
133+
target/nextest/ci/junit.xml
134+
135+
- name: Upload coverage to Codecov
136+
uses: codecov/codecov-action@v5
137+
# if: (!cancelled()) # Upload reports even if tests failed
138+
if: false # Skip until we set up Codecov for the @purduehackers org
139+
with:
140+
token: ${{ secrets.CODECOV_TOKEN }}
141+
files: target/llvm-cov/codecov.json
142+
fail_ci_if_error: true
143+
144+
- name: Upload HTML coverage report
145+
uses: actions/upload-artifact@v4
146+
if: (!cancelled()) # Upload reports even if tests failed
147+
with:
148+
name: coverage-html
149+
path: target/llvm-cov/html/
102150

103151
# Adding this because we don't want to run the whole build workflow on each
104152
# push
@@ -110,10 +158,12 @@ jobs:
110158
uses: actions/checkout@v4
111159

112160
- name: Set up Rust toolchain
113-
uses: dtolnay/rust-toolchain@stable
161+
run: rustup install --profile minimal
114162

115163
- name: Cache build artifacts
116164
uses: Swatinem/rust-cache@v2
165+
with:
166+
cache-on-failure: true
117167

118168
- name: Compile project
119169
run: cargo build --workspace --all-targets --release --locked

0 commit comments

Comments
 (0)