From 79dd2f94aa192d8340838e25c5131cd3cc6eb8ab Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Sat, 16 Nov 2019 16:21:48 +0000 Subject: [PATCH] send-qa-email/utils: Improve new branch regression script handling 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 --- scripts/build-perf-test-wrapper | 2 +- scripts/send-qa-email | 24 +++++++++++++++++++----- scripts/utils.py | 8 +++++--- 3 files changed, 25 insertions(+), 9 deletions(-) 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 a769bbc..3b07209 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,13 +62,25 @@ 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]) 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 e022709..68652d9 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