blob: 12ac26f79272c5ccdbc9b29438c14cc571a05e2d [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', [
24 'linux_trusty_blink_rel',
25 'linux_trusty_blink_dbg',
26 ]),
27 ('master.tryserver.chromium.linux', [
28 'linux_chromium_compile_dbg_ng',
29 'linux_chromium_compile_rel_ng',
30 'linux_chromium_dbg_ng',
31 'linux_chromium_rel_ng',
32 'linux_optional_gpu_tests_rel',
33 ]),
34 ('master.tryserver.chromium.mac', [
35 'mac_chromium_compile_dbg_ng',
36 'mac_chromium_compile_rel_ng',
37 'mac_chromium_dbg_ng',
38 'mac_chromium_rel_ng',
39 'mac_optional_gpu_tests_rel',
40 ]),
41 ('master.tryserver.chromium.win', [
42 'win_chromium_compile_dbg_ng',
43 'win_chromium_compile_rel_ng',
44 'win_chromium_dbg_ng',
Hal Canary287a3fe2017-05-18 11:29:04 -040045 'win_optional_gpu_tests_rel',
Ravi Mistry01f70aa2017-10-17 08:16:28 -040046 'win7_chromium_rel_ng',
47 'win10_chromium_x64_rel_ng',
Hal Canary287a3fe2017-05-18 11:29:04 -040048 ]),
49 ('master.tryserver.chromium.android', [
50 'android_compile_dbg',
51 'android_compile_rel',
Ravi Mistry01f70aa2017-10-17 08:16:28 -040052 'android_n5x_swarming_dbg',
53 'android_n5x_swarming_rel',
Hal Canary287a3fe2017-05-18 11:29:04 -040054 'android_optional_gpu_tests_rel',
55 ])
56]
Ravi Mistry01b48e72017-05-17 14:28:06 -040057
58
59def addChromiumTrybots(f):
Hal Canary287a3fe2017-05-18 11:29:04 -040060 for master, bots in CQ_INCLUDE_CHROMIUM_TRYBOTS:
Ravi Mistry01b48e72017-05-17 14:28:06 -040061 f.write('[bucket "%s"]\n' % master)
Hal Canary287a3fe2017-05-18 11:29:04 -040062 for bot in bots:
Ravi Mistry01b48e72017-05-17 14:28:06 -040063 f.write('\tbuilder = %s\n' % bot)
64
65
Eric Borencff9f952017-10-17 09:18:18 -040066def main():
67 parser = argparse.ArgumentParser()
68 parser.add_argument("--gitcookies")
69 parser.add_argument("--repo_name")
70 parser.add_argument("--tasks_json")
71 args = parser.parse_args()
72
73 skia_repo = SKIA_REPO_TEMPLATE % args.repo_name
Ravi Mistry01b48e72017-05-17 14:28:06 -040074 with git_utils.NewGitCheckout(repository=skia_repo):
75 # Fetch and checkout the meta/config branch.
76 subprocess.check_call(['git', 'fetch', skia_repo, 'refs/meta/config:cfg'])
77 subprocess.check_call(['git', 'checkout', 'cfg'])
78
79 # Create list of tryjobs from tasks_json.
80 tryjobs = []
Eric Borencff9f952017-10-17 09:18:18 -040081 with open(args.tasks_json) as tasks_json:
Ravi Mistry01b48e72017-05-17 14:28:06 -040082 data = json.load(tasks_json)
83 for job in data['jobs'].keys():
84 if not job.startswith('Upload-'):
85 tryjobs.append(job)
86 tryjobs.sort()
87
88 # Write to buildbucket.config.
89 buildbucket_config = os.path.join(os.getcwd(), 'buildbucket.config')
90 with open(buildbucket_config, 'w') as f:
91
Eric Borencff9f952017-10-17 09:18:18 -040092 if args.repo_name == 'skia':
Ravi Mistry01b48e72017-05-17 14:28:06 -040093 addChromiumTrybots(f)
94
95 # Adding all Skia jobs.
96 f.write('[bucket "skia.primary"]\n')
97 for job in tryjobs:
98 f.write('\tbuilder = ' + job + '\n')
99
100 # Push the change as the update-meta-config user.
101 config_dict = {
102 'user.name': SKIA_COMMITTER_NAME,
103 'user.email': SKIA_COMMITTER_EMAIL,
Eric Borencff9f952017-10-17 09:18:18 -0400104 'http.cookiefile': args.gitcookies,
Ravi Mistry01b48e72017-05-17 14:28:06 -0400105 }
106 with git_utils.GitLocalConfig(config_dict):
107 subprocess.check_call(['git', 'add', 'buildbucket.config'])
108 try:
109 subprocess.check_call(
110 ['git', 'commit', '-m', 'Update builders in buildbucket.config'])
111 except subprocess.CalledProcessError:
112 print 'No changes to buildbucket.config'
113 return
114
115 subprocess.check_call(['git', 'push', skia_repo, 'cfg:refs/meta/config'])
116
117
118if '__main__' == __name__:
Eric Borencff9f952017-10-17 09:18:18 -0400119 main()