From 6376517472259310185b224f58973fdc24edbe6a Mon Sep 17 00:00:00 2001 From: Eric Boren Date: Mon, 16 Oct 2017 14:22:47 -0400 Subject: Add bin/try script Wrapper for "git cl try" which allows searching jobs using regular expressions. Bug: skia: Change-Id: I07a1b487f2eca9da7df4c4d4c65e22e459b76fed Reviewed-on: https://skia-review.googlesource.com/60261 Commit-Queue: Eric Boren Reviewed-by: Kevin Lubick Reviewed-by: Ravi Mistry --- bin/try | 10 +++++++++ bin/try.bat | 6 ++++++ bin/try.py | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+) create mode 100755 bin/try create mode 100644 bin/try.bat create mode 100755 bin/try.py (limited to 'bin') diff --git a/bin/try b/bin/try new file mode 100755 index 0000000000..6bc08bdeb0 --- /dev/null +++ b/bin/try @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +# Copyright 2017 Google Inc. +# +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +base_dir=$(dirname "$0") + +python "$base_dir/try.py" "$@" diff --git a/bin/try.bat b/bin/try.bat new file mode 100644 index 0000000000..a0685c7f89 --- /dev/null +++ b/bin/try.bat @@ -0,0 +1,6 @@ +@echo off +:: Copyright 2017 Google Inc. +:: +:: Use of this source code is governed by a BSD-style license that can be +:: found in the LICENSE file. +python "%~dp0\try.py" %* diff --git a/bin/try.py b/bin/try.py new file mode 100755 index 0000000000..a5dc378255 --- /dev/null +++ b/bin/try.py @@ -0,0 +1,70 @@ +#!/usr/bin/env python + +# Copyright 2017 Google Inc. +# +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + + +"""Submit one or more try jobs.""" + + +import argparse +import json +import os +import re +import subprocess +import sys + + +BUCKET = 'skia.primary' +CHECKOUT_ROOT = os.path.realpath(os.path.join( + os.path.dirname(os.path.abspath(__file__)), os.pardir)) +JOBS_JSON = os.path.join(CHECKOUT_ROOT, 'infra', 'bots', 'jobs.json') + + +def main(): + # Parse arguments. + d = 'Helper script for triggering try jobs defined in %s.' % JOBS_JSON + parser = argparse.ArgumentParser(description=d) + parser.add_argument('--list', action='store_true', default=False, + help='Just list the jobs; do not trigger anything.') + parser.add_argument('job', nargs='?', default=None, + help='Job name or regular expression to match job names.') + args = parser.parse_args() + + # Load and filter the list of jobs. + with open(JOBS_JSON) as f: + jobs = json.load(f) + if args.job: + jobs = [j for j in jobs if re.search(args.job, j)] + + # Display the list of jobs. + if len(jobs) == 0: + print 'Found no jobs matching "%s"' % repr(args.job) + sys.exit(1) + print 'Found %d jobs:' % len(jobs) + for j in jobs: + print ' %s' % j + if args.list: + return + + # Prompt before triggering jobs. + resp = raw_input('\nDo you want to trigger these jobs? (y/n) ') + if resp != 'y': + sys.exit(1) + + # Trigger the try jobs. + cmd = ['git', 'cl', 'try', '-B', BUCKET] + for j in jobs: + cmd.extend(['-b', j]) + try: + subprocess.check_call(cmd) + except subprocess.CalledProcessError: + # Output from the command will fall through, so just exit here rather than + # printing a stack trace. + sys.exit(1) + + +if __name__ == '__main__': + main() -- cgit v1.2.3