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 <richard.purdie@linuxfoundation.org>
This commit is contained in:
Richard Purdie 2019-11-16 16:21:48 +00:00
parent 014a1c4b89
commit 79dd2f94aa
3 changed files with 25 additions and 9 deletions

View File

@ -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)

View File

@ -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])

View File

@ -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