Ravi Mistry | 01b48e7 | 2017-05-17 14:28:06 -0400 | [diff] [blame] | 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@skia.org' |
| 19 | SKIA_COMMITTER_NAME = 'Update Meta Config' |
| 20 | SKIA_REPO_TEMPLATE = 'https://skia.googlesource.com/%s.git' |
| 21 | |
Hal Canary | 287a3fe | 2017-05-18 11:29:04 -0400 | [diff] [blame] | 22 | CQ_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 Canary | 287a3fe | 2017-05-18 11:29:04 -0400 | [diff] [blame] | 45 | 'win_optional_gpu_tests_rel', |
Ravi Mistry | 01f70aa | 2017-10-17 08:16:28 -0400 | [diff] [blame] | 46 | 'win7_chromium_rel_ng', |
| 47 | 'win10_chromium_x64_rel_ng', |
Hal Canary | 287a3fe | 2017-05-18 11:29:04 -0400 | [diff] [blame] | 48 | ]), |
| 49 | ('master.tryserver.chromium.android', [ |
| 50 | 'android_compile_dbg', |
| 51 | 'android_compile_rel', |
Ravi Mistry | 01f70aa | 2017-10-17 08:16:28 -0400 | [diff] [blame] | 52 | 'android_n5x_swarming_dbg', |
| 53 | 'android_n5x_swarming_rel', |
Hal Canary | 287a3fe | 2017-05-18 11:29:04 -0400 | [diff] [blame] | 54 | 'android_optional_gpu_tests_rel', |
| 55 | ]) |
| 56 | ] |
Ravi Mistry | 01b48e7 | 2017-05-17 14:28:06 -0400 | [diff] [blame] | 57 | |
| 58 | |
| 59 | def addChromiumTrybots(f): |
Hal Canary | 287a3fe | 2017-05-18 11:29:04 -0400 | [diff] [blame] | 60 | for master, bots in CQ_INCLUDE_CHROMIUM_TRYBOTS: |
Ravi Mistry | 01b48e7 | 2017-05-17 14:28:06 -0400 | [diff] [blame] | 61 | f.write('[bucket "%s"]\n' % master) |
Hal Canary | 287a3fe | 2017-05-18 11:29:04 -0400 | [diff] [blame] | 62 | for bot in bots: |
Ravi Mistry | 01b48e7 | 2017-05-17 14:28:06 -0400 | [diff] [blame] | 63 | f.write('\tbuilder = %s\n' % bot) |
| 64 | |
| 65 | |
Eric Boren | cff9f95 | 2017-10-17 09:18:18 -0400 | [diff] [blame] | 66 | def 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 Mistry | 01b48e7 | 2017-05-17 14:28:06 -0400 | [diff] [blame] | 74 | 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 Boren | cff9f95 | 2017-10-17 09:18:18 -0400 | [diff] [blame] | 81 | with open(args.tasks_json) as tasks_json: |
Ravi Mistry | 01b48e7 | 2017-05-17 14:28:06 -0400 | [diff] [blame] | 82 | 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 Boren | cff9f95 | 2017-10-17 09:18:18 -0400 | [diff] [blame] | 92 | if args.repo_name == 'skia': |
Ravi Mistry | 01b48e7 | 2017-05-17 14:28:06 -0400 | [diff] [blame] | 93 | 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 Boren | cff9f95 | 2017-10-17 09:18:18 -0400 | [diff] [blame] | 104 | 'http.cookiefile': args.gitcookies, |
Ravi Mistry | 01b48e7 | 2017-05-17 14:28:06 -0400 | [diff] [blame] | 105 | } |
| 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 | |
| 118 | if '__main__' == __name__: |
Eric Boren | cff9f95 | 2017-10-17 09:18:18 -0400 | [diff] [blame] | 119 | main() |