1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-27 11:07:44 +00:00

Add step to GnuTest workflow to compare results against master

This commit is contained in:
James Robson 2021-08-05 15:44:03 +01:00
parent fe539a6dea
commit 81a5f0a4dc
2 changed files with 45 additions and 0 deletions

View file

@ -90,3 +90,16 @@ jobs:
with:
name: gnu-result
path: gnu-result.json
- name: Download the result
uses: dawidd6/action-download-artifact@v2
with:
workflow: GnuTests.yml
name: gnu-result
repo: uutils/coreutils
branch: master
path: dl
- name: Compare against master results
shell: bash
run: |
mv dl/gnu-result.json master-gnu-result.json
python uutils/util/compare_gnu_result.py

View file

@ -0,0 +1,32 @@
#! /usr/bin/python
"""
Compare the current results to the last results gathered from the master branch to highlight
if a PR is making the results better/worse
"""
import json
import sys
from os import environ
NEW = json.load(open("gnu-result.json"))
OLD = json.load(open("master-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 master: PASS {pass_d:+d} / FAIL {fail_d:+d} / ERROR {error_d:+d} / SKIP {skip_d:+d} "
)
# If results are worse fail the job to draw attention
if pass_d < 0:
sys.exit(1)