• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# 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_REPO_TEMPLATE = 'https://skia.googlesource.com/%s.git'
19
20CQ_INCLUDE_CHROMIUM_TRYBOTS = [
21    ('luci.chromium.try', [
22        'android_optional_gpu_tests_rel',
23        'linux-blink-rel',
24        'linux_chromium_compile_dbg_ng',
25        'linux_chromium_dbg_ng',
26        'linux_chromium_rel_ng',
27        'linux_optional_gpu_tests_rel',
28        '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',
33        'mac_chromium_compile_dbg_ng',
34        'mac_chromium_compile_rel_ng',
35        'mac_chromium_dbg_ng',
36        'mac_chromium_rel_ng',
37        'mac_optional_gpu_tests_rel',
38        'win10-blink-rel',
39        'win7-blink-rel',
40        'win_chromium_compile_dbg_ng',
41        'win_chromium_dbg_ng',
42        'win_optional_gpu_tests_rel',
43    ]),
44    ('master.tryserver.chromium.linux', [
45        'linux_chromium_compile_rel_ng',
46    ]),
47    ('master.tryserver.chromium.win', [
48        'win_chromium_compile_rel_ng',
49        'win7_chromium_rel_ng',
50        'win10_chromium_x64_rel_ng',
51    ]),
52    ('master.tryserver.chromium.android', [
53        'android_blink_rel',
54        'android_compile_dbg',
55        'android_compile_rel',
56        'android_n5x_swarming_dbg',
57        'android_n5x_swarming_rel',
58    ])
59]
60
61
62def addChromiumTrybots(f):
63  for master, bots in CQ_INCLUDE_CHROMIUM_TRYBOTS:
64    f.write('[bucket "%s"]\n' % master)
65    for bot in bots:
66      f.write('\tbuilder = %s\n' % bot)
67
68
69def main():
70  parser = argparse.ArgumentParser()
71  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
76  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 = []
83    with open(args.tasks_json) as tasks_json:
84      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
94      if args.repo_name == 'skia':
95        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
102    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
109
110    subprocess.check_call(['git', 'push', skia_repo, 'cfg:refs/meta/config'])
111
112
113if '__main__' == __name__:
114  main()
115