2016-07-26 18:52:17 +00:00
|
|
|
# Copyright 2014 The Chromium Authors. All rights reserved.
|
|
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
|
|
# found in the LICENSE file.
|
|
|
|
|
|
|
|
"""Create a CL to update the SKP version."""
|
|
|
|
|
|
|
|
|
|
|
|
import argparse
|
|
|
|
import os
|
|
|
|
import subprocess
|
|
|
|
import sys
|
2016-11-23 13:38:18 +00:00
|
|
|
import urllib2
|
2016-07-26 18:52:17 +00:00
|
|
|
|
2016-11-17 13:13:51 +00:00
|
|
|
import git_utils
|
2016-07-26 18:52:17 +00:00
|
|
|
|
2018-04-23 12:35:45 +00:00
|
|
|
|
2016-07-26 18:52:17 +00:00
|
|
|
COMMIT_MSG = '''Update SKP version
|
|
|
|
|
|
|
|
Automatic commit by the RecreateSKPs bot.
|
|
|
|
|
2018-04-23 12:35:45 +00:00
|
|
|
TBR=rmistry@google.com
|
2016-07-26 18:52:17 +00:00
|
|
|
NO_MERGE_BUILDS
|
2018-04-23 12:35:45 +00:00
|
|
|
'''
|
2016-07-26 18:52:17 +00:00
|
|
|
SKIA_REPO = 'https://skia.googlesource.com/skia.git'
|
|
|
|
|
|
|
|
|
2018-04-23 12:35:45 +00:00
|
|
|
def main(target_dir):
|
2019-01-25 17:05:59 +00:00
|
|
|
# We're going to sync a new, clean Skia checkout to upload the CL to update
|
|
|
|
# the SKPs. However, we want to use the scripts from the current checkout,
|
|
|
|
# in order to facilitate running this as a try job.
|
|
|
|
infrabots_dir = os.path.dirname(os.path.realpath(__file__))
|
|
|
|
skp_dir = os.path.join(infrabots_dir, 'assets', 'skp')
|
|
|
|
upload_py = os.path.join(skp_dir, 'upload.py')
|
|
|
|
|
2016-12-06 13:14:12 +00:00
|
|
|
with git_utils.NewGitCheckout(repository=SKIA_REPO):
|
2016-11-23 13:38:18 +00:00
|
|
|
# First verify that there are no gen_tasks diffs.
|
2019-01-25 17:05:59 +00:00
|
|
|
tmp_infrabots_dir = os.path.join(os.getcwd(), 'infra', 'bots')
|
|
|
|
tmp_gen_tasks = os.path.join(tmp_infrabots_dir, 'gen_tasks.go')
|
2016-11-23 13:38:18 +00:00
|
|
|
try:
|
2019-01-25 17:05:59 +00:00
|
|
|
subprocess.check_call(['go', 'run', tmp_gen_tasks, '--test'])
|
2016-11-23 13:38:18 +00:00
|
|
|
except subprocess.CalledProcessError as e:
|
|
|
|
print >> sys.stderr, (
|
|
|
|
'gen_tasks.go failed, not uploading SKP update:\n\n%s' % e.output)
|
|
|
|
sys.exit(1)
|
2016-10-18 12:20:26 +00:00
|
|
|
|
2018-04-26 12:49:38 +00:00
|
|
|
# Upload the new version, land the update CL as the recreate-skps user.
|
2018-04-23 12:35:45 +00:00
|
|
|
with git_utils.GitBranch(branch_name='update_skp_version',
|
|
|
|
commit_msg=COMMIT_MSG,
|
|
|
|
commit_queue=True):
|
2019-01-25 17:05:59 +00:00
|
|
|
upload_cmd = ['python', upload_py, '-t', target_dir]
|
|
|
|
if args.chromium_path:
|
|
|
|
chromium_revision = subprocess.check_output(
|
|
|
|
['git', 'rev-parse', 'HEAD'], cwd=args.chromium_path).rstrip()
|
|
|
|
upload_cmd.extend([
|
|
|
|
'--extra_tags', 'chromium_revision:%s' % chromium_revision])
|
|
|
|
subprocess.check_call(upload_cmd)
|
|
|
|
# We used upload.py from the repo that this script lives in, NOT the temp
|
|
|
|
# repo we've created. Therefore, the VERSION file was written in that repo
|
|
|
|
# so we need to copy it to the temp repo in order to commit it.
|
|
|
|
src = os.path.join(skp_dir, 'VERSION')
|
|
|
|
dst = os.path.join(
|
|
|
|
os.getcwd(), 'infra', 'bots', 'assets', 'skp', 'VERSION')
|
|
|
|
subprocess.check_call(['cp', src, dst])
|
|
|
|
subprocess.check_call(['go', 'run', tmp_gen_tasks])
|
2018-04-23 12:35:45 +00:00
|
|
|
subprocess.check_call([
|
|
|
|
'git', 'add', os.path.join('infra', 'bots', 'tasks.json')])
|
2016-07-26 18:52:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
if '__main__' == __name__:
|
|
|
|
parser = argparse.ArgumentParser()
|
|
|
|
parser.add_argument("--target_dir")
|
2019-01-25 17:05:59 +00:00
|
|
|
parser.add_argument("--chromium_path")
|
2016-07-26 18:52:17 +00:00
|
|
|
args = parser.parse_args()
|
2018-04-23 12:35:45 +00:00
|
|
|
main(args.target_dir)
|