borenet | 1ed2ae4 | 2016-07-26 11:52:17 -0700 | [diff] [blame] | 1 | # Copyright 2014 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 | """Create a CL to update the SKP version.""" |
| 6 | |
| 7 | |
| 8 | import argparse |
| 9 | import os |
| 10 | import subprocess |
| 11 | import sys |
Ravi Mistry | badc137 | 2016-11-23 08:38:18 -0500 | [diff] [blame] | 12 | import urllib2 |
borenet | 1ed2ae4 | 2016-07-26 11:52:17 -0700 | [diff] [blame] | 13 | |
Ravi Mistry | bd2d111 | 2016-11-17 08:13:51 -0500 | [diff] [blame] | 14 | import git_utils |
borenet | 1ed2ae4 | 2016-07-26 11:52:17 -0700 | [diff] [blame] | 15 | |
Eric Boren | 7817931 | 2018-04-23 08:35:45 -0400 | [diff] [blame] | 16 | |
borenet | 1ed2ae4 | 2016-07-26 11:52:17 -0700 | [diff] [blame] | 17 | COMMIT_MSG = '''Update SKP version |
| 18 | |
| 19 | Automatic commit by the RecreateSKPs bot. |
| 20 | |
Eric Boren | 7817931 | 2018-04-23 08:35:45 -0400 | [diff] [blame] | 21 | TBR=rmistry@google.com |
borenet | 1ed2ae4 | 2016-07-26 11:52:17 -0700 | [diff] [blame] | 22 | NO_MERGE_BUILDS |
Eric Boren | 7817931 | 2018-04-23 08:35:45 -0400 | [diff] [blame] | 23 | ''' |
borenet | 1ed2ae4 | 2016-07-26 11:52:17 -0700 | [diff] [blame] | 24 | SKIA_REPO = 'https://skia.googlesource.com/skia.git' |
| 25 | |
| 26 | |
Eric Boren | 7817931 | 2018-04-23 08:35:45 -0400 | [diff] [blame] | 27 | def main(target_dir): |
Ravi Mistry | e7d34b1 | 2016-12-06 08:14:12 -0500 | [diff] [blame] | 28 | with git_utils.NewGitCheckout(repository=SKIA_REPO): |
Ravi Mistry | badc137 | 2016-11-23 08:38:18 -0500 | [diff] [blame] | 29 | # First verify that there are no gen_tasks diffs. |
| 30 | gen_tasks = os.path.join(os.getcwd(), 'infra', 'bots', 'gen_tasks.go') |
| 31 | try: |
| 32 | subprocess.check_call(['go', 'run', gen_tasks, '--test']) |
| 33 | except subprocess.CalledProcessError as e: |
| 34 | print >> sys.stderr, ( |
| 35 | 'gen_tasks.go failed, not uploading SKP update:\n\n%s' % e.output) |
| 36 | sys.exit(1) |
borenet | 8a91da9 | 2016-10-18 05:20:26 -0700 | [diff] [blame] | 37 | |
Eric Boren | e7950e3 | 2018-04-26 08:49:38 -0400 | [diff] [blame] | 38 | # Upload the new version, land the update CL as the recreate-skps user. |
Eric Boren | 7817931 | 2018-04-23 08:35:45 -0400 | [diff] [blame] | 39 | with git_utils.GitBranch(branch_name='update_skp_version', |
| 40 | commit_msg=COMMIT_MSG, |
| 41 | commit_queue=True): |
| 42 | upload_script = os.path.join( |
| 43 | os.getcwd(), 'infra', 'bots', 'assets', 'skp', 'upload.py') |
| 44 | subprocess.check_call(['python', upload_script, '-t', target_dir]) |
| 45 | subprocess.check_call(['go', 'run', gen_tasks]) |
| 46 | subprocess.check_call([ |
| 47 | 'git', 'add', os.path.join('infra', 'bots', 'tasks.json')]) |
borenet | 1ed2ae4 | 2016-07-26 11:52:17 -0700 | [diff] [blame] | 48 | |
| 49 | |
| 50 | if '__main__' == __name__: |
| 51 | parser = argparse.ArgumentParser() |
| 52 | parser.add_argument("--target_dir") |
| 53 | args = parser.parse_args() |
Eric Boren | 7817931 | 2018-04-23 08:35:45 -0400 | [diff] [blame] | 54 | main(args.target_dir) |