2017-05-17 18:28:06 +00:00
|
|
|
# Copyright 2017 The Chromium Authors. All rights reserved.
|
|
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
|
|
# found in the LICENSE file.
|
|
|
|
|
|
|
|
"""Update meta/config of the specified Skia repo."""
|
|
|
|
|
|
|
|
|
|
|
|
import argparse
|
|
|
|
import json
|
|
|
|
import os
|
|
|
|
import subprocess
|
|
|
|
import sys
|
|
|
|
import urllib2
|
|
|
|
|
|
|
|
import git_utils
|
|
|
|
|
|
|
|
|
|
|
|
SKIA_REPO_TEMPLATE = 'https://skia.googlesource.com/%s.git'
|
|
|
|
|
2019-11-14 20:46:47 +00:00
|
|
|
CQ_INCLUDE_CHROMIUM_BUCKETS = [
|
|
|
|
'luci.chromium.try',
|
2017-05-18 15:29:04 +00:00
|
|
|
]
|
2017-05-17 18:28:06 +00:00
|
|
|
|
|
|
|
|
2019-11-14 20:46:47 +00:00
|
|
|
def addChromiumBuckets(f):
|
|
|
|
for bucket in CQ_INCLUDE_CHROMIUM_BUCKETS:
|
|
|
|
f.write('[bucket "%s"]\n' % bucket)
|
2017-05-17 18:28:06 +00:00
|
|
|
|
|
|
|
|
2017-10-17 13:18:18 +00:00
|
|
|
def main():
|
|
|
|
parser = argparse.ArgumentParser()
|
|
|
|
parser.add_argument("--repo_name")
|
|
|
|
parser.add_argument("--tasks_json")
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
skia_repo = SKIA_REPO_TEMPLATE % args.repo_name
|
2017-05-17 18:28:06 +00:00
|
|
|
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'])
|
|
|
|
subprocess.check_call(['git', 'checkout', 'cfg'])
|
|
|
|
|
|
|
|
# Create list of tryjobs from tasks_json.
|
|
|
|
tryjobs = []
|
2017-10-17 13:18:18 +00:00
|
|
|
with open(args.tasks_json) as tasks_json:
|
2017-05-17 18:28:06 +00:00
|
|
|
data = json.load(tasks_json)
|
|
|
|
for job in data['jobs'].keys():
|
|
|
|
if not job.startswith('Upload-'):
|
|
|
|
tryjobs.append(job)
|
|
|
|
tryjobs.sort()
|
|
|
|
|
|
|
|
# Write to buildbucket.config.
|
|
|
|
buildbucket_config = os.path.join(os.getcwd(), 'buildbucket.config')
|
|
|
|
with open(buildbucket_config, 'w') as f:
|
|
|
|
|
2017-10-17 13:18:18 +00:00
|
|
|
if args.repo_name == 'skia':
|
2019-11-14 20:46:47 +00:00
|
|
|
addChromiumBuckets(f)
|
2017-05-17 18:28:06 +00:00
|
|
|
|
|
|
|
# Adding all Skia jobs.
|
2020-02-05 21:19:25 +00:00
|
|
|
f.write('[bucket "luci.skia.skia.primary"]\n')
|
2017-05-17 18:28:06 +00:00
|
|
|
for job in tryjobs:
|
|
|
|
f.write('\tbuilder = ' + job + '\n')
|
|
|
|
|
2018-04-23 12:20:57 +00:00
|
|
|
subprocess.check_call(['git', 'add', 'buildbucket.config'])
|
|
|
|
try:
|
|
|
|
subprocess.check_call(
|
|
|
|
['git', 'commit', '-m', 'Update builders in buildbucket.config'])
|
|
|
|
except subprocess.CalledProcessError:
|
|
|
|
print 'No changes to buildbucket.config'
|
|
|
|
return
|
|
|
|
|
|
|
|
subprocess.check_call(['git', 'push', skia_repo, 'cfg:refs/meta/config'])
|
2017-05-17 18:28:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
if '__main__' == __name__:
|
2017-10-17 13:18:18 +00:00
|
|
|
main()
|