Files

51 lines
1.6 KiB
Python
Raw Permalink Normal View History

2024-03-20 19:41:00 +05:00
#!/usr/bin/env python3
"""
2025-03-18 20:36:38 +01:00
Compare the current results to the last results gathered from the main branch to
highlight if a PR is making the results better/worse.
2025-03-07 10:03:59 +01:00
Don't exit with error code if all failing tests are in the ignore-intermittent.txt list.
"""
import json
import sys
from os import environ
2022-08-14 12:45:42 +02:00
REPO_DEFAULT_BRANCH = environ.get("REPO_DEFAULT_BRANCH", "main")
2025-03-07 10:03:59 +01:00
ONLY_INTERMITTENT = environ.get("ONLY_INTERMITTENT", "false")
NEW = json.load(open("gnu-result.json"))
OLD = json.load(open("main-gnu-result.json"))
# Extract the specific results from the dicts
last = OLD[list(OLD.keys())[0]]
current = NEW[list(NEW.keys())[0]]
pass_d = int(current["pass"]) - int(last["pass"])
fail_d = int(current["fail"]) - int(last["fail"])
error_d = int(current["error"]) - int(last["error"])
skip_d = int(current["skip"]) - int(last["skip"])
# Get an annotation to highlight changes
print(
2025-03-18 20:36:38 +01:00
f"""::warning ::Changes from '{REPO_DEFAULT_BRANCH}': PASS {pass_d:+d} /
FAIL {fail_d:+d} / ERROR {error_d:+d} / SKIP {skip_d:+d}"""
)
2025-03-07 10:03:59 +01:00
# If results are worse, check if we should fail the job
if pass_d < 0:
print(
2025-03-18 20:36:38 +01:00
f"""::error ::PASS count is reduced from
'{REPO_DEFAULT_BRANCH}': PASS {pass_d:+d}"""
)
2025-03-07 10:03:59 +01:00
# Check if all failing tests are intermittent based on the environment variable
2025-03-18 19:16:58 +01:00
only_intermittent = ONLY_INTERMITTENT.lower() == "true"
2025-03-07 10:03:59 +01:00
if only_intermittent:
print("::notice ::All failing tests are in the ignored intermittent list")
print("::notice ::Not failing the build")
else:
print("::error ::Found non-ignored failing tests")
sys.exit(1)