blob: a1833dfc0f0646da7307611898e30a745000d4b6 [file] [log] [blame]
borenet1ed2ae42016-07-26 11:52:17 -07001# 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
8import argparse
9import os
10import subprocess
11import sys
Ravi Mistrybadc1372016-11-23 08:38:18 -050012import urllib2
borenet1ed2ae42016-07-26 11:52:17 -070013
Ravi Mistrybd2d1112016-11-17 08:13:51 -050014import git_utils
borenet1ed2ae42016-07-26 11:52:17 -070015
Ravi Mistrybadc1372016-11-23 08:38:18 -050016SKIA_COMMITTER_EMAIL = 'update-skps@skia.org'
17SKIA_COMMITTER_NAME = 'UpdateSKPs'
borenet1ed2ae42016-07-26 11:52:17 -070018COMMIT_MSG = '''Update SKP version
19
20Automatic commit by the RecreateSKPs bot.
21
Ravi Mistrybadc1372016-11-23 08:38:18 -050022TBR=%s
borenet1ed2ae42016-07-26 11:52:17 -070023NO_MERGE_BUILDS
Ravi Mistrybadc1372016-11-23 08:38:18 -050024''' % SKIA_COMMITTER_EMAIL
borenet1ed2ae42016-07-26 11:52:17 -070025SKIA_REPO = 'https://skia.googlesource.com/skia.git'
26
27
Ravi Mistrybadc1372016-11-23 08:38:18 -050028def main(target_dir, gitcookies):
Ravi Mistrye7d34b12016-12-06 08:14:12 -050029 with git_utils.NewGitCheckout(repository=SKIA_REPO):
Ravi Mistrybadc1372016-11-23 08:38:18 -050030 # Download CIPD.
31 cipd_sha1 = os.path.join(os.getcwd(), 'infra', 'bots', 'tools', 'luci-go',
32 'linux64', 'cipd.sha1')
33 subprocess.check_call(['download_from_google_storage', '-s', cipd_sha1,
34 '--bucket', 'chromium-luci'])
borenet1ed2ae42016-07-26 11:52:17 -070035
Ravi Mistrybadc1372016-11-23 08:38:18 -050036 # First verify that there are no gen_tasks diffs.
37 gen_tasks = os.path.join(os.getcwd(), 'infra', 'bots', 'gen_tasks.go')
38 try:
39 subprocess.check_call(['go', 'run', gen_tasks, '--test'])
40 except subprocess.CalledProcessError as e:
41 print >> sys.stderr, (
42 'gen_tasks.go failed, not uploading SKP update:\n\n%s' % e.output)
43 sys.exit(1)
borenet8a91da92016-10-18 05:20:26 -070044
Ravi Mistrybadc1372016-11-23 08:38:18 -050045 # Skip GCE Auth in depot_tools/gerrit_utils.py. Use gitcookies instead.
46 os.environ['SKIP_GCE_AUTH_FOR_GIT'] = 'True'
47 os.environ['GIT_COOKIES_PATH'] = gitcookies
48 # Upload the new version, land the update CL as the update-skps user.
49 config_dict = {
50 'user.name': SKIA_COMMITTER_NAME,
51 'user.email': SKIA_COMMITTER_EMAIL,
52 'http.cookiefile': gitcookies,
53 }
54 with git_utils.GitLocalConfig(config_dict):
55 with git_utils.GitBranch(branch_name='update_skp_version',
56 commit_msg=COMMIT_MSG,
57 commit_queue=True):
58 upload_script = os.path.join(
59 os.getcwd(), 'infra', 'bots', 'assets', 'skp', 'upload.py')
60 subprocess.check_call(['python', upload_script, '-t', target_dir])
61 subprocess.check_call(['go', 'run', gen_tasks])
62 subprocess.check_call([
63 'git', 'add', os.path.join('infra', 'bots', 'tasks.json')])
borenet1ed2ae42016-07-26 11:52:17 -070064
65
66if '__main__' == __name__:
67 parser = argparse.ArgumentParser()
68 parser.add_argument("--target_dir")
Ravi Mistrybadc1372016-11-23 08:38:18 -050069 parser.add_argument("--gitcookies")
borenet1ed2ae42016-07-26 11:52:17 -070070 args = parser.parse_args()
Ravi Mistrybadc1372016-11-23 08:38:18 -050071 main(args.target_dir, args.gitcookies)