blob: 2193f343fc420175a17cb14360f7a8b726d208ab [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
12
13sys.path.insert(0, os.path.join(os.getcwd(), 'common'))
14# pylint:disable=F0401
15from py.utils import git_utils
16
17
18
19CHROMIUM_SKIA = 'https://chromium.googlesource.com/skia.git'
20COMMIT_MSG = '''Update SKP version
21
22Automatic commit by the RecreateSKPs bot.
23
24TBR=
25NO_MERGE_BUILDS
26'''
27SKIA_COMMITTER_EMAIL = 'skia.buildbots@gmail.com'
28SKIA_COMMITTER_NAME = 'skia.buildbots'
29SKIA_REPO = 'https://skia.googlesource.com/skia.git'
30
31
32def 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
borenet8a91da92016-10-18 05:20:26 -070047 # 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.
borenet1ed2ae42016-07-26 11:52:17 -070057 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])
borenet8a91da92016-10-18 05:20:26 -070063 subprocess.check_call(['go', 'run', gen_tasks])
64 subprocess.check_call([
65 'git', 'add', os.path.join('infra', 'bots', 'tasks.json')])
borenet1ed2ae42016-07-26 11:52:17 -070066
67
68if '__main__' == __name__:
69 parser = argparse.ArgumentParser()
70 parser.add_argument("--target_dir")
71 args = parser.parse_args()
72 main(args.target_dir)