Skip to content

Commit 53a3d7d

Browse files
committed
ci: integrate Codecov test analytics via cargo-nextest
Switch CI test runner from `cargo test` to `cargo-nextest` to produce JUnit XML reports. Results are uploaded to Codecov's new test analytics feature for tracking test duration trends, failure rates, and flaky tests.
1 parent 4b02de1 commit 53a3d7d

4 files changed

Lines changed: 38 additions & 2 deletions

File tree

.config/nextest.toml

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

.github/scripts/ci_config.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import argparse
1212
import json
1313
import os
14+
import shutil
1415
import subprocess
1516
import sys
1617
from pathlib import Path
@@ -118,6 +119,9 @@ def run_group_tests(args):
118119
if coverage and args.group not in no_coverage:
119120
github_output("crate_flags", args.group)
120121

122+
junit_dir = Path("target/test-results")
123+
junit_dir.mkdir(parents=True, exist_ok=True)
124+
121125
for crate in crates:
122126
# Skip dash-fuzz on Windows
123127
if args.os == "windows-latest" and crate == "dash-fuzz":
@@ -127,17 +131,32 @@ def run_group_tests(args):
127131
github_group_start(f"Testing {crate}")
128132

129133
if coverage and args.group not in no_coverage:
130-
cmd = ["cargo", "llvm-cov", "--no-report", "-p", crate, "--all-features"]
134+
cmd = [
135+
"cargo", "llvm-cov", "nextest",
136+
"--no-report", "-p", crate, "--all-features",
137+
"--profile", "ci",
138+
]
131139
else:
132-
cmd = ["cargo", "test", "-p", crate, "--all-features"]
140+
cmd = [
141+
"cargo", "nextest", "run",
142+
"-p", crate, "--all-features",
143+
"--profile", "ci",
144+
]
133145
result = subprocess.run(cmd)
134146

147+
# Collect JUnit XML per crate for Codecov test analytics
148+
src = Path("target/nextest/ci/junit.xml")
149+
if src.exists():
150+
shutil.copy(src, junit_dir / f"junit-{crate}.xml")
151+
135152
github_group_end()
136153

137154
if result.returncode != 0:
138155
failed.append(crate)
139156
github_error(f"Test failed for {crate} on {args.os}")
140157

158+
github_output("junit_dir", str(junit_dir))
159+
141160
if failed:
142161
print("\n" + "=" * 40)
143162
print(f"FAILED TESTS ({args.group} on {args.os}):")

.github/workflows/build-and-test.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ jobs:
4242
with:
4343
shared-key: "test-${{ inputs.os }}-${{ matrix.group }}"
4444

45+
- name: Install cargo-nextest
46+
uses: taiki-e/install-action@nextest
47+
4548
- name: Install cargo-llvm-cov
4649
if: inputs.coverage
4750
uses: taiki-e/install-action@cargo-llvm-cov
@@ -85,6 +88,14 @@ jobs:
8588
token: ${{ secrets.CODECOV_TOKEN }}
8689
fail_ci_if_error: true
8790

91+
- name: Upload test results to Codecov
92+
if: ${{ !cancelled() }}
93+
uses: codecov/test-results-action@v1
94+
with:
95+
files: target/test-results/junit-*.xml
96+
flags: ${{ matrix.group }}
97+
token: ${{ secrets.CODECOV_TOKEN }}
98+
8899
- name: Upload failed dashd test logs
89100
if: failure() && (matrix.group == 'spv' || matrix.group == 'ffi')
90101
uses: actions/upload-artifact@v4

key-wallet/src/transaction_checking/transaction_router/tests/coinbase.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ async fn test_update_state_flag_behavior() {
252252

253253
// First check with update_state = false
254254
let result1 =
255+
255256
managed_wallet_info.check_core_transaction(&tx, context, &mut wallet, false).await;
256257

257258
assert!(result1.is_relevant);

0 commit comments

Comments
 (0)