Skip to content

Commit ff0b9b4

Browse files
fix(ci): initialize coverage output on clean runners
Create the report directory before llvm-cov exports LCOV and document the same prerequisite locally. Add workflow regression tests for the Rust components, doctor tools, and coverage directory ordering. Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
1 parent 89d6b60 commit ff0b9b4

3 files changed

Lines changed: 63 additions & 1 deletion

File tree

.github/workflows/ci.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,10 @@ jobs:
153153
- uses: taiki-e/install-action@v2
154154
with:
155155
tool: cargo-llvm-cov@0.6.21,cargo-nextest@0.9.102
156-
- run: cargo llvm-cov nextest --locked -p cortex-cli -p cortex-app-server -p cortex-common --profile ci --lcov --output-path target/readiness/lcov.info
156+
- name: Collect application coverage
157+
run: |
158+
mkdir -p target/readiness
159+
cargo llvm-cov nextest --locked -p cortex-cli -p cortex-app-server -p cortex-common --profile ci --lcov --output-path target/readiness/lcov.info
157160
- run: python3 scripts/readiness/coverage.py --base "$QUALITY_BASE"
158161
- uses: actions/upload-artifact@v4
159162
if: always()

docs/guides/development.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ response for the coding service. Keep live tests out of default CI.
6464
python3 scripts/readiness/tests.py
6565
python3 scripts/readiness/tests.py --repeat 3
6666
cargo test --locked --workspace --doc
67+
mkdir -p target/readiness
6768
cargo llvm-cov nextest --locked -p cortex-cli -p cortex-app-server -p cortex-common \
6869
--profile ci --lcov --output-path target/readiness/lcov.info
6970
python3 scripts/readiness/coverage.py --base origin/main
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import shlex
2+
import tomllib
3+
import unittest
4+
from pathlib import Path
5+
6+
import yaml
7+
8+
ROOT = Path(__file__).resolve().parents[2]
9+
10+
11+
class WorkflowTests(unittest.TestCase):
12+
def setUp(self):
13+
self.ci = yaml.safe_load((ROOT / ".github/workflows/ci.yml").read_text())
14+
15+
def test_policy_job_installs_required_toolchain_components(self):
16+
toolchain = tomllib.loads((ROOT / "rust-toolchain.toml").read_text())["toolchain"]
17+
step = next(
18+
step for step in self.ci["jobs"]["quality"]["steps"]
19+
if step.get("uses", "").startswith("dtolnay/rust-toolchain@")
20+
)
21+
self.assertEqual(step["uses"], f"dtolnay/rust-toolchain@{toolchain['channel']}")
22+
components = {value.strip() for value in step["with"]["components"].split(",")}
23+
self.assertTrue(set(toolchain["components"]) <= components)
24+
25+
def test_doctor_jobs_install_real_tools_before_tests(self):
26+
stability = yaml.safe_load(
27+
(ROOT / ".github/workflows/test-stability.yml").read_text()
28+
)
29+
jobs = [
30+
self.ci["jobs"]["test"],
31+
self.ci["jobs"]["coverage"],
32+
stability["jobs"]["repeat"],
33+
]
34+
for job in jobs:
35+
installed = set()
36+
found_tests = False
37+
for step in job["steps"]:
38+
command = step.get("run", "")
39+
for line in command.splitlines():
40+
if "apt-get install" in line:
41+
installed.update(shlex.split(line))
42+
if "scripts/readiness/tests.py" in command or "cargo llvm-cov nextest" in command:
43+
self.assertTrue({"git", "ripgrep"} <= installed)
44+
found_tests = True
45+
self.assertTrue(found_tests)
46+
47+
def test_coverage_creates_report_directory_before_export(self):
48+
commands = "\n".join(
49+
step.get("run", "") for step in self.ci["jobs"]["coverage"]["steps"]
50+
)
51+
lines = [line.strip() for line in commands.splitlines()]
52+
directory = lines.index("mkdir -p target/readiness")
53+
report = next(
54+
index for index, line in enumerate(lines)
55+
if "cargo llvm-cov nextest" in line
56+
and "--output-path target/readiness/lcov.info" in line
57+
)
58+
self.assertLess(directory, report)

0 commit comments

Comments
 (0)