bin/try: Add support for select Chromium trybots

These are hard-coded in update_meta_config.py, which is used to set the
list of trybots in Gerrit.

Bug: skia:
Change-Id: I6e512e4cb59974e27e8954cf5134c70068e716f3
Reviewed-on: https://skia-review.googlesource.com/60521
Reviewed-by: Ravi Mistry <rmistry@google.com>
Commit-Queue: Eric Boren <borenet@google.com>
This commit is contained in:
Eric Boren 2017-10-17 09:18:18 -04:00 committed by Skia Commit-Bot
parent 7bbbf62d6e
commit cff9f956c7
2 changed files with 47 additions and 28 deletions

View File

@ -17,10 +17,15 @@ import subprocess
import sys
BUCKET = 'skia.primary'
BUCKET_SKIA_PRIMARY = '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')
INFRA_BOTS = os.path.join(CHECKOUT_ROOT, 'infra', 'bots')
JOBS_JSON = os.path.join(INFRA_BOTS, 'jobs.json')
sys.path.insert(0, INFRA_BOTS)
import update_meta_config
def main():
@ -33,19 +38,31 @@ def main():
help='Job name or regular expression to match job names.')
args = parser.parse_args()
# Load and filter the list of jobs.
# Load and filter the list of Skia jobs.
jobs = []
with open(JOBS_JSON) as f:
jobs = json.load(f)
jobs.append((BUCKET_SKIA_PRIMARY, json.load(f)))
jobs.extend(update_meta_config.CQ_INCLUDE_CHROMIUM_TRYBOTS)
if args.job:
jobs = [j for j in jobs if re.search(args.job, j)]
new_jobs = []
for bucket, job_list in jobs:
filtered = [j for j in job_list if re.search(args.job, j)]
if len(filtered) > 0:
new_jobs.append((bucket, filtered))
jobs = new_jobs
# 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
count = 0
for bucket, job_list in jobs:
count += len(job_list)
print 'Found %d jobs:' % count
for bucket, job_list in jobs:
print ' %s:' % bucket
for j in job_list:
print ' %s' % j
if args.list:
return
@ -55,15 +72,16 @@ def main():
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)
for bucket, job_list in jobs:
cmd = ['git', 'cl', 'try', '-B', bucket]
for j in job_list:
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__':

View File

@ -63,8 +63,14 @@ def addChromiumTrybots(f):
f.write('\tbuilder = %s\n' % bot)
def main(gitcookies, repo_name, tasks_json):
skia_repo = SKIA_REPO_TEMPLATE % repo_name
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--gitcookies")
parser.add_argument("--repo_name")
parser.add_argument("--tasks_json")
args = parser.parse_args()
skia_repo = SKIA_REPO_TEMPLATE % args.repo_name
with git_utils.NewGitCheckout(repository=skia_repo):
# Fetch and checkout the meta/config branch.
subprocess.check_call(['git', 'fetch', skia_repo, 'refs/meta/config:cfg'])
@ -72,7 +78,7 @@ def main(gitcookies, repo_name, tasks_json):
# Create list of tryjobs from tasks_json.
tryjobs = []
with open(tasks_json) as tasks_json:
with open(args.tasks_json) as tasks_json:
data = json.load(tasks_json)
for job in data['jobs'].keys():
if not job.startswith('Upload-'):
@ -83,7 +89,7 @@ def main(gitcookies, repo_name, tasks_json):
buildbucket_config = os.path.join(os.getcwd(), 'buildbucket.config')
with open(buildbucket_config, 'w') as f:
if repo_name == 'skia':
if args.repo_name == 'skia':
addChromiumTrybots(f)
# Adding all Skia jobs.
@ -95,7 +101,7 @@ def main(gitcookies, repo_name, tasks_json):
config_dict = {
'user.name': SKIA_COMMITTER_NAME,
'user.email': SKIA_COMMITTER_EMAIL,
'http.cookiefile': gitcookies,
'http.cookiefile': args.gitcookies,
}
with git_utils.GitLocalConfig(config_dict):
subprocess.check_call(['git', 'add', 'buildbucket.config'])
@ -110,9 +116,4 @@ def main(gitcookies, repo_name, tasks_json):
if '__main__' == __name__:
parser = argparse.ArgumentParser()
parser.add_argument("--gitcookies")
parser.add_argument("--repo_name")
parser.add_argument("--tasks_json")
args = parser.parse_args()
main(args.gitcookies, args.repo_name, args.tasks_json)
main()