Skip to content

Commit

Permalink
[CI] Switch to source-based code coverage for rust
Browse files Browse the repository at this point in the history
  • Loading branch information
glandium committed Jan 7, 2025
1 parent 658d9b7 commit b00f89c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
16 changes: 10 additions & 6 deletions CI/decision.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
Build,
Git,
Hg,
install_rust,
nproc,
)
from variables import * # noqa: F403
Expand Down Expand Up @@ -143,7 +144,8 @@ def __init__(self, **kwargs):
[
"shopt -s nullglob",
"cd repo",
"zip $ARTIFACTS/coverage.zip" ' $(find . -name "*.gcda")',
"zip $ARTIFACTS/coverage.zip"
' $(find . -name "*.gcda" -o -name "*.profraw")',
"cd ..",
"shopt -u nullglob",
]
Expand All @@ -155,6 +157,7 @@ def __init__(self, **kwargs):
artifacts.push(artifact)
artifacts.append("coverage.zip")
self.coverage.append(self)
kwargs.setdefault("env", {})["LLVM_PROFILE_FILE"] = "/repo/%m.profraw"
elif variant == "asan" and task_env == "linux":
kwargs["caps"] = ["SYS_PTRACE"]
if not desc:
Expand Down Expand Up @@ -417,6 +420,7 @@ def main():
{f"file:cov-{task.id}.zip": task} for task in TestTask.coverage
]
task = Build.by_name("linux.coverage")
coverage_mounts.append(task.mount())
coverage_mounts.append(
{
"file:gcno-build.zip": {
Expand All @@ -426,11 +430,11 @@ def main():
}
)

merge_coverage.extend(
[
"grcov -s repo -t lcov -o repo/coverage.lcov gcno-build.zip "
+ " ".join(f"cov-{task.id}.zip" for task in TestTask.coverage),
]
merge_coverage.extend(install_rust())
merge_coverage.append("rustup component add llvm-tools-preview")
merge_coverage.append(
"grcov -s repo -t lcov -o repo/coverage.lcov -b git-cinnabar gcno-build.zip "
+ " ".join(f"cov-{task.id}.zip" for task in TestTask.coverage)
)

if merge_coverage:
Expand Down
2 changes: 1 addition & 1 deletion CI/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ def file_format(url):
dependencies.append(t.id)
else:
raise Exception("Don't know how to handle {}".format(k))
task["dependencies"] = sorted(dependencies)
task["dependencies"] = sorted(set(dependencies))
index = kwargs.get("index")
id = None
if index and all(isinstance(d, Index.Existing) for d in dependencies[1:]):
Expand Down
2 changes: 1 addition & 1 deletion CI/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ def prefix(p, s):
]
environ["RUSTFLAGS"] = " ".join(
[
"-Zprofile",
"-Cinstrument-coverage",
"-Ccodegen-units=1",
"-Cinline-threshold=0",
]
Expand Down

0 comments on commit b00f89c

Please sign in to comment.