Skip to content

Commit 2cf8a74

Browse files
committed
Enable markdown coverage in CI.
1 parent fb511b3 commit 2cf8a74

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
posargs: [""]
5151
include:
5252
- noxenv: tests-3.11
53-
posargs: ghcoverage
53+
posargs: coverage github
5454

5555
steps:
5656
- uses: actions/checkout@v3

noxfile.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from pathlib import Path
2+
import os
23

34
import nox
45

@@ -24,10 +25,26 @@ def _session(fn):
2425
def tests(session):
2526
session.install("-r", ROOT / "test-requirements.txt")
2627

27-
if session.posargs and session.posargs[0] in {"coverage", "ghcoverage"}:
28+
if session.posargs and session.posargs[0] == "coverage":
29+
if len(session.posargs) > 1 and session.posargs[1] == "github":
30+
github = os.environ["GITHUB_STEP_SUMMARY"]
31+
else:
32+
github = None
33+
2834
session.install("coverage[toml]")
2935
session.run("coverage", "run", "-m", "pytest", REFERENCING)
30-
session.run("coverage", "report")
36+
if github is None:
37+
session.run("coverage", "report")
38+
else:
39+
with open(github, "a") as summary:
40+
summary.write("### Coverage\n\n")
41+
summary.flush() # without a flush, output seems out of order.
42+
session.run(
43+
"coverage",
44+
"report",
45+
"--format=markdown",
46+
stdout=summary,
47+
)
3148
else:
3249
session.run("pytest", *session.posargs, REFERENCING)
3350

0 commit comments

Comments
 (0)