2024-03-20 14:41:00 +00:00
|
|
|
#!/usr/bin/env python3
|
2021-08-05 14:44:03 +00:00
|
|
|
|
|
|
|
"""
|
2022-01-22 02:43:02 +00:00
|
|
|
Compare the current results to the last results gathered from the main branch to highlight
|
2021-08-05 14:44:03 +00:00
|
|
|
if a PR is making the results better/worse
|
|
|
|
"""
|
|
|
|
|
|
|
|
import json
|
|
|
|
import sys
|
|
|
|
from os import environ
|
|
|
|
|
2022-08-14 10:45:42 +00:00
|
|
|
REPO_DEFAULT_BRANCH = environ.get("REPO_DEFAULT_BRANCH", "main")
|
2022-03-31 21:38:46 +00:00
|
|
|
|
2021-08-05 14:44:03 +00:00
|
|
|
NEW = json.load(open("gnu-result.json"))
|
2022-01-22 02:43:02 +00:00
|
|
|
OLD = json.load(open("main-gnu-result.json"))
|
2021-08-05 14:44:03 +00:00
|
|
|
|
|
|
|
# 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(
|
2022-03-31 21:38:46 +00:00
|
|
|
f"::warning ::Changes from '{REPO_DEFAULT_BRANCH}': PASS {pass_d:+d} / FAIL {fail_d:+d} / ERROR {error_d:+d} / SKIP {skip_d:+d} "
|
2021-08-05 14:44:03 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# If results are worse fail the job to draw attention
|
|
|
|
if pass_d < 0:
|
2022-03-30 13:54:04 +00:00
|
|
|
print(
|
2022-03-31 21:38:46 +00:00
|
|
|
f"::error ::PASS count is reduced from '{REPO_DEFAULT_BRANCH}': PASS {pass_d:+d} "
|
2022-03-30 13:54:04 +00:00
|
|
|
)
|
2021-08-05 14:44:03 +00:00
|
|
|
sys.exit(1)
|