6376517472
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>
71 lines
1.8 KiB
Python
Executable File
71 lines
1.8 KiB
Python
Executable File
#!/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()
|