Skip to content

Commit c730f73

Browse files
committed
Tweak to fix 0 counts
1 parent 666a4cd commit c730f73

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

.github/scripts/tox-summary.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@
2626
r"(?P<job_name>[a-zA-Z0-9_-]+)-(?P<job_num>\d+)-(?P<run_id>[a-zA-Z0-9]+)-(?P<job_id>[a-zA-Z0-9_-]+)-results.json"
2727
)
2828
ANSI_ESCAPE_RE = re.compile(r"\x1b\[[0-9;]*[a-zA-Z]")
29-
PYTEST_SUMMARY_RE = re.compile(r"=+ (?P<summary>.+?) in (?P<duration>[\d.]+)s =+")
29+
PYTEST_SUMMARY_RE = re.compile(r"=+ (?P<summary>.+?) in (?P<duration>[\d.]+)s(?: \([\d:]+\))? =+")
3030
PYTEST_COUNT_RE = re.compile(r"(\d+) (passed|failed|skipped|xfailed|xpassed|errors?|warnings?|deselected|rerun)")
3131
PYTEST_COUNT_NORMALIZE = {"error": "errors", "warning": "warnings"}
32+
COUNT_KEYS = ("passed", "failed", "xfailed", "xpassed", "errors", "warnings")
3233

3334
GITHUB_SERVER_URL = os.environ.get("GITHUB_SERVER_URL", "https://github.com")
3435
GITHUB_REPOSITORY = os.environ.get("GITHUB_REPOSITORY", "newrelic/newrelic-python-agent")
@@ -75,16 +76,18 @@ def main():
7576

7677
with GITHUB_SUMMARY.open("w") as output_fp:
7778
summary = summarize_results(results)
78-
totals = {
79-
f"total_{key}": sum(r[key] for r in summary)
80-
for key in ("passed", "failed", "xfailed", "xpassed", "errors", "warnings")
81-
}
79+
totals = {f"total_{key}": sum(r[key] for r in summary) for key in COUNT_KEYS}
8280
# Print table header
8381
print(TABLE_HEADER.format(**totals), file=output_fp)
8482

8583
for result in summary:
84+
# Print "-" for counts we couldn't parse to distinguish from 0 counts
85+
row = dict(result)
86+
if not row["parsed"]:
87+
for key in COUNT_KEYS:
88+
row[key] = "-"
8689
line = "| {env_name} | {status} | {duration} | {setup_duration} | {test_duration} | {runner} | {passed} | {failed} | {xfailed} | {xpassed} | {errors} | {warnings} |".format(
87-
**result
90+
**row
8891
)
8992
print(line, file=output_fp)
9093

@@ -140,6 +143,7 @@ def summarize_results(results):
140143
"errors": counts.get("errors", 0),
141144
"warnings": counts.get("warnings", 0),
142145
"runner": runner,
146+
"parsed": bool(counts), # If counts is still empty, this failed to parse
143147
}
144148
)
145149

0 commit comments

Comments
 (0)