diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2020-10-13 12:46:26 +0100 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2020-10-13 12:46:26 +0100 |
commit | b37da837630ca7cdbc45de4c5339bbfc6d21beed (patch) | |
tree | caa5f92f4c8b01d3bacfa690a0651411c8b05ad5 /scripts | |
parent | 724c1c8bb350d84c097ab2005aad15e125d06b6c (diff) | |
parent | ea8bf1e514d2f442dd1a008794eb1563e2ee1c48 (diff) | |
download | qemu-b37da837630ca7cdbc45de4c5339bbfc6d21beed.zip |
Merge remote-tracking branch 'remotes/huth-gitlab/tags/pull-request-2020-10-13' into staging
* qtest improvements (test for crash found with the fuzzer, increase
downtime in migration test, less verbose output when running w/o KVM)
* Improve handling of acceptance tests in the Gitlab-CI
* Run checkpatch.pl in the Gitlab-CI
* Improve the gitlab-pipeline-status script
* Misc patches (mark 'moxie' as deprecated, remove stale .gitignore files, ...)
# gpg: Signature made Tue 13 Oct 2020 11:49:06 BST
# gpg: using RSA key 27B88847EEE0250118F3EAB92ED9D774FE702DB5
# gpg: issuer "thuth@redhat.com"
# gpg: Good signature from "Thomas Huth <th.huth@gmx.de>" [full]
# gpg: aka "Thomas Huth <thuth@redhat.com>" [full]
# gpg: aka "Thomas Huth <huth@tuxfamily.org>" [full]
# gpg: aka "Thomas Huth <th.huth@posteo.de>" [unknown]
# Primary key fingerprint: 27B8 8847 EEE0 2501 18F3 EAB9 2ED9 D774 FE70 2DB5
* remotes/huth-gitlab/tags/pull-request-2020-10-13: (23 commits)
scripts/ci/gitlab-pipeline-status: wait for pipeline creation
scripts/ci/gitlab-pipeline-status: use more descriptive exceptions
scripts/ci/gitlab-pipeline-status: handle keyboard interrupts
scripts/ci/gitlab-pipeline-status: refactor parser creation
scripts/ci/gitlab-pipeline-status: give early feedback on running pipelines
scripts/ci/gitlab-pipeline-status: improve message regarding timeout
scripts/ci/gitlab-pipeline-status: make branch name configurable
gitlab: assign python helper files to GitLab maintainers section
gitlab: add a CI job to validate the DCO sign off
gitlab: add a CI job for running checkpatch.pl
configure: fixes indent of $meson setup
docs/system/deprecated: Mark the 'moxie' CPU as deprecated
Remove superfluous .gitignore files
MAINTAINERS: Ignore bios-tables-test in the qtest section
Add a comment in bios-tables-test.c to clarify the reason behind approach
softmmu/vl: Be less verbose about missing KVM when running the qtests
tests/migration: Allow longer timeouts
qtest: add fuzz test case
Acceptance tests: show test report on GitLab CI
Acceptance tests: do not show canceled test logs on GitLab CI
...
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/ci/gitlab-pipeline-status | 63 |
1 files changed, 44 insertions, 19 deletions
diff --git a/scripts/ci/gitlab-pipeline-status b/scripts/ci/gitlab-pipeline-status index 348a49b6a4..bac8233079 100755 --- a/scripts/ci/gitlab-pipeline-status +++ b/scripts/ci/gitlab-pipeline-status @@ -23,20 +23,28 @@ import time import sys -def get_local_staging_branch_commit(): +class CommunicationFailure(Exception): + """Failed to communicate to gitlab.com APIs.""" + + +class NoPipelineFound(Exception): + """Communication is successfull but pipeline is not found.""" + + +def get_local_branch_commit(branch='staging'): """ Returns the commit sha1 for the *local* branch named "staging" """ - result = subprocess.run(['git', 'rev-parse', 'staging'], + result = subprocess.run(['git', 'rev-parse', branch], stdin=subprocess.DEVNULL, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, cwd=os.path.dirname(__file__), universal_newlines=True).stdout.strip() - if result == 'staging': - raise ValueError("There's no local branch named 'staging'") + if result == branch: + raise ValueError("There's no local branch named '%s'" % branch) if len(result) != 40: - raise ValueError("Branch staging HEAD doesn't look like a sha1") + raise ValueError("Branch '%s' HEAD doesn't look like a sha1" % branch) return result @@ -50,14 +58,14 @@ def get_pipeline_status(project_id, commit_sha1): connection.request('GET', url=url) response = connection.getresponse() if response.code != http.HTTPStatus.OK: - raise ValueError("Failed to receive a successful response") + raise CommunicationFailure("Failed to receive a successful response") json_response = json.loads(response.read()) # As far as I can tell, there should be only one pipeline for the same # project + commit. If this assumption is false, we can add further # filters to the url, such as username, and order_by. if not json_response: - raise ValueError("No pipeline found") + raise NoPipelineFound("No pipeline found") return json_response[0] @@ -69,16 +77,28 @@ def wait_on_pipeline_success(timeout, interval, start = time.time() while True: if time.time() >= (start + timeout): - print("Waiting on the pipeline timed out") + msg = ("Timeout (-t/--timeout) of %i seconds reached, " + "won't wait any longer for the pipeline to complete") + msg %= timeout + print(msg) return False - status = get_pipeline_status(project_id, commit_sha) - if status['status'] == 'running': + try: + status = get_pipeline_status(project_id, commit_sha) + except NoPipelineFound: + print('Pipeline has not been found, it may not have been created yet.') + time.sleep(1) + continue + + pipeline_status = status['status'] + status_to_wait = ('created', 'waiting_for_resource', 'preparing', + 'pending', 'running') + if pipeline_status in status_to_wait: + print('%s...' % pipeline_status) time.sleep(interval) - print('running...') continue - if status['status'] == 'success': + if pipeline_status == 'success': return True msg = "Pipeline failed, check: %s" % status['web_url'] @@ -86,10 +106,7 @@ def wait_on_pipeline_success(timeout, interval, return False -def main(): - """ - Script entry point - """ +def create_parser(): parser = argparse.ArgumentParser( prog='pipeline-status', description='check or wait on a pipeline status') @@ -110,7 +127,7 @@ def main(): 'for https://gitlab.com/qemu-project/qemu, that ' 'is, "%(default)s"')) try: - default_commit = get_local_staging_branch_commit() + default_commit = get_local_branch_commit() commit_required = False except ValueError: default_commit = '' @@ -124,9 +141,15 @@ def main(): parser.add_argument('--verbose', action='store_true', default=False, help=('A minimal verbosity level that prints the ' 'overall result of the check/wait')) + return parser +def main(): + """ + Script entry point + """ + parser = create_parser() args = parser.parse_args() - + success = False try: if args.wait: success = wait_on_pipeline_success( @@ -139,9 +162,11 @@ def main(): args.commit) success = status['status'] == 'success' except Exception as error: # pylint: disable=W0703 - success = False if args.verbose: print("ERROR: %s" % error.args[0]) + except KeyboardInterrupt: + if args.verbose: + print("Exiting on user's request") if success: if args.verbose: |