[autobuilder-helper,thud,04/40] send-qa-email/utils: Improve new branch regression script handling

Submitted by Richard Purdie on Sept. 10, 2020, 1:29 p.m. | Patch ID: 176326

Details

Message ID 20200910133035.2044355-4-richard.purdie@linuxfoundation.org
State New
Headers show

Commit Message

Richard Purdie Sept. 10, 2020, 1:29 p.m.
There are several issues:

* New branches don't currently have git regression history
* The regression tool errors if there isn't anything to compare against

To fix this, create a branch with history and only generate a regression
report if there are commits to compare against.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 scripts/build-perf-test-wrapper |  2 +-
 scripts/send-qa-email           | 24 +++++++++++++++++++-----
 scripts/utils.py                |  8 +++++---
 3 files changed, 25 insertions(+), 9 deletions(-)

Patch hide | download patch | download mbox

diff --git a/scripts/build-perf-test-wrapper b/scripts/build-perf-test-wrapper
index ab66a20..e7b24ad 100755
--- a/scripts/build-perf-test-wrapper
+++ b/scripts/build-perf-test-wrapper
@@ -182,7 +182,7 @@  if git_repo:
 
     extraopts = " --branch %s --commit %s" % (branch, gitrevfull)
     if args.repo and args.branch:
-        comparebranch = utils.getcomparisonbranch(ourconfig, args.repo, args.branch)
+        basebranch, comparebranch = utils.getcomparisonbranch(ourconfig, args.repo, args.branch)
         if comparebranch:
             extraopts = extraopts + " --branch2 %s" % (comparebranch)
 
diff --git a/scripts/send-qa-email b/scripts/send-qa-email
index ec89845..38c951b 100755
--- a/scripts/send-qa-email
+++ b/scripts/send-qa-email
@@ -48,8 +48,10 @@  if 'poky' in repos and os.path.exists(resulttool) and args.results_dir:
     branch = repos['poky']['branch']
     repo = repos['poky']['url']
 
-    extraopts = " --branch %s --commit %s" % (branch, revision)
-    comparebranch = utils.getcomparisonbranch(ourconfig, repo, branch)
+    extraopts = None
+    basebranch, comparebranch = utils.getcomparisonbranch(ourconfig, repo, branch)
+    if basebranch:
+        extraopts = " --branch %s --commit %s" % (branch, revision)
     if comparebranch:
         extraopts = extraopts + " --branch2 %s" % (comparebranch)
 
@@ -60,6 +62,17 @@  if 'poky' in repos and os.path.exists(resulttool) and args.results_dir:
     tempdir = tempfile.mkdtemp(prefix='sendqaemail.')
     try:
         subprocess.check_call(["git", "clone", "git@git.yoctoproject.org:yocto-testresults", tempdir])
+
+        # If the base comparision branch isn't present regression comparision won't work
+        # at least until we can tell the tool to ignore internal branch information
+        if basebranch:
+            try:
+                subprocess.check_call(["git", "rev-parse", "--verify", basebranch], cwd=tempdir)
+            except subprocess.CalledProcessError:
+                # Doesn't exist so base it off master
+                subprocess.check_call(["git", "branch", "master", basebranch], cwd=tempdir)
+                extraopts = None
+
         subprocess.check_call([resulttool, "store", args.results_dir, tempdir])
         if basebranch:
             subprocess.check_call(["git", "push", "--all", "--force"], cwd=tempdir)
@@ -68,9 +81,10 @@  if 'poky' in repos and os.path.exists(resulttool) and args.results_dir:
             subprocess.check_call(["git", "push", "--all"], cwd=tempdir)
             subprocess.check_call(["git", "push", "--tags"], cwd=tempdir)
 
-        regreport = subprocess.check_output([resulttool, "regression-git", tempdir] + extraopts.split())
-        with open(args.results_dir + "/testresult-regressions-report.txt", "wb") as f:
-            f.write(regreport)
+        if extraopts:
+            regreport = subprocess.check_output([resulttool, "regression-git", tempdir] + extraopts.split())
+            with open(args.results_dir + "/testresult-regressions-report.txt", "wb") as f:
+                f.write(regreport)
 
     finally:
         subprocess.check_call(["rm", "-rf",  tempdir])
diff --git a/scripts/utils.py b/scripts/utils.py
index 45d3f93..31e1537 100644
--- a/scripts/utils.py
+++ b/scripts/utils.py
@@ -347,11 +347,10 @@  class ArgParser(argparse.ArgumentParser):
 
 #
 # Figure out which branch we might need to compare against
+# Also return whether this is a forked branch or not.
 #
 def getcomparisonbranch(ourconfig, reponame, branchname):
     print("Working off %s:%s\n" % (reponame, branchname))
-    base = None
-    basebranch = None
     if "/" in reponame:
         reponame = reponame.rsplit("/", 1)[1]
     if reponame.endswith(".git"):
@@ -361,4 +360,7 @@  def getcomparisonbranch(ourconfig, reponame, branchname):
         if base:
             baserepo, basebranch = base.split(":")
             print("Comparing to %s\n" % (basebranch))
-    return basebranch
+            return branchname, basebranch
+    if (reponame + ":" + branchname) in getconfig("BUILD_HISTORY_DIRECTPUSH", ourconfig):
+        return branchname, None
+    return None, None