diff mbox series

[yocto-autobuilder-helper,6/8] scripts/send-qa-email: fix testing branches regression reporting

Message ID 20230313145145.2574842-7-alexis.lothore@bootlin.com
State New
Headers show
Series fix regression reports generation on "master-next" branches | expand

Commit Message

Alexis Lothoré March 13, 2023, 2:51 p.m. UTC
From: Alexis Lothoré <alexis.lothore@bootlin.com>

d6018b891a3b7c62c7a2883c7fb9ae55e66f1363 broke regression reporting for testing
branches (e.g: master-next in poky, ross/mut in poky-contrib) by ignoring the comparebranch returned by
utils.getcomparison branch

Fix regression reporting for those branches by using comparebranch again. The
fix also refactor/add a intermediary step to guess base and target for
regression reporting, to isolate a bit the logic and make it easier later to add
multiple base/target couples

Signed-off-by: Alexis Lothoré <alexis.lothore@bootlin.com>
---
 scripts/send_qa_email.py | 27 +++++++++++++++++++--------
 1 file changed, 19 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/scripts/send_qa_email.py b/scripts/send_qa_email.py
index 540eb94..78e051a 100755
--- a/scripts/send_qa_email.py
+++ b/scripts/send_qa_email.py
@@ -49,18 +49,28 @@  def get_previous_tag(targetrepodir, version):
     defaultbaseversion, _, _ = utils.get_version_from_string(subprocess.check_output(["git", "describe", "--abbrev=0"], cwd=targetrepodir).decode('utf-8').strip())
     return utils.get_tag_from_version(defaultbaseversion, None)
 
-def generate_regression_report(querytool, targetrepodir, basebranch, resultdir, outputdir, yoctoversion):
-    baseversion = get_previous_tag(targetrepodir, yoctoversion)
-    print(f"Comparing {basebranch} to {baseversion}")
+def get_regression_base_and_target(basebranch, comparebranch, release, targetrepodir):
+    if not basebranch:
+        # Basebranch/comparebranch is an arbitrary configuration (not defined in config.json): do not run regression reporting
+        return None, None
+
+    if is_release_version(release):
+        # We are on a release: ignore comparebranch (which is very likely None), regression reporting must be done against previous tag
+        return get_previous_tag(targetrepodir, release), basebranch
+    elif comparebranch:
+        # Basebranch/comparebranch is defined in config.json: regression reporting must be done against branches as defined in config.json
+        return comparebranch, basebranch
+
+def generate_regression_report(querytool, targetrepodir, base, target, resultdir, outputdir):
+    print(f"Comparing {target} to {base}")
 
     try:
-        regreport = subprocess.check_output([querytool, "regression-report", baseversion, basebranch, '-t', resultdir])
+        regreport = subprocess.check_output([querytool, "regression-report", base, target, '-t', resultdir])
         with open(outputdir + "/testresult-regressions-report.txt", "wb") as f:
            f.write(regreport)
     except subprocess.CalledProcessError as e:
         error = str(e)
-        print(f"Error while generating report between {basebranch} and {baseversion} : {error}")
-
+        print(f"Error while generating report between {target} and {base} : {error}")
 
 def send_qa_email():
     parser = utils.ArgParser(description='Process test results and optionally send an email about the build to prompt QA to begin testing.')
@@ -142,8 +152,9 @@  def send_qa_email():
                 subprocess.check_call(["git", "push", "--all"], cwd=tempdir)
                 subprocess.check_call(["git", "push", "--tags"], cwd=tempdir)
 
-            if basebranch:
-                generate_regression_report(querytool, targetrepodir, basebranch, tempdir, args.results_dir, args.release)
+            regression_base, regression_target = get_regression_base_and_target(basebranch, comparebranch, args.release, targetrepodir)
+            if regression_base and regression_target:
+                generate_regression_report(querytool, targetrepodir, regression_base, regression_target, tempdir, args.results_dir)
 
         finally:
             subprocess.check_call(["rm", "-rf",  tempdir])