|
26 | 26 | 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" |
27 | 27 | ) |
28 | 28 | 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:]+\))? =+") |
30 | 30 | PYTEST_COUNT_RE = re.compile(r"(\d+) (passed|failed|skipped|xfailed|xpassed|errors?|warnings?|deselected|rerun)") |
31 | 31 | PYTEST_COUNT_NORMALIZE = {"error": "errors", "warning": "warnings"} |
| 32 | +COUNT_KEYS = ("passed", "failed", "xfailed", "xpassed", "errors", "warnings") |
32 | 33 |
|
33 | 34 | GITHUB_SERVER_URL = os.environ.get("GITHUB_SERVER_URL", "https://github.com") |
34 | 35 | GITHUB_REPOSITORY = os.environ.get("GITHUB_REPOSITORY", "newrelic/newrelic-python-agent") |
@@ -75,16 +76,18 @@ def main(): |
75 | 76 |
|
76 | 77 | with GITHUB_SUMMARY.open("w") as output_fp: |
77 | 78 | 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} |
82 | 80 | # Print table header |
83 | 81 | print(TABLE_HEADER.format(**totals), file=output_fp) |
84 | 82 |
|
85 | 83 | 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] = "-" |
86 | 89 | line = "| {env_name} | {status} | {duration} | {setup_duration} | {test_duration} | {runner} | {passed} | {failed} | {xfailed} | {xpassed} | {errors} | {warnings} |".format( |
87 | | - **result |
| 90 | + **row |
88 | 91 | ) |
89 | 92 | print(line, file=output_fp) |
90 | 93 |
|
@@ -140,6 +143,7 @@ def summarize_results(results): |
140 | 143 | "errors": counts.get("errors", 0), |
141 | 144 | "warnings": counts.get("warnings", 0), |
142 | 145 | "runner": runner, |
| 146 | + "parsed": bool(counts), # If counts is still empty, this failed to parse |
143 | 147 | } |
144 | 148 | ) |
145 | 149 |
|
|
0 commit comments