Skip to content
Snippets Groups Projects
Commit ebbe0df0 authored by Ralf Jung's avatar Ralf Jung
Browse files

Merge remote-tracking branch 'origin/master' into gen_proofmode

parents 88d2204f 658c756f
No related branches found
No related tags found
No related merge requests found
...@@ -45,6 +45,6 @@ for datapoint in results: ...@@ -45,6 +45,6 @@ for datapoint in results:
print("Sending {}...".format(commit), end='') print("Sending {}...".format(commit), end='')
date = subprocess.check_output(['git', 'show', commit, '-s', '--pretty=%cI']).strip().decode('UTF-8') date = subprocess.check_output(['git', 'show', commit, '-s', '--pretty=%cI']).strip().decode('UTF-8')
headers = {'X-Project': args.project, 'X-Branch': args.branch, 'X-Commit': commit, 'X-Config': args.config, 'X-Date': date} headers = {'X-Project': args.project, 'X-Branch': args.branch, 'X-Commit': commit, 'X-Config': args.config, 'X-Date': date}
r = requests.post(args.server+"/build_times_8.6", data=times, headers=headers, auth=(args.user, args.password)) r = requests.post(args.server+"/build_times", data=times, headers=headers, auth=(args.user, args.password))
print(" {}".format(r.text.strip())) print(" {}".format(r.text.strip()))
r.raise_for_status() r.raise_for_status()
#!/usr/bin/env python3 #!/usr/bin/env python3
import argparse, pprint, sys, glob, zipfile import argparse, pprint, sys, glob, zipfile, subprocess
import requests import requests
import parse_log import parse_log
...@@ -40,6 +40,9 @@ parser.add_argument("-c", "--commits", ...@@ -40,6 +40,9 @@ parser.add_argument("-c", "--commits",
parser.add_argument("-a", "--artifacts", parser.add_argument("-a", "--artifacts",
dest="artifacts", dest="artifacts",
help="Location of the artifacts (following GitLab's folder structure). If not given (which should be the common case), the artifacts will be downloaded from GitLab.") help="Location of the artifacts (following GitLab's folder structure). If not given (which should be the common case), the artifacts will be downloaded from GitLab.")
parser.add_argument("-b", "--blacklist-branch",
dest="blacklist_branch",
help="Skip the commit if it is contained in the given branch.")
args = parser.parse_args() args = parser.parse_args()
log_file = sys.stdout if args.file == "-" else open(args.file, "a") log_file = sys.stdout if args.file == "-" else open(args.file, "a")
...@@ -60,7 +63,13 @@ BREAK = False ...@@ -60,7 +63,13 @@ BREAK = False
for commit in parse_log.parse_git_commits(args.commits): for commit in parse_log.parse_git_commits(args.commits):
if BREAK: if BREAK:
break break
print("Fetching {}...".format(commit)) # test to skip the commit
if args.blacklist_branch is not None:
branches = subprocess.check_output(["git", "branch", "-r", "--contains", commit]).decode("utf-8")
if args.blacklist_branch in map(lambda x: x.strip(), branches.split('\n')):
continue
# Find out more about the commit
print("Fetching {}...".format(commit), end='')
commit_data = req("/projects/{}/repository/commits/{}".format(project['id'], commit)) commit_data = req("/projects/{}/repository/commits/{}".format(project['id'], commit))
if commit_data.status_code != 200: if commit_data.status_code != 200:
raise Exception("Commit not found?") raise Exception("Commit not found?")
...@@ -68,10 +77,12 @@ for commit in parse_log.parse_git_commits(args.commits): ...@@ -68,10 +77,12 @@ for commit in parse_log.parse_git_commits(args.commits):
if builds.status_code != 200: if builds.status_code != 200:
raise Exception("Build not found?") raise Exception("Build not found?")
# iterate over builds by decreasing ID, and look for the artifact # iterate over builds by decreasing ID, and look for the artifact
found_build = False
for build in builds.json(): for build in builds.json():
if build['status'] in ('created', 'pending', 'running'): if build['status'] in ('created', 'pending', 'running'):
# build still not yet done, don't fetch this or any later commit # build still not yet done, don't fetch this or any later commit
BREAK = True BREAK = True
print(" build still in progress, aborting")
break break
if build['status'] != 'success': if build['status'] != 'success':
# build failed or cancelled, skip to next # build failed or cancelled, skip to next
...@@ -100,4 +111,8 @@ for commit in parse_log.parse_git_commits(args.commits): ...@@ -100,4 +111,8 @@ for commit in parse_log.parse_git_commits(args.commits):
log_file.write(build_times.text) log_file.write(build_times.text)
log_file.flush() log_file.flush()
# don't fetch another build # don't fetch another build
found_build = True
print(" success")
break break
if not found_build:
print(" found no succeessful build")
...@@ -41,7 +41,7 @@ def parse(file, parse_times = PARSE_FULL): ...@@ -41,7 +41,7 @@ def parse(file, parse_times = PARSE_FULL):
times[name] = time times[name] = time
continue continue
# nothing else we know about, ignore # nothing else we know about, ignore
print("Ignoring line",line) print("Ignoring line",line,"(in commit {})".format(commit))
# end of file. previous commit, if any, is done now. # end of file. previous commit, if any, is done now.
if commit is not None: if commit is not None:
yield Result(commit, times) yield Result(commit, times)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment