Skip to content

Commit 48f74ed

Browse files
committed
ci: add coverage for cts
1 parent 5b2c840 commit 48f74ed

File tree

2 files changed

+33
-5
lines changed

2 files changed

+33
-5
lines changed

.github/workflows/cts.yml

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,15 @@ jobs:
4343

4444
- name: Install Repo MSRV toolchain
4545
run: |
46-
rustup toolchain install ${{ env.MSRV }} --no-self-update --profile=minimal --target ${{ matrix.target }}
46+
rustup toolchain install ${{ env.MSRV }} --no-self-update --profile=minimal --target ${{ matrix.target }} --component llvm-tools
4747
rustup override set ${{ env.MSRV }}
4848
cargo -V
4949
50+
- name: Install `cargo-llvm-cov`
51+
uses: taiki-e/install-action@v2
52+
with:
53+
tool: cargo-llvm-cov
54+
5055
- name: caching
5156
uses: Swatinem/rust-cache@v2
5257
with:
@@ -60,7 +65,7 @@ jobs:
6065
mkdir -p .cargo
6166
cat <<EOF >> .cargo/config.toml
6267
[profile.dev]
63-
debug = 1
68+
debug = "line-tables-only"
6469
EOF
6570
6671
- name: (Windows) Install DXC
@@ -71,12 +76,28 @@ jobs:
7176
if: matrix.os == 'windows-2022'
7277
uses: ./.github/actions/install-warp
7378
with:
74-
target-dirs: "target/debug"
79+
target-dirs: "target/llvm-cov-target/debug"
7580

7681
- name: (Linux) Install Mesa
7782
if: matrix.os == 'ubuntu-24.04'
7883
uses: ./.github/actions/install-mesa
7984

8085
- name: run CTS
8186
shell: bash
82-
run: cargo xtask cts
87+
run: cargo xtask cts --llvm-cov
88+
89+
- name: Generate coverage report
90+
id: coverage
91+
shell: bash
92+
continue-on-error: true
93+
run: |
94+
set -e
95+
96+
cargo llvm-cov report --lcov --output-path lcov.info
97+
98+
- name: Upload coverage report to Codecov
99+
uses: codecov/codecov-action@v5
100+
if: steps.coverage.outcome == 'success'
101+
with:
102+
files: lcov.info
103+
token: ${{ secrets.CODECOV_TOKEN }}

xtask/src/cts.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const CTS_DEFAULT_TEST_LIST: &str = "cts_runner/test.lst";
1717

1818
pub fn run_cts(shell: Shell, mut args: Arguments) -> anyhow::Result<()> {
1919
let skip_checkout = args.contains("--skip-checkout");
20+
let llvm_cov = args.contains("--llvm-cov");
2021

2122
let mut list_files = Vec::<OsString>::new();
2223
while let Some(file) = args.opt_value_from_str("-f")? {
@@ -134,12 +135,18 @@ pub fn run_cts(shell: Shell, mut args: Arguments) -> anyhow::Result<()> {
134135
log::info!("Skipping CTS checkout because --skip-checkout was specified");
135136
}
136137

138+
let run_flags = if llvm_cov {
139+
&["llvm-cov", "--no-cfg-coverage", "--no-report", "run"][..]
140+
} else {
141+
&["run"][..]
142+
};
143+
137144
log::info!("Running CTS");
138145
for test in &tests {
139146
log::info!("Running {}", test.to_string_lossy());
140147
shell
141148
.cmd("cargo")
142-
.args(["run"])
149+
.args(run_flags)
143150
.args(["--manifest-path".as_ref(), wgpu_cargo_toml.as_os_str()])
144151
.args(["-p", "cts_runner"])
145152
.args(["--bin", "cts_runner"])

0 commit comments

Comments
 (0)