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