blob: f7e5fe62ce41d6b8bdab7b4b7a7100b1f241f4bd [file] [log] [blame]
Ravi Mistry01b48e72017-05-17 14:28:06 -04001# Copyright 2017 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5"""Update meta/config of the specified Skia repo."""
6
7
8import argparse
9import json
10import os
11import subprocess
12import sys
13import urllib2
14
15import git_utils
16
17
Ravi Mistry01b48e72017-05-17 14:28:06 -040018SKIA_REPO_TEMPLATE = 'https://skia.googlesource.com/%s.git'
19
Ravi Mistryc95e54b2019-11-14 15:46:47 -050020CQ_INCLUDE_CHROMIUM_BUCKETS = [
21 'luci.chromium.try',
Hal Canary287a3fe2017-05-18 11:29:04 -040022]
Ravi Mistry01b48e72017-05-17 14:28:06 -040023
24
Ravi Mistryc95e54b2019-11-14 15:46:47 -050025def addChromiumBuckets(f):
26 for bucket in CQ_INCLUDE_CHROMIUM_BUCKETS:
27 f.write('[bucket "%s"]\n' % bucket)
Ravi Mistry01b48e72017-05-17 14:28:06 -040028
29
Eric Borencff9f952017-10-17 09:18:18 -040030def main():
31 parser = argparse.ArgumentParser()
Eric Borencff9f952017-10-17 09:18:18 -040032 parser.add_argument("--repo_name")
33 parser.add_argument("--tasks_json")
34 args = parser.parse_args()
35
36 skia_repo = SKIA_REPO_TEMPLATE % args.repo_name
Ravi Mistry01b48e72017-05-17 14:28:06 -040037 with git_utils.NewGitCheckout(repository=skia_repo):
38 # Fetch and checkout the meta/config branch.
39 subprocess.check_call(['git', 'fetch', skia_repo, 'refs/meta/config:cfg'])
40 subprocess.check_call(['git', 'checkout', 'cfg'])
41
42 # Create list of tryjobs from tasks_json.
43 tryjobs = []
Eric Borencff9f952017-10-17 09:18:18 -040044 with open(args.tasks_json) as tasks_json:
Ravi Mistry01b48e72017-05-17 14:28:06 -040045 data = json.load(tasks_json)
46 for job in data['jobs'].keys():
47 if not job.startswith('Upload-'):
48 tryjobs.append(job)
49 tryjobs.sort()
50
51 # Write to buildbucket.config.
52 buildbucket_config = os.path.join(os.getcwd(), 'buildbucket.config')
53 with open(buildbucket_config, 'w') as f:
54
Eric Borencff9f952017-10-17 09:18:18 -040055 if args.repo_name == 'skia':
Ravi Mistryc95e54b2019-11-14 15:46:47 -050056 addChromiumBuckets(f)
Ravi Mistry01b48e72017-05-17 14:28:06 -040057
58 # Adding all Skia jobs.
Ravi Mistryf6e3eaf2020-02-05 16:19:25 -050059 f.write('[bucket "luci.skia.skia.primary"]\n')
Ravi Mistry01b48e72017-05-17 14:28:06 -040060 for job in tryjobs:
61 f.write('\tbuilder = ' + job + '\n')
62
Eric Boren32f84782018-04-23 08:20:57 -040063 subprocess.check_call(['git', 'add', 'buildbucket.config'])
64 try:
65 subprocess.check_call(
66 ['git', 'commit', '-m', 'Update builders in buildbucket.config'])
67 except subprocess.CalledProcessError:
68 print 'No changes to buildbucket.config'
69 return
Ravi Mistry01b48e72017-05-17 14:28:06 -040070
Eric Boren32f84782018-04-23 08:20:57 -040071 subprocess.check_call(['git', 'push', skia_repo, 'cfg:refs/meta/config'])
Ravi Mistry01b48e72017-05-17 14:28:06 -040072
73
74if '__main__' == __name__:
Eric Borencff9f952017-10-17 09:18:18 -040075 main()