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
|
|
|
|
2016-11-23 13:38:18 +00:00
|
|
|
SKIA_COMMITTER_EMAIL = 'update-skps@skia.org'
|
|
|
|
SKIA_COMMITTER_NAME = 'UpdateSKPs'
|
2016-07-26 18:52:17 +00:00
|
|
|
COMMIT_MSG = '''Update SKP version
|
|
|
|
|
|
|
|
Automatic commit by the RecreateSKPs bot.
|
|
|
|
|
2016-11-23 13:38:18 +00:00
|
|
|
TBR=%s
|
2016-07-26 18:52:17 +00:00
|
|
|
NO_MERGE_BUILDS
|
2016-11-23 13:38:18 +00:00
|
|
|
''' % SKIA_COMMITTER_EMAIL
|
2016-07-26 18:52:17 +00:00
|
|
|
SKIA_REPO = 'https://skia.googlesource.com/skia.git'
|
|
|
|
|
|
|
|
|
2016-11-23 13:38:18 +00:00
|
|
|
def main(target_dir, gitcookies):
|
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.
|
|
|
|
gen_tasks = os.path.join(os.getcwd(), 'infra', 'bots', 'gen_tasks.go')
|
|
|
|
try:
|
|
|
|
subprocess.check_call(['go', 'run', gen_tasks, '--test'])
|
|
|
|
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
|
|
|
|
2016-11-23 13:38:18 +00:00
|
|
|
# Skip GCE Auth in depot_tools/gerrit_utils.py. Use gitcookies instead.
|
|
|
|
os.environ['SKIP_GCE_AUTH_FOR_GIT'] = 'True'
|
|
|
|
os.environ['GIT_COOKIES_PATH'] = gitcookies
|
2017-03-20 14:43:26 +00:00
|
|
|
os.environ['USE_CIPD_GCE_AUTH'] = 'True'
|
2016-11-23 13:38:18 +00:00
|
|
|
# Upload the new version, land the update CL as the update-skps user.
|
|
|
|
config_dict = {
|
|
|
|
'user.name': SKIA_COMMITTER_NAME,
|
|
|
|
'user.email': SKIA_COMMITTER_EMAIL,
|
|
|
|
'http.cookiefile': gitcookies,
|
|
|
|
}
|
|
|
|
with git_utils.GitLocalConfig(config_dict):
|
|
|
|
with git_utils.GitBranch(branch_name='update_skp_version',
|
|
|
|
commit_msg=COMMIT_MSG,
|
|
|
|
commit_queue=True):
|
|
|
|
upload_script = os.path.join(
|
|
|
|
os.getcwd(), 'infra', 'bots', 'assets', 'skp', 'upload.py')
|
|
|
|
subprocess.check_call(['python', upload_script, '-t', target_dir])
|
|
|
|
subprocess.check_call(['go', 'run', gen_tasks])
|
|
|
|
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")
|
2016-11-23 13:38:18 +00:00
|
|
|
parser.add_argument("--gitcookies")
|
2016-07-26 18:52:17 +00:00
|
|
|
args = parser.parse_args()
|
2016-11-23 13:38:18 +00:00
|
|
|
main(args.target_dir, args.gitcookies)
|