blob: 55d2967b535db04b3623761b680f36eecdaff258 [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
18SKIA_COMMITTER_EMAIL = 'update-meta-config@skia.org'
19SKIA_COMMITTER_NAME = 'Update Meta Config'
20SKIA_REPO_TEMPLATE = 'https://skia.googlesource.com/%s.git'
21
Hal Canary287a3fe2017-05-18 11:29:04 -040022CQ_INCLUDE_CHROMIUM_TRYBOTS = [
23 ('master.tryserver.blink', [
Hal Canary287a3fe2017-05-18 11:29:04 -040024 'linux_trusty_blink_dbg',
Mike Kleinfb4d3f02017-10-25 09:53:23 -040025 'linux_trusty_blink_rel',
26 'mac10.10_blink_rel',
27 'mac10.11_blink_rel',
28 'mac10.11_retina_blink_rel',
29 'mac10.12_blink_rel',
30 'win10_blink_rel',
31 'win7_blink_rel',
Hal Canary287a3fe2017-05-18 11:29:04 -040032 ]),
33 ('master.tryserver.chromium.linux', [
34 'linux_chromium_compile_dbg_ng',
35 'linux_chromium_compile_rel_ng',
36 'linux_chromium_dbg_ng',
37 'linux_chromium_rel_ng',
38 'linux_optional_gpu_tests_rel',
39 ]),
40 ('master.tryserver.chromium.mac', [
41 'mac_chromium_compile_dbg_ng',
42 'mac_chromium_compile_rel_ng',
43 'mac_chromium_dbg_ng',
44 'mac_chromium_rel_ng',
45 'mac_optional_gpu_tests_rel',
46 ]),
47 ('master.tryserver.chromium.win', [
48 'win_chromium_compile_dbg_ng',
49 'win_chromium_compile_rel_ng',
50 'win_chromium_dbg_ng',
Hal Canary287a3fe2017-05-18 11:29:04 -040051 'win_optional_gpu_tests_rel',
Ravi Mistry01f70aa2017-10-17 08:16:28 -040052 'win7_chromium_rel_ng',
53 'win10_chromium_x64_rel_ng',
Hal Canary287a3fe2017-05-18 11:29:04 -040054 ]),
55 ('master.tryserver.chromium.android', [
Mike Kleinf8e353d2017-10-25 12:06:09 -040056 'android_blink_rel',
Hal Canary287a3fe2017-05-18 11:29:04 -040057 'android_compile_dbg',
58 'android_compile_rel',
Ravi Mistry01f70aa2017-10-17 08:16:28 -040059 'android_n5x_swarming_dbg',
60 'android_n5x_swarming_rel',
Hal Canary287a3fe2017-05-18 11:29:04 -040061 'android_optional_gpu_tests_rel',
62 ])
63]
Ravi Mistry01b48e72017-05-17 14:28:06 -040064
65
66def addChromiumTrybots(f):
Hal Canary287a3fe2017-05-18 11:29:04 -040067 for master, bots in CQ_INCLUDE_CHROMIUM_TRYBOTS:
Ravi Mistry01b48e72017-05-17 14:28:06 -040068 f.write('[bucket "%s"]\n' % master)
Hal Canary287a3fe2017-05-18 11:29:04 -040069 for bot in bots:
Ravi Mistry01b48e72017-05-17 14:28:06 -040070 f.write('\tbuilder = %s\n' % bot)
71
72
Eric Borencff9f952017-10-17 09:18:18 -040073def main():
74 parser = argparse.ArgumentParser()
75 parser.add_argument("--gitcookies")
76 parser.add_argument("--repo_name")
77 parser.add_argument("--tasks_json")
78 args = parser.parse_args()
79
80 skia_repo = SKIA_REPO_TEMPLATE % args.repo_name
Ravi Mistry01b48e72017-05-17 14:28:06 -040081 with git_utils.NewGitCheckout(repository=skia_repo):
82 # Fetch and checkout the meta/config branch.
83 subprocess.check_call(['git', 'fetch', skia_repo, 'refs/meta/config:cfg'])
84 subprocess.check_call(['git', 'checkout', 'cfg'])
85
86 # Create list of tryjobs from tasks_json.
87 tryjobs = []
Eric Borencff9f952017-10-17 09:18:18 -040088 with open(args.tasks_json) as tasks_json:
Ravi Mistry01b48e72017-05-17 14:28:06 -040089 data = json.load(tasks_json)
90 for job in data['jobs'].keys():
91 if not job.startswith('Upload-'):
92 tryjobs.append(job)
93 tryjobs.sort()
94
95 # Write to buildbucket.config.
96 buildbucket_config = os.path.join(os.getcwd(), 'buildbucket.config')
97 with open(buildbucket_config, 'w') as f:
98
Eric Borencff9f952017-10-17 09:18:18 -040099 if args.repo_name == 'skia':
Ravi Mistry01b48e72017-05-17 14:28:06 -0400100 addChromiumTrybots(f)
101
102 # Adding all Skia jobs.
103 f.write('[bucket "skia.primary"]\n')
104 for job in tryjobs:
105 f.write('\tbuilder = ' + job + '\n')
106
107 # Push the change as the update-meta-config user.
108 config_dict = {
109 'user.name': SKIA_COMMITTER_NAME,
110 'user.email': SKIA_COMMITTER_EMAIL,
Eric Borencff9f952017-10-17 09:18:18 -0400111 'http.cookiefile': args.gitcookies,
Ravi Mistry01b48e72017-05-17 14:28:06 -0400112 }
113 with git_utils.GitLocalConfig(config_dict):
114 subprocess.check_call(['git', 'add', 'buildbucket.config'])
115 try:
116 subprocess.check_call(
117 ['git', 'commit', '-m', 'Update builders in buildbucket.config'])
118 except subprocess.CalledProcessError:
119 print 'No changes to buildbucket.config'
120 return
121
122 subprocess.check_call(['git', 'push', skia_repo, 'cfg:refs/meta/config'])
123
124
125if '__main__' == __name__:
Eric Borencff9f952017-10-17 09:18:18 -0400126 main()