blob: 7d0b0798ef99565724a25a4216f935fc0dc88f3d [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
Ravi Mistrybd2d1112016-11-17 08:13:51 -050013import git_utils
borenet1ed2ae42016-07-26 11:52:17 -070014
15
16CHROMIUM_SKIA = 'https://chromium.googlesource.com/skia.git'
17COMMIT_MSG = '''Update SKP version
18
19Automatic commit by the RecreateSKPs bot.
20
21TBR=
22NO_MERGE_BUILDS
23'''
24SKIA_COMMITTER_EMAIL = 'skia.buildbots@gmail.com'
25SKIA_COMMITTER_NAME = 'skia.buildbots'
26SKIA_REPO = 'https://skia.googlesource.com/skia.git'
27
28
29def main(target_dir):
30 subprocess.check_call(['git', 'config', '--local', 'user.name',
31 SKIA_COMMITTER_NAME])
32 subprocess.check_call(['git', 'config', '--local', 'user.email',
33 SKIA_COMMITTER_EMAIL])
34 if CHROMIUM_SKIA in subprocess.check_output(['git', 'remote', '-v']):
35 subprocess.check_call(['git', 'remote', 'set-url', 'origin', SKIA_REPO,
36 CHROMIUM_SKIA])
37
38 # Download CIPD.
39 cipd_sha1 = os.path.join(os.getcwd(), 'infra', 'bots', 'tools', 'luci-go',
40 'linux64', 'cipd.sha1')
41 subprocess.check_call(['download_from_google_storage', '-s', cipd_sha1,
42 '--bucket', 'chromium-luci'])
43
borenet8a91da92016-10-18 05:20:26 -070044 # First verify that there are no gen_tasks diffs.
45 gen_tasks = os.path.join(os.getcwd(), 'infra', 'bots', 'gen_tasks.go')
46 try:
47 subprocess.check_call(['go', 'run', gen_tasks, '--test'])
48 except subprocess.CalledProcessError as e:
49 print >> sys.stderr, ('gen_tasks.go failed, not uploading SKP update:\n\n%s'
50 % e.output)
51 sys.exit(1)
52
53 # Upload the new version, land the update CL.
borenet1ed2ae42016-07-26 11:52:17 -070054 with git_utils.GitBranch(branch_name='update_skp_version',
55 commit_msg=COMMIT_MSG,
56 commit_queue=True):
57 upload_script = os.path.join(
58 os.getcwd(), 'infra', 'bots', 'assets', 'skp', 'upload.py')
59 subprocess.check_call(['python', upload_script, '-t', target_dir])
borenet8a91da92016-10-18 05:20:26 -070060 subprocess.check_call(['go', 'run', gen_tasks])
61 subprocess.check_call([
62 'git', 'add', os.path.join('infra', 'bots', 'tasks.json')])
borenet1ed2ae42016-07-26 11:52:17 -070063
64
65if '__main__' == __name__:
66 parser = argparse.ArgumentParser()
67 parser.add_argument("--target_dir")
68 args = parser.parse_args()
69 main(args.target_dir)