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