Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(215)

Side by Side Diff: recipes/recipe_modules/recipe_autoroller/api.py

Issue 2242653003: recipe_autoroller: ensure the trivial roll CLs always have CQ bit set (attempt #3) (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | recipes/recipes/recipe_autoroller.expected/previously_uploaded_match.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2016 The Chromium Authors. All rights reserved. 1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import hashlib 5 import hashlib
6 import json 6 import json
7 import re 7 import re
8 8
9 from recipe_engine import recipe_api 9 from recipe_engine import recipe_api
10 10
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 82
83 83
84 # These are different results of a roll attempt: 84 # These are different results of a roll attempt:
85 # - success means we have a working non-empty roll 85 # - success means we have a working non-empty roll
86 # - empty means the repo is using latest revision of its dependencies 86 # - empty means the repo is using latest revision of its dependencies
87 # - failure means there are roll candidates but none of them are suitable 87 # - failure means there are roll candidates but none of them are suitable
88 # for an automated roll 88 # for an automated roll
89 ROLL_SUCCESS, ROLL_EMPTY, ROLL_FAILURE = range(3) 89 ROLL_SUCCESS, ROLL_EMPTY, ROLL_FAILURE = range(3)
90 90
91 91
92 _AUTH_REFRESH_TOKEN_FLAG = (
93 '--auth-refresh-token-json=/creds/refresh_tokens/recipe-roller')
94
95
92 def get_commit_message(roll_result, tbrs=()): 96 def get_commit_message(roll_result, tbrs=()):
93 """Construct a roll commit message from 'recipes.py autoroll' result. 97 """Construct a roll commit message from 'recipes.py autoroll' result.
94 """ 98 """
95 message = 'Roll recipe dependencies (%s).\n' % ( 99 message = 'Roll recipe dependencies (%s).\n' % (
96 'trivial' if roll_result['trivial'] else 'nontrivial') 100 'trivial' if roll_result['trivial'] else 'nontrivial')
97 message += COMMIT_MESSAGE_HEADER 101 message += COMMIT_MESSAGE_HEADER
98 if not roll_result['trivial']: 102 if not roll_result['trivial']:
99 message += NON_TRIVIAL_MESSAGE 103 message += NON_TRIVIAL_MESSAGE
100 message += COMMIT_MESSAGE_INFO 104 message += COMMIT_MESSAGE_INFO
101 105
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 # We have uploaded before, now let's check the diff hash to see if we 241 # We have uploaded before, now let's check the diff hash to see if we
238 # have uploaded this patchset before. 242 # have uploaded this patchset before.
239 change_data = json.loads(cat_result.stdout) 243 change_data = json.loads(cat_result.stdout)
240 cat_result.presentation.links['Issue %s' % change_data['issue']] = ( 244 cat_result.presentation.links['Issue %s' % change_data['issue']] = (
241 change_data['issue_url']) 245 change_data['issue_url'])
242 # Pass --rietveld flag to match upload args below. 246 # Pass --rietveld flag to match upload args below.
243 self.m.git('cl', 'issue', change_data['issue'], '--rietveld', cwd=workdir) 247 self.m.git('cl', 'issue', change_data['issue'], '--rietveld', cwd=workdir)
244 if change_data['diff_digest'] != diff_digest: 248 if change_data['diff_digest'] != diff_digest:
245 need_to_upload = True 249 need_to_upload = True
246 rebase = True 250 rebase = True
251 elif roll_result['trivial']:
252 # We won't be uploading. Make sure trivial rolls don't get stuck
253 # if previous CQ attempt failed because of flake.
254 # Pass --rietveld flag to match upload args below.
255 self.m.git('cl', 'set-commit', '--rietveld', _AUTH_REFRESH_TOKEN_FLAG,
256 cwd=workdir)
247 257
248 if need_to_upload: 258 if need_to_upload:
249 tbrs = [] 259 tbrs = []
250 if not rebase: 260 if not rebase:
251 tbrs = TRIVIAL_ROLL_TBR_EMAILS 261 tbrs = TRIVIAL_ROLL_TBR_EMAILS
252 commit_message = ( 262 commit_message = (
253 'Rebase' if rebase else get_commit_message(roll_result, tbrs=tbrs)) 263 'Rebase' if rebase else get_commit_message(roll_result, tbrs=tbrs))
254 if roll_result['trivial']: 264 if roll_result['trivial']:
255 # Land immediately. 265 # Land immediately.
256 upload_args = ['--use-commit-queue'] 266 upload_args = ['--use-commit-queue']
257 else: 267 else:
258 upload_args = ['--send-mail', '--cq-dry-run'] 268 upload_args = ['--send-mail', '--cq-dry-run']
259 upload_args.extend(['--bypass-hooks', '-f']) 269 upload_args.extend(['--bypass-hooks', '-f'])
260 # git cl upload doesn't work yet with gerrit and git cache. 270 # git cl upload doesn't work yet with gerrit and git cache.
261 upload_args.extend(['--rietveld']) 271 upload_args.extend(['--rietveld'])
262 upload_args.extend([ 272 upload_args.extend([_AUTH_REFRESH_TOKEN_FLAG])
263 '--auth-refresh-token-json=/creds/refresh_tokens/recipe-roller'])
264 self.m.git_cl.upload( 273 self.m.git_cl.upload(
265 commit_message, upload_args, name='git cl upload', cwd=workdir) 274 commit_message, upload_args, name='git cl upload', cwd=workdir)
266 issue_result = self.m.git( 275 issue_result = self.m.git(
267 'cl', 'issue', 276 'cl', 'issue',
268 name='git cl issue', stdout=self.m.raw_io.output(), 277 name='git cl issue', stdout=self.m.raw_io.output(),
269 cwd=workdir, 278 cwd=workdir,
270 step_test_data=lambda: self.m.raw_io.test_api.stream_output( 279 step_test_data=lambda: self.m.raw_io.test_api.stream_output(
271 'Issue number: ' 280 'Issue number: '
272 '123456789 (https://codereview.chromium.org/123456789)')) 281 '123456789 (https://codereview.chromium.org/123456789)'))
273 282
274 m = re.match('Issue number: (\d+) \((\S*)\)', issue_result.stdout.strip()) 283 m = re.match('Issue number: (\d+) \((\S*)\)', issue_result.stdout.strip())
275 if not m: 284 if not m:
276 self.m.python.failing_step( 285 self.m.python.failing_step(
277 'git cl upload failed', 'git cl issue output "%s" is not valid' % 286 'git cl upload failed', 'git cl issue output "%s" is not valid' %
278 issue_result.stdout.strip()) 287 issue_result.stdout.strip())
279 288
280 change_data = { 289 change_data = {
281 'issue': m.group(1), 290 'issue': m.group(1),
282 'issue_url': m.group(2), 291 'issue_url': m.group(2),
283 'diff_digest': diff_digest, 292 'diff_digest': diff_digest,
284 } 293 }
285 issue_result.presentation.links['Issue %s' % change_data['issue']] = ( 294 issue_result.presentation.links['Issue %s' % change_data['issue']] = (
286 change_data['issue_url']) 295 change_data['issue_url'])
287 self.m.gsutil.upload( 296 self.m.gsutil.upload(
288 self.m.json.input(change_data), 297 self.m.json.input(change_data),
289 'recipe-roller-cl-uploads', 298 'recipe-roller-cl-uploads',
290 cfg_digest) 299 cfg_digest)
OLDNEW
« no previous file with comments | « no previous file | recipes/recipes/recipe_autoroller.expected/previously_uploaded_match.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698