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 | |
Ravi Mistry | 01b48e7 | 2017-05-17 14:28:06 -0400 | [diff] [blame] | 18 | SKIA_REPO_TEMPLATE = 'https://skia.googlesource.com/%s.git' |
| 19 | |
Hal Canary | 287a3fe | 2017-05-18 11:29:04 -0400 | [diff] [blame] | 20 | CQ_INCLUDE_CHROMIUM_TRYBOTS = [ |
Eric Boren | 464846e | 2018-03-15 13:34:23 -0400 | [diff] [blame] | 21 | ('luci.chromium.try', [ |
Yuly Novikov | 73bd3db | 2018-03-21 16:21:49 -0400 | [diff] [blame] | 22 | 'android_optional_gpu_tests_rel', |
Eric Boren | a2e613c | 2018-11-26 10:35:18 -0500 | [diff] [blame] | 23 | 'linux-blink-rel', |
Ravi Mistry | a19381d | 2018-04-16 14:07:21 -0400 | [diff] [blame] | 24 | 'linux_chromium_compile_dbg_ng', |
| 25 | 'linux_chromium_dbg_ng', |
| 26 | 'linux_chromium_rel_ng', |
Eric Boren | 464846e | 2018-03-15 13:34:23 -0400 | [diff] [blame] | 27 | 'linux_optional_gpu_tests_rel', |
Eric Boren | a2e613c | 2018-11-26 10:35:18 -0500 | [diff] [blame] | 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', |
Eric Boren | e8faee7 | 2018-03-21 16:23:25 -0400 | [diff] [blame] | 33 | 'mac_chromium_compile_dbg_ng', |
Ravi Mistry | a19381d | 2018-04-16 14:07:21 -0400 | [diff] [blame] | 34 | 'mac_chromium_compile_rel_ng', |
| 35 | 'mac_chromium_dbg_ng', |
| 36 | 'mac_chromium_rel_ng', |
Corentin Wallez | 578a8f1 | 2018-03-20 13:42:43 -0400 | [diff] [blame] | 37 | 'mac_optional_gpu_tests_rel', |
Eric Boren | a2e613c | 2018-11-26 10:35:18 -0500 | [diff] [blame] | 38 | 'win10-blink-rel', |
| 39 | 'win7-blink-rel', |
Ravi Mistry | a19381d | 2018-04-16 14:07:21 -0400 | [diff] [blame] | 40 | 'win_chromium_compile_dbg_ng', |
| 41 | 'win_chromium_dbg_ng', |
Corentin Wallez | a591428 | 2018-04-11 15:45:39 -0400 | [diff] [blame] | 42 | 'win_optional_gpu_tests_rel', |
Eric Boren | 464846e | 2018-03-15 13:34:23 -0400 | [diff] [blame] | 43 | ]), |
Hal Canary | 287a3fe | 2017-05-18 11:29:04 -0400 | [diff] [blame] | 44 | ('master.tryserver.chromium.linux', [ |
Hal Canary | 287a3fe | 2017-05-18 11:29:04 -0400 | [diff] [blame] | 45 | 'linux_chromium_compile_rel_ng', |
Hal Canary | 287a3fe | 2017-05-18 11:29:04 -0400 | [diff] [blame] | 46 | ]), |
| 47 | ('master.tryserver.chromium.win', [ |
Hal Canary | 287a3fe | 2017-05-18 11:29:04 -0400 | [diff] [blame] | 48 | 'win_chromium_compile_rel_ng', |
Ravi Mistry | 01f70aa | 2017-10-17 08:16:28 -0400 | [diff] [blame] | 49 | 'win7_chromium_rel_ng', |
| 50 | 'win10_chromium_x64_rel_ng', |
Hal Canary | 287a3fe | 2017-05-18 11:29:04 -0400 | [diff] [blame] | 51 | ]), |
| 52 | ('master.tryserver.chromium.android', [ |
Mike Klein | f8e353d | 2017-10-25 12:06:09 -0400 | [diff] [blame] | 53 | 'android_blink_rel', |
Hal Canary | 287a3fe | 2017-05-18 11:29:04 -0400 | [diff] [blame] | 54 | 'android_compile_dbg', |
| 55 | 'android_compile_rel', |
Ravi Mistry | 01f70aa | 2017-10-17 08:16:28 -0400 | [diff] [blame] | 56 | 'android_n5x_swarming_dbg', |
| 57 | 'android_n5x_swarming_rel', |
Hal Canary | 287a3fe | 2017-05-18 11:29:04 -0400 | [diff] [blame] | 58 | ]) |
| 59 | ] |
Ravi Mistry | 01b48e7 | 2017-05-17 14:28:06 -0400 | [diff] [blame] | 60 | |
| 61 | |
| 62 | def addChromiumTrybots(f): |
Hal Canary | 287a3fe | 2017-05-18 11:29:04 -0400 | [diff] [blame] | 63 | for master, bots in CQ_INCLUDE_CHROMIUM_TRYBOTS: |
Ravi Mistry | 01b48e7 | 2017-05-17 14:28:06 -0400 | [diff] [blame] | 64 | f.write('[bucket "%s"]\n' % master) |
Hal Canary | 287a3fe | 2017-05-18 11:29:04 -0400 | [diff] [blame] | 65 | for bot in bots: |
Ravi Mistry | 01b48e7 | 2017-05-17 14:28:06 -0400 | [diff] [blame] | 66 | f.write('\tbuilder = %s\n' % bot) |
| 67 | |
| 68 | |
Eric Boren | cff9f95 | 2017-10-17 09:18:18 -0400 | [diff] [blame] | 69 | def main(): |
| 70 | parser = argparse.ArgumentParser() |
Eric Boren | cff9f95 | 2017-10-17 09:18:18 -0400 | [diff] [blame] | 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 |
Ravi Mistry | 01b48e7 | 2017-05-17 14:28:06 -0400 | [diff] [blame] | 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 = [] |
Eric Boren | cff9f95 | 2017-10-17 09:18:18 -0400 | [diff] [blame] | 83 | with open(args.tasks_json) as tasks_json: |
Ravi Mistry | 01b48e7 | 2017-05-17 14:28:06 -0400 | [diff] [blame] | 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 | |
Eric Boren | cff9f95 | 2017-10-17 09:18:18 -0400 | [diff] [blame] | 94 | if args.repo_name == 'skia': |
Ravi Mistry | 01b48e7 | 2017-05-17 14:28:06 -0400 | [diff] [blame] | 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 | |
Eric Boren | 32f8478 | 2018-04-23 08:20:57 -0400 | [diff] [blame] | 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 |
Ravi Mistry | 01b48e7 | 2017-05-17 14:28:06 -0400 | [diff] [blame] | 109 | |
Eric Boren | 32f8478 | 2018-04-23 08:20:57 -0400 | [diff] [blame] | 110 | subprocess.check_call(['git', 'push', skia_repo, 'cfg:refs/meta/config']) |
Ravi Mistry | 01b48e7 | 2017-05-17 14:28:06 -0400 | [diff] [blame] | 111 | |
| 112 | |
| 113 | if '__main__' == __name__: |
Eric Boren | cff9f95 | 2017-10-17 09:18:18 -0400 | [diff] [blame] | 114 | main() |