blob: 8688e785ae4c336b94a4df737e8491dd3d53b9db [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
Hal Canary287a3fe2017-05-18 11:29:04 -040020CQ_INCLUDE_CHROMIUM_TRYBOTS = [
Eric Boren464846e2018-03-15 13:34:23 -040021 ('luci.chromium.try', [
Yuly Novikov73bd3db2018-03-21 16:21:49 -040022 'android_optional_gpu_tests_rel',
Eric Borena2e613c2018-11-26 10:35:18 -050023 'linux-blink-rel',
Ravi Mistrya19381d2018-04-16 14:07:21 -040024 'linux_chromium_compile_dbg_ng',
25 'linux_chromium_dbg_ng',
26 'linux_chromium_rel_ng',
Eric Boren464846e2018-03-15 13:34:23 -040027 'linux_optional_gpu_tests_rel',
Eric Borena2e613c2018-11-26 10:35:18 -050028 'mac10.10-blink-rel',
29 'mac10.11-blink-rel',
30 'mac10.12-blink-rel',
31 'mac10.13-blink-rel',
32 'mac10.13_retina-blink-rel',
Eric Borene8faee72018-03-21 16:23:25 -040033 'mac_chromium_compile_dbg_ng',
Ravi Mistrya19381d2018-04-16 14:07:21 -040034 'mac_chromium_compile_rel_ng',
35 'mac_chromium_dbg_ng',
36 'mac_chromium_rel_ng',
Corentin Wallez578a8f12018-03-20 13:42:43 -040037 'mac_optional_gpu_tests_rel',
Eric Borena2e613c2018-11-26 10:35:18 -050038 'win10-blink-rel',
39 'win7-blink-rel',
Ravi Mistrya19381d2018-04-16 14:07:21 -040040 'win_chromium_compile_dbg_ng',
41 'win_chromium_dbg_ng',
Corentin Walleza5914282018-04-11 15:45:39 -040042 'win_optional_gpu_tests_rel',
Eric Boren464846e2018-03-15 13:34:23 -040043 ]),
Hal Canary287a3fe2017-05-18 11:29:04 -040044 ('master.tryserver.chromium.linux', [
Hal Canary287a3fe2017-05-18 11:29:04 -040045 'linux_chromium_compile_rel_ng',
Hal Canary287a3fe2017-05-18 11:29:04 -040046 ]),
47 ('master.tryserver.chromium.win', [
Hal Canary287a3fe2017-05-18 11:29:04 -040048 'win_chromium_compile_rel_ng',
Ravi Mistry01f70aa2017-10-17 08:16:28 -040049 'win7_chromium_rel_ng',
50 'win10_chromium_x64_rel_ng',
Hal Canary287a3fe2017-05-18 11:29:04 -040051 ]),
52 ('master.tryserver.chromium.android', [
Mike Kleinf8e353d2017-10-25 12:06:09 -040053 'android_blink_rel',
Hal Canary287a3fe2017-05-18 11:29:04 -040054 'android_compile_dbg',
55 'android_compile_rel',
Ravi Mistry01f70aa2017-10-17 08:16:28 -040056 'android_n5x_swarming_dbg',
57 'android_n5x_swarming_rel',
Hal Canary287a3fe2017-05-18 11:29:04 -040058 ])
59]
Ravi Mistry01b48e72017-05-17 14:28:06 -040060
61
62def addChromiumTrybots(f):
Hal Canary287a3fe2017-05-18 11:29:04 -040063 for master, bots in CQ_INCLUDE_CHROMIUM_TRYBOTS:
Ravi Mistry01b48e72017-05-17 14:28:06 -040064 f.write('[bucket "%s"]\n' % master)
Hal Canary287a3fe2017-05-18 11:29:04 -040065 for bot in bots:
Ravi Mistry01b48e72017-05-17 14:28:06 -040066 f.write('\tbuilder = %s\n' % bot)
67
68
Eric Borencff9f952017-10-17 09:18:18 -040069def main():
70 parser = argparse.ArgumentParser()
Eric Borencff9f952017-10-17 09:18:18 -040071 parser.add_argument("--repo_name")
72 parser.add_argument("--tasks_json")
73 args = parser.parse_args()
74
75 skia_repo = SKIA_REPO_TEMPLATE % args.repo_name
Ravi Mistry01b48e72017-05-17 14:28:06 -040076 with git_utils.NewGitCheckout(repository=skia_repo):
77 # Fetch and checkout the meta/config branch.
78 subprocess.check_call(['git', 'fetch', skia_repo, 'refs/meta/config:cfg'])
79 subprocess.check_call(['git', 'checkout', 'cfg'])
80
81 # Create list of tryjobs from tasks_json.
82 tryjobs = []
Eric Borencff9f952017-10-17 09:18:18 -040083 with open(args.tasks_json) as tasks_json:
Ravi Mistry01b48e72017-05-17 14:28:06 -040084 data = json.load(tasks_json)
85 for job in data['jobs'].keys():
86 if not job.startswith('Upload-'):
87 tryjobs.append(job)
88 tryjobs.sort()
89
90 # Write to buildbucket.config.
91 buildbucket_config = os.path.join(os.getcwd(), 'buildbucket.config')
92 with open(buildbucket_config, 'w') as f:
93
Eric Borencff9f952017-10-17 09:18:18 -040094 if args.repo_name == 'skia':
Ravi Mistry01b48e72017-05-17 14:28:06 -040095 addChromiumTrybots(f)
96
97 # Adding all Skia jobs.
98 f.write('[bucket "skia.primary"]\n')
99 for job in tryjobs:
100 f.write('\tbuilder = ' + job + '\n')
101
Eric Boren32f84782018-04-23 08:20:57 -0400102 subprocess.check_call(['git', 'add', 'buildbucket.config'])
103 try:
104 subprocess.check_call(
105 ['git', 'commit', '-m', 'Update builders in buildbucket.config'])
106 except subprocess.CalledProcessError:
107 print 'No changes to buildbucket.config'
108 return
Ravi Mistry01b48e72017-05-17 14:28:06 -0400109
Eric Boren32f84782018-04-23 08:20:57 -0400110 subprocess.check_call(['git', 'push', skia_repo, 'cfg:refs/meta/config'])
Ravi Mistry01b48e72017-05-17 14:28:06 -0400111
112
113if '__main__' == __name__:
Eric Borencff9f952017-10-17 09:18:18 -0400114 main()