| 1 |
#!/usr/bin/env python3 |
| 2 |
|
| 3 |
""" |
| 4 |
Compare the current results to the last results gathered from the main branch to |
| 5 |
highlight if a PR is making the results better/worse. |
| 6 |
Don't exit with error code if all failing tests are in the ignore-intermittent.txt list. |
| 7 |
""" |
| 8 |
|
| 9 |
import json |
| 10 |
import sys |
| 11 |
from os import environ |
| 12 |
|
| 13 |
REPO_DEFAULT_BRANCH = environ.get("REPO_DEFAULT_BRANCH", "main") |
| 14 |
ONLY_INTERMITTENT = environ.get("ONLY_INTERMITTENT", "false") |
| 15 |
|
| 16 |
with open("gnu-result.json") as f: |
| 17 |
NEW = json.load(f) |
| 18 |
with open("main-gnu-result.json") as f: |
| 19 |
OLD = json.load(f) |
| 20 |
|
| 21 |
# Extract the specific results from the dicts |
| 22 |
last = OLD[next(iter(OLD.keys()))] |
| 23 |
current = NEW[next(iter(NEW.keys()))] |
| 24 |
|
| 25 |
|
| 26 |
pass_d = int(current["pass"]) - int(last["pass"]) |
| 27 |
fail_d = int(current["fail"]) - int(last["fail"]) |
| 28 |
error_d = int(current["error"]) - int(last["error"]) |
| 29 |
skip_d = int(current["skip"]) - int(last["skip"]) |
| 30 |
|
| 31 |
# Get an annotation to highlight changes |
| 32 |
print( |
| 33 |
f"""::warning ::Changes from '{REPO_DEFAULT_BRANCH}': PASS {pass_d:+d} / |
| 34 |
FAIL {fail_d:+d} / ERROR {error_d:+d} / SKIP {skip_d:+d}""" |
| 35 |
) |
| 36 |
|
| 37 |
# If results are worse, check if we should fail the job |
| 38 |
if pass_d < 0: |
| 39 |
print( |
| 40 |
f"""::error ::PASS count is reduced from |
| 41 |
'{REPO_DEFAULT_BRANCH}': PASS {pass_d:+d}""" |
| 42 |
) |
| 43 |
|
| 44 |
# Check if all failing tests are intermittent based on the environment variable |
| 45 |
only_intermittent = ONLY_INTERMITTENT.lower() == "true" |
| 46 |
|
| 47 |
if only_intermittent: |
| 48 |
print("::notice ::All failing tests are in the ignored intermittent list") |
| 49 |
print("::notice ::Not failing the build") |
| 50 |
else: |
| 51 |
print("::error ::Found non-ignored failing tests") |
| 52 |
sys.exit(1) |