blob: ba472d2ff671b4bca8a28eddf71825abe0c80111 [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
Eric Boren78179312018-04-23 08:35:45 -040016
borenet1ed2ae42016-07-26 11:52:17 -070017COMMIT_MSG = '''Update SKP version
18
19Automatic commit by the RecreateSKPs bot.
20
Eric Boren78179312018-04-23 08:35:45 -040021TBR=rmistry@google.com
borenet1ed2ae42016-07-26 11:52:17 -070022NO_MERGE_BUILDS
Eric Boren78179312018-04-23 08:35:45 -040023'''
borenet1ed2ae42016-07-26 11:52:17 -070024SKIA_REPO = 'https://skia.googlesource.com/skia.git'
25
26
Eric Boren78179312018-04-23 08:35:45 -040027def main(target_dir):
Ravi Mistrye7d34b12016-12-06 08:14:12 -050028 with git_utils.NewGitCheckout(repository=SKIA_REPO):
Ravi Mistrybadc1372016-11-23 08:38:18 -050029 # First verify that there are no gen_tasks diffs.
30 gen_tasks = os.path.join(os.getcwd(), 'infra', 'bots', 'gen_tasks.go')
31 try:
32 subprocess.check_call(['go', 'run', gen_tasks, '--test'])
33 except subprocess.CalledProcessError as e:
34 print >> sys.stderr, (
35 'gen_tasks.go failed, not uploading SKP update:\n\n%s' % e.output)
36 sys.exit(1)
borenet8a91da92016-10-18 05:20:26 -070037
Eric Borene7950e32018-04-26 08:49:38 -040038 # Upload the new version, land the update CL as the recreate-skps user.
Eric Boren78179312018-04-23 08:35:45 -040039 with git_utils.GitBranch(branch_name='update_skp_version',
40 commit_msg=COMMIT_MSG,
41 commit_queue=True):
42 upload_script = os.path.join(
43 os.getcwd(), 'infra', 'bots', 'assets', 'skp', 'upload.py')
44 subprocess.check_call(['python', upload_script, '-t', target_dir])
45 subprocess.check_call(['go', 'run', gen_tasks])
46 subprocess.check_call([
47 'git', 'add', os.path.join('infra', 'bots', 'tasks.json')])
borenet1ed2ae42016-07-26 11:52:17 -070048
49
50if '__main__' == __name__:
51 parser = argparse.ArgumentParser()
52 parser.add_argument("--target_dir")
53 args = parser.parse_args()
Eric Boren78179312018-04-23 08:35:45 -040054 main(args.target_dir)