From 67c8f1a54adfff8e9214ae63cefb3e91a49f1e13 Mon Sep 17 00:00:00 2001 From: Xinyuan Lin Date: Thu, 27 Aug 2026 00:58:42 -0700 Subject: [PATCH] ci(pyamber): measure branch coverage --- .github/workflows/build.yml | 6 ++++++ amber/pyproject.toml | 11 ++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6a2a6cff2c3..208e5c4665b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1122,6 +1122,12 @@ jobs: # --junit-xml emits a JUnit-XML report alongside the coverage XML # so the Test Analytics upload below can feed Codecov's failing- # test PR comments and flaky-test detection on main. + # + # Branch coverage is ON, but via `[tool.coverage.run] branch = true` + # in amber/pyproject.toml rather than a `--cov-branch` flag here, so + # that a local `pytest --cov` reports the same metric as CI. Don't + # add the flag back: it would be redundant, and two switches for one + # boolean invites someone to remove one and think it is off. env: # Pytest runs with -s, so loguru's default stderr sink prints # straight into the CI log; pin it to WARNING (loguru has no WARN) diff --git a/amber/pyproject.toml b/amber/pyproject.toml index dd9f2f939e4..3915e16ebb4 100644 --- a/amber/pyproject.toml +++ b/amber/pyproject.toml @@ -42,4 +42,13 @@ testpaths = ["src/test/python"] addopts = "--import-mode=importlib" markers = [ "integration: end-to-end test routed to the amber-integration CI job", -] \ No newline at end of file +] + +# Branch coverage. Without this, coverage.py records only whether each +# statement ran, so a half-taken `if` reads as fully covered and Codecov +# has no partial-line data for any pyamber file. Setting it here rather +# than passing `--cov-branch` in CI keeps a local `pytest --cov` run on +# the same metric as the pipeline — a local-vs-CI split is exactly how a +# line comes to look green on a laptop and partial on Codecov. +[tool.coverage.run] +branch = true