Home | History | Annotate | Download | only in bots
      1 # Copyright 2018 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 
      6 """Create a CL to update the go_deps asset version."""
      7 
      8 
      9 import os
     10 import subprocess
     11 import sys
     12 
     13 import git_utils
     14 
     15 
     16 COMMIT_MSG = '''Update go_deps asset
     17 
     18 Automatic commit by the UpdateGoDEPS bot.
     19 
     20 TBR=borenet (at] google.com
     21 '''
     22 SKIA_REPO = 'https://skia.googlesource.com/skia.git'
     23 
     24 
     25 def main():
     26   with git_utils.NewGitCheckout(repository=SKIA_REPO):
     27     # First verify that there are no gen_tasks diffs.
     28     gen_tasks = os.path.join(os.getcwd(), 'infra', 'bots', 'gen_tasks.go')
     29     try:
     30       subprocess.check_call(['go', 'run', gen_tasks, '--test'])
     31     except subprocess.CalledProcessError as e:
     32       print >> sys.stderr, (
     33          'gen_tasks.go failed, not updating Go DEPS:\n\n%s' % e.output)
     34       sys.exit(1)
     35 
     36     # Upload the new version, land the update CL as the update-go-deps user.
     37     with git_utils.GitBranch(branch_name='update_go_deps_version',
     38                              commit_msg=COMMIT_MSG,
     39                              commit_queue=True):
     40       script = os.path.join(
     41           os.getcwd(), 'infra', 'bots', 'assets', 'go_deps',
     42           'create_and_upload.py')
     43       subprocess.check_call(['python', script])
     44       subprocess.check_call(['go', 'run', gen_tasks])
     45       subprocess.check_call([
     46           'git', 'add', os.path.join('infra', 'bots', 'tasks.json')])
     47 
     48 
     49 if '__main__' == __name__:
     50   main()
     51