• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# 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
12import urllib2
13
14import git_utils
15
16SKIA_COMMITTER_EMAIL = 'update-skps@skia.org'
17SKIA_COMMITTER_NAME = 'UpdateSKPs'
18COMMIT_MSG = '''Update SKP version
19
20Automatic commit by the RecreateSKPs bot.
21
22TBR=%s
23NO_MERGE_BUILDS
24''' % SKIA_COMMITTER_EMAIL
25SKIA_REPO = 'https://skia.googlesource.com/skia.git'
26
27
28def main(target_dir, gitcookies):
29  with git_utils.NewGitCheckout(repository=SKIA_REPO):
30    # First verify that there are no gen_tasks diffs.
31    gen_tasks = os.path.join(os.getcwd(), 'infra', 'bots', 'gen_tasks.go')
32    try:
33      subprocess.check_call(['go', 'run', gen_tasks, '--test'])
34    except subprocess.CalledProcessError as e:
35      print >> sys.stderr, (
36         'gen_tasks.go failed, not uploading SKP update:\n\n%s' % e.output)
37      sys.exit(1)
38
39    # Skip GCE Auth in depot_tools/gerrit_utils.py. Use gitcookies instead.
40    os.environ['SKIP_GCE_AUTH_FOR_GIT'] = 'True'
41    os.environ['GIT_COOKIES_PATH'] = gitcookies
42    os.environ['USE_CIPD_GCE_AUTH'] = 'True'
43    # Upload the new version, land the update CL as the update-skps user.
44    config_dict = {
45      'user.name': SKIA_COMMITTER_NAME,
46      'user.email': SKIA_COMMITTER_EMAIL,
47      'http.cookiefile': gitcookies,
48    }
49    with git_utils.GitLocalConfig(config_dict):
50      with git_utils.GitBranch(branch_name='update_skp_version',
51                               commit_msg=COMMIT_MSG,
52                               commit_queue=True):
53        upload_script = os.path.join(
54            os.getcwd(), 'infra', 'bots', 'assets', 'skp', 'upload.py')
55        subprocess.check_call(['python', upload_script, '-t', target_dir])
56        subprocess.check_call(['go', 'run', gen_tasks])
57        subprocess.check_call([
58            'git', 'add', os.path.join('infra', 'bots', 'tasks.json')])
59
60
61if '__main__' == __name__:
62  parser = argparse.ArgumentParser()
63  parser.add_argument("--target_dir")
64  parser.add_argument("--gitcookies")
65  args = parser.parse_args()
66  main(args.target_dir, args.gitcookies)
67