Skip to content

Commit 9f614ac

Browse files
committed
Try again at coverage without a separate shell script.
nox may behave a bit better here than tox, I couldn't get this to work previously.
1 parent aa8aef6 commit 9f614ac

File tree

3 files changed

+23
-16
lines changed

3 files changed

+23
-16
lines changed

.github/coverage.sh

Lines changed: 0 additions & 3 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ jobs:
5252
include:
5353
- os: ubuntu-latest
5454
noxenv: "tests-3.11(format)"
55-
posargs: ghcoverage
55+
posargs: coverage github
5656
- os: ubuntu-latest
5757
noxenv: "tests-3.11(no-extras)"
58-
posargs: ghcoverage
58+
posargs: coverage github
5959
exclude:
6060
- os: windows-latest
6161
noxenv: readme

noxfile.py

Lines changed: 21 additions & 11 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

@@ -47,27 +48,36 @@ def tests(session, installable):
4748

4849
session.install("virtue", installable)
4950

50-
if session.posargs and session.posargs[0] in {"coverage", "ghcoverage"}:
51-
ghcoverage = session.posargs.pop(0) == "ghcoverage"
51+
if session.posargs and session.posargs[0] == "coverage":
52+
if len(session.posargs) > 1 and session.posargs[1] == "github":
53+
posargs = session.posargs[2:]
54+
github = os.environ["GITHUB_STEP_SUMMARY"]
55+
else:
56+
posargs, github = session.posargs[1:], None
5257

5358
session.install("coverage[toml]")
5459
session.run(
5560
"coverage",
5661
"run",
57-
*session.posargs,
62+
*posargs,
5863
"-m",
5964
"virtue",
6065
PACKAGE,
6166
env=env,
6267
)
63-
session.run("coverage", "report")
64-
65-
if ghcoverage:
66-
session.run(
67-
"sh",
68-
ROOT / ".github/coverage.sh",
69-
f"{session.bin}/python",
70-
)
68+
69+
if github is None:
70+
session.run("coverage", "report")
71+
else:
72+
with open(github, "a") as summary:
73+
summary.write("### Coverage\n\n")
74+
summary.flush() # without a flush, output seems out of order.
75+
session.run(
76+
"coverage",
77+
"report",
78+
"--format=markdown",
79+
stdout=summary,
80+
)
7181
else:
7282
session.run("virtue", *session.posargs, PACKAGE, env=env)
7383

0 commit comments

Comments
 (0)