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', [ |
Hal Canary | 287a3fe | 2017-05-18 11:29:04 -0400 | [diff] [blame] | 24 | 'linux_trusty_blink_dbg', |
Mike Klein | fb4d3f0 | 2017-10-25 09:53:23 -0400 | [diff] [blame] | 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', |
Hal Canary | 287a3fe | 2017-05-18 11:29:04 -0400 | [diff] [blame] | 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', |
Hal Canary | 287a3fe | 2017-05-18 11:29:04 -0400 | [diff] [blame] | 51 | 'win_optional_gpu_tests_rel', |
Ravi Mistry | 01f70aa | 2017-10-17 08:16:28 -0400 | [diff] [blame] | 52 | 'win7_chromium_rel_ng', |
| 53 | 'win10_chromium_x64_rel_ng', |
Hal Canary | 287a3fe | 2017-05-18 11:29:04 -0400 | [diff] [blame] | 54 | ]), |
| 55 | ('master.tryserver.chromium.android', [ |
Mike Klein | f8e353d | 2017-10-25 12:06:09 -0400 | [diff] [blame^] | 56 | 'android_blink_rel', |
Hal Canary | 287a3fe | 2017-05-18 11:29:04 -0400 | [diff] [blame] | 57 | 'android_compile_dbg', |
| 58 | 'android_compile_rel', |
Ravi Mistry | 01f70aa | 2017-10-17 08:16:28 -0400 | [diff] [blame] | 59 | 'android_n5x_swarming_dbg', |
| 60 | 'android_n5x_swarming_rel', |
Hal Canary | 287a3fe | 2017-05-18 11:29:04 -0400 | [diff] [blame] | 61 | 'android_optional_gpu_tests_rel', |
| 62 | ]) |
| 63 | ] |
Ravi Mistry | 01b48e7 | 2017-05-17 14:28:06 -0400 | [diff] [blame] | 64 | |
| 65 | |
| 66 | def addChromiumTrybots(f): |
Hal Canary | 287a3fe | 2017-05-18 11:29:04 -0400 | [diff] [blame] | 67 | for master, bots in CQ_INCLUDE_CHROMIUM_TRYBOTS: |
Ravi Mistry | 01b48e7 | 2017-05-17 14:28:06 -0400 | [diff] [blame] | 68 | f.write('[bucket "%s"]\n' % master) |
Hal Canary | 287a3fe | 2017-05-18 11:29:04 -0400 | [diff] [blame] | 69 | for bot in bots: |
Ravi Mistry | 01b48e7 | 2017-05-17 14:28:06 -0400 | [diff] [blame] | 70 | f.write('\tbuilder = %s\n' % bot) |
| 71 | |
| 72 | |
Eric Boren | cff9f95 | 2017-10-17 09:18:18 -0400 | [diff] [blame] | 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 |
Ravi Mistry | 01b48e7 | 2017-05-17 14:28:06 -0400 | [diff] [blame] | 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 = [] |
Eric Boren | cff9f95 | 2017-10-17 09:18:18 -0400 | [diff] [blame] | 88 | with open(args.tasks_json) as tasks_json: |
Ravi Mistry | 01b48e7 | 2017-05-17 14:28:06 -0400 | [diff] [blame] | 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 | |
Eric Boren | cff9f95 | 2017-10-17 09:18:18 -0400 | [diff] [blame] | 99 | if args.repo_name == 'skia': |
Ravi Mistry | 01b48e7 | 2017-05-17 14:28:06 -0400 | [diff] [blame] | 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, |
Eric Boren | cff9f95 | 2017-10-17 09:18:18 -0400 | [diff] [blame] | 111 | 'http.cookiefile': args.gitcookies, |
Ravi Mistry | 01b48e7 | 2017-05-17 14:28:06 -0400 | [diff] [blame] | 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__: |
Eric Boren | cff9f95 | 2017-10-17 09:18:18 -0400 | [diff] [blame] | 126 | main() |