aboutsummaryrefslogtreecommitdiffhomepage
path: root/bin
diff options
context:
space:
mode:
authorGravatar Eric Boren <borenet@google.com>2017-10-16 14:22:47 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-10-16 19:37:11 +0000
commit6376517472259310185b224f58973fdc24edbe6a (patch)
treecce4861ae0c5d4efcbcdc87e96648263468a3fa2 /bin
parentcc7a2f6864945ac7c96ce8900f6f339c4fb95f3b (diff)
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 <borenet@google.com> Reviewed-by: Kevin Lubick <kjlubick@google.com> Reviewed-by: Ravi Mistry <rmistry@google.com>
Diffstat (limited to 'bin')
-rwxr-xr-xbin/try10
-rw-r--r--bin/try.bat6
-rwxr-xr-xbin/try.py70
3 files changed, 86 insertions, 0 deletions
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()