File: compare_gnu_result.py

package info (click to toggle)
rust-coreutils 0.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 485,976 kB
  • sloc: ansic: 103,608; asm: 28,570; sh: 8,672; python: 5,662; makefile: 474; cpp: 97; javascript: 72
file content (50 lines) | stat: -rwxr-xr-x 1,615 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python3

"""
Compare the current results to the last results gathered from the main branch to
highlight if a PR is making the results better/worse.
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

REPO_DEFAULT_BRANCH = environ.get("REPO_DEFAULT_BRANCH", "main")
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(
    f"""::warning ::Changes from '{REPO_DEFAULT_BRANCH}': PASS {pass_d:+d} /
    FAIL {fail_d:+d} / ERROR {error_d:+d} / SKIP {skip_d:+d}"""
)

# If results are worse, check if we should fail the job
if pass_d < 0:
    print(
        f"""::error ::PASS count is reduced from
        '{REPO_DEFAULT_BRANCH}': PASS {pass_d:+d}"""
    )

    # Check if all failing tests are intermittent based on the environment variable
    only_intermittent = ONLY_INTERMITTENT.lower() == "true"

    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)