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 8 import argparse 9 import json 10 import os 11 import subprocess 12 import sys 13 import urllib2 14 15 import git_utils 16 17 18 SKIA_COMMITTER_EMAIL = 'update-meta-config (at] skia.org' 19 SKIA_COMMITTER_NAME = 'Update Meta Config' 20 SKIA_REPO_TEMPLATE = 'https://skia.googlesource.com/%s.git' 21 22 CQ_INCLUDE_CHROMIUM_TRYBOTS = [ 23 ('master.tryserver.blink', [ 24 'linux_trusty_blink_dbg', 25 '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', 32 ]), 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', 51 'win_optional_gpu_tests_rel', 52 'win7_chromium_rel_ng', 53 'win10_chromium_x64_rel_ng', 54 ]), 55 ('master.tryserver.chromium.android', [ 56 'android_blink_rel', 57 'android_compile_dbg', 58 'android_compile_rel', 59 'android_n5x_swarming_dbg', 60 'android_n5x_swarming_rel', 61 'android_optional_gpu_tests_rel', 62 ]) 63 ] 64 65 66 def addChromiumTrybots(f): 67 for master, bots in CQ_INCLUDE_CHROMIUM_TRYBOTS: 68 f.write('[bucket "%s"]\n' % master) 69 for bot in bots: 70 f.write('\tbuilder = %s\n' % bot) 71 72 73 def 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 81 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 = [] 88 with open(args.tasks_json) as tasks_json: 89 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 99 if args.repo_name == 'skia': 100 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, 111 'http.cookiefile': args.gitcookies, 112 } 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 125 if '__main__' == __name__: 126 main() 127