Add unittest code coverage to CI (#39789)

Add a CI workflow to determine the code coverage. For now we only run
unit-tests, wpt-tests with code coverage can be added later.
We use `lld` to avoid OOM errors during linking (with `ld`, we would
need to reduce the build-concurrency drastically to prevent OOM errors
in CI)
For now, coverage would run during `full` and on-demand (i.e explicitly
requested via try). This workflow failing should not influence the
merge-queue, since we intentionally don't add this workflow to the
required status checks (yet).

Future work: It still needs some investigation to figure out if we can
get pull-request comments from the codecov bot, for coverage runs on try
branches.


Testing: [try
run](https://github.com/servo/servo/actions/runs/18431480782/job/52519348479),
[codecov report from the try
run](f41a50f321)

---------

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
Signed-off-by: Jonathan Schwender <55576758+jschwe@users.noreply.github.com>
Co-authored-by: Sam <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
Jonathan Schwender
2025-10-13 20:17:24 +02:00
committed by GitHub
parent 312891a14e
commit 07ff87754d
6 changed files with 169 additions and 1 deletions

View File

@@ -39,6 +39,7 @@ class JobConfig(object):
unit_tests: bool = False
build_libservo: bool = False
bencher: bool = False
coverage: bool = False
build_args: str = ""
wpt_args: str = ""
number_of_wpt_chunks: int = 20
@@ -57,6 +58,7 @@ class JobConfig(object):
self.unit_tests |= other.unit_tests
self.build_libservo |= other.build_libservo
self.bencher |= other.bencher
self.coverage |= other.coverage
self.number_of_wpt_chunks = max(self.number_of_wpt_chunks, other.number_of_wpt_chunks)
self.update_name()
return True
@@ -83,6 +85,8 @@ class JobConfig(object):
modifier.append("WPT")
if self.bencher:
modifier.append("Bencher")
if self.coverage:
modifier.append("Coverage")
if modifier:
self.name += " (" + ", ".join(modifier) + ")"
@@ -155,6 +159,8 @@ def handle_modifier(config: Optional[JobConfig], s: str) -> Optional[JobConfig]:
config.profile = "production"
if "bencher" in s:
config.bencher = True
if "coverage" in s:
config.coverage = True
elif "wpt" in s:
config.wpt = True
config.update_name()
@@ -204,6 +210,9 @@ class Config(object):
words.extend(["linux-production-bencher", "macos-production-bencher", "windows-production-bencher"])
words.extend(["ohos-production-bencher"])
continue # skip over keyword
if word in ["cov", "coverage", "test-coverage"]:
words.extend(["linux-coverage"])
continue # skip over keyword
job = handle_preset(word)
job = handle_modifier(job, word)
if job is None:
@@ -252,6 +261,7 @@ class TestParser(unittest.TestCase):
"wpt": False,
"wpt_args": "",
"build_args": "",
"coverage": False,
}
],
},
@@ -274,6 +284,7 @@ class TestParser(unittest.TestCase):
"bencher": True,
"wpt_args": "",
"build_args": "",
"coverage": False,
},
{
"name": "MacOS (Unit Tests, Build libservo)",
@@ -286,6 +297,7 @@ class TestParser(unittest.TestCase):
"bencher": False,
"wpt_args": "",
"build_args": "",
"coverage": False,
},
{
"name": "Windows (Unit Tests, Build libservo)",
@@ -298,6 +310,7 @@ class TestParser(unittest.TestCase):
"bencher": False,
"wpt_args": "",
"build_args": "",
"coverage": False,
},
{
"name": "Android",
@@ -310,6 +323,7 @@ class TestParser(unittest.TestCase):
"bencher": False,
"wpt_args": "",
"build_args": "",
"coverage": False,
},
{
"name": "OpenHarmony",
@@ -322,6 +336,7 @@ class TestParser(unittest.TestCase):
"bencher": False,
"wpt_args": "",
"build_args": "",
"coverage": False,
},
{
"name": "Lint",
@@ -334,6 +349,7 @@ class TestParser(unittest.TestCase):
"bencher": False,
"wpt_args": "",
"build_args": "",
"coverage": False,
},
],
},
@@ -356,6 +372,7 @@ class TestParser(unittest.TestCase):
"wpt": True,
"wpt_args": "",
"build_args": "",
"coverage": False,
}
],
},