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 |
| 12 | |
Ravi Mistry | bd2d111 | 2016-11-17 08:13:51 -0500 | [diff] [blame^] | 13 | import git_utils |
borenet | 1ed2ae4 | 2016-07-26 11:52:17 -0700 | [diff] [blame] | 14 | |
| 15 | |
| 16 | CHROMIUM_SKIA = 'https://chromium.googlesource.com/skia.git' |
| 17 | COMMIT_MSG = '''Update SKP version |
| 18 | |
| 19 | Automatic commit by the RecreateSKPs bot. |
| 20 | |
| 21 | TBR= |
| 22 | NO_MERGE_BUILDS |
| 23 | ''' |
| 24 | SKIA_COMMITTER_EMAIL = 'skia.buildbots@gmail.com' |
| 25 | SKIA_COMMITTER_NAME = 'skia.buildbots' |
| 26 | SKIA_REPO = 'https://skia.googlesource.com/skia.git' |
| 27 | |
| 28 | |
| 29 | def main(target_dir): |
| 30 | subprocess.check_call(['git', 'config', '--local', 'user.name', |
| 31 | SKIA_COMMITTER_NAME]) |
| 32 | subprocess.check_call(['git', 'config', '--local', 'user.email', |
| 33 | SKIA_COMMITTER_EMAIL]) |
| 34 | if CHROMIUM_SKIA in subprocess.check_output(['git', 'remote', '-v']): |
| 35 | subprocess.check_call(['git', 'remote', 'set-url', 'origin', SKIA_REPO, |
| 36 | CHROMIUM_SKIA]) |
| 37 | |
| 38 | # Download CIPD. |
| 39 | cipd_sha1 = os.path.join(os.getcwd(), 'infra', 'bots', 'tools', 'luci-go', |
| 40 | 'linux64', 'cipd.sha1') |
| 41 | subprocess.check_call(['download_from_google_storage', '-s', cipd_sha1, |
| 42 | '--bucket', 'chromium-luci']) |
| 43 | |
borenet | 8a91da9 | 2016-10-18 05:20:26 -0700 | [diff] [blame] | 44 | # First verify that there are no gen_tasks diffs. |
| 45 | gen_tasks = os.path.join(os.getcwd(), 'infra', 'bots', 'gen_tasks.go') |
| 46 | try: |
| 47 | subprocess.check_call(['go', 'run', gen_tasks, '--test']) |
| 48 | except subprocess.CalledProcessError as e: |
| 49 | print >> sys.stderr, ('gen_tasks.go failed, not uploading SKP update:\n\n%s' |
| 50 | % e.output) |
| 51 | sys.exit(1) |
| 52 | |
| 53 | # Upload the new version, land the update CL. |
borenet | 1ed2ae4 | 2016-07-26 11:52:17 -0700 | [diff] [blame] | 54 | with git_utils.GitBranch(branch_name='update_skp_version', |
| 55 | commit_msg=COMMIT_MSG, |
| 56 | commit_queue=True): |
| 57 | upload_script = os.path.join( |
| 58 | os.getcwd(), 'infra', 'bots', 'assets', 'skp', 'upload.py') |
| 59 | subprocess.check_call(['python', upload_script, '-t', target_dir]) |
borenet | 8a91da9 | 2016-10-18 05:20:26 -0700 | [diff] [blame] | 60 | subprocess.check_call(['go', 'run', gen_tasks]) |
| 61 | subprocess.check_call([ |
| 62 | 'git', 'add', os.path.join('infra', 'bots', 'tasks.json')]) |
borenet | 1ed2ae4 | 2016-07-26 11:52:17 -0700 | [diff] [blame] | 63 | |
| 64 | |
| 65 | if '__main__' == __name__: |
| 66 | parser = argparse.ArgumentParser() |
| 67 | parser.add_argument("--target_dir") |
| 68 | args = parser.parse_args() |
| 69 | main(args.target_dir) |