| OLD | NEW |
| 1 # Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2014 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 """Rolls recipes.cfg dependencies.""" | 5 """Rolls recipes.cfg dependencies.""" |
| 6 | 6 |
| 7 DEPS = [ | 7 DEPS = [ |
| 8 'depot_tools/bot_update', | 8 'depot_tools/bot_update', |
| 9 'depot_tools/gclient', | 9 'depot_tools/gclient', |
| 10 'file', | 10 'file', |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 for project in fetch_result['projects']: | 174 for project in fetch_result['projects']: |
| 175 mapping[project['id']] = project | 175 mapping[project['id']] = project |
| 176 mapping[project['id']] = dict(project) | 176 mapping[project['id']] = dict(project) |
| 177 return mapping | 177 return mapping |
| 178 | 178 |
| 179 | 179 |
| 180 RietveldPatch = collections.namedtuple( | 180 RietveldPatch = collections.namedtuple( |
| 181 'RietveldPatch', 'project server issue patchset') | 181 'RietveldPatch', 'project server issue patchset') |
| 182 | 182 |
| 183 | 183 |
| 184 def parse_patches(api, patches_raw): | 184 def parse_patches(api, patches_raw, rietveld, issue, patchset, patch_project): |
| 185 """ | 185 """ |
| 186 gives mapping of project to patch | 186 gives mapping of project to patch |
| 187 expect input of | 187 expect input of |
| 188 project1:https://a.b.c/1342342#ps1,project2:https://d.ce.f/1231231#ps1 | 188 project1:https://a.b.c/1342342#ps1,project2:https://d.ce.f/1231231#ps1 |
| 189 """ | 189 """ |
| 190 result = {} |
| 191 |
| 192 if rietveld and issue and patchset and patch_project: |
| 193 result[patch_project] = RietveldPatch( |
| 194 patch_project, rietveld, issue, patchset) |
| 195 |
| 190 if not patches_raw: | 196 if not patches_raw: |
| 191 return {} | 197 return result |
| 192 | |
| 193 result = {} | |
| 194 | 198 |
| 195 for patch_raw in patches_raw.split(','): | 199 for patch_raw in patches_raw.split(','): |
| 196 project, url = patch_raw.split(':', 1) | 200 project, url = patch_raw.split(':', 1) |
| 197 server, issue_and_patchset = url.rsplit('/', 1) | 201 server, issue_and_patchset = url.rsplit('/', 1) |
| 198 issue, patchset = issue_and_patchset.split('#') | 202 issue, patchset = issue_and_patchset.split('#') |
| 199 patchset = patchset[2:] | 203 patchset = patchset[2:] |
| 200 | 204 |
| 201 if project in result: | 205 if project in result: |
| 202 api.python.failing_step( | 206 api.python.failing_step( |
| 203 "Invalid patchset list", | 207 "Invalid patchset list", |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 'depot_tools', | 315 'depot_tools', |
| 312 ] | 316 ] |
| 313 | 317 |
| 314 PROPERTIES = { | 318 PROPERTIES = { |
| 315 'patches': Property(kind=str, param_name='patches_raw', default="", | 319 'patches': Property(kind=str, param_name='patches_raw', default="", |
| 316 help="Patches to apply. Format is" | 320 help="Patches to apply. Format is" |
| 317 "project1:https://url.to.codereview/123456#ps01 where" | 321 "project1:https://url.to.codereview/123456#ps01 where" |
| 318 "url.to.codereview is the address of the code review site" | 322 "url.to.codereview is the address of the code review site" |
| 319 ", 123456 is the issue number, and ps01 is the patchset" | 323 ", 123456 is the issue number, and ps01 is the patchset" |
| 320 "number"), | 324 "number"), |
| 325 # This recipe can be used as a tryjob by setting the rietveld, issue, and |
| 326 # patchset properties, like a normal tryjob. If those are set, it will use |
| 327 # those, as well as any data sent in the regular properties, as patches to |
| 328 # apply. |
| 329 "rietveld": Property(kind=str, default="", |
| 330 help="The code review site the tryjob patch isfrom"), |
| 331 "issue": Property(kind=int, default=None, |
| 332 help="The issue number this patch is from"), |
| 333 "patchset": Property(kind=int, default=None, |
| 334 help="The patchset to apply from this patch"), |
| 335 "patch_project": Property( |
| 336 kind=str, default=None, |
| 337 help="The luci-config name of the project this patch belongs to"), |
| 321 } | 338 } |
| 322 | 339 |
| 323 def RunSteps(api, patches_raw): | 340 def RunSteps(api, patches_raw, rietveld, issue, patchset, patch_project): |
| 324 auth_token = get_auth_token(api) | 341 auth_token = get_auth_token(api) |
| 325 headers = {'Authorization': 'Bearer %s' % auth_token} | 342 headers = {'Authorization': 'Bearer %s' % auth_token} |
| 326 | 343 |
| 327 patches = parse_patches(api, patches_raw) | 344 patches = parse_patches( |
| 345 api, patches_raw, rietveld, issue, patchset, patch_project) |
| 328 | 346 |
| 329 root_dir = api.path['slave_build'] | 347 root_dir = api.path['slave_build'] |
| 330 | 348 |
| 331 url_mapping = get_url_mapping(api, auth_token) | 349 url_mapping = get_url_mapping(api, auth_token) |
| 332 | 350 |
| 333 # luci config project name to recipe config namedtuple | 351 # luci config project name to recipe config namedtuple |
| 334 recipe_configs = {} | 352 recipe_configs = {} |
| 335 | 353 |
| 336 # List of all the projects we care about testing. luci-config names | 354 # List of all the projects we care about testing. luci-config names |
| 337 all_projects = set(p for p in url_mapping if p in PROJECTS_TO_TRY) | 355 all_projects = set(p for p in url_mapping if p in PROJECTS_TO_TRY) |
| 338 | 356 |
| 339 recipe_configs = { | 357 recipe_configs = { |
| 340 p: get_project_config(api, p, headers) for p in all_projects} | 358 p: get_project_config(api, p, headers) for p in all_projects} |
| 341 | 359 |
| 342 downstream_projects, deps = get_deps_info(all_projects, recipe_configs) | 360 deps, downstream_projects = get_deps_info(all_projects, recipe_configs) |
| 343 | 361 |
| 344 projs_to_test, locations = checkout_projects( | 362 projs_to_test, locations = checkout_projects( |
| 345 api, all_projects, url_mapping, downstream_projects, root_dir, patches) | 363 api, all_projects, url_mapping, downstream_projects, root_dir, patches) |
| 346 | 364 |
| 347 with api.step.defer_results(): | 365 with api.step.defer_results(): |
| 348 for proj in projs_to_test: | 366 for proj in projs_to_test: |
| 349 deps_locs = {dep: locations[dep] for dep in deps[proj]} | 367 deps_locs = {dep: locations[dep] for dep in deps[proj]} |
| 350 | 368 |
| 351 simulation_test( | 369 simulation_test( |
| 352 api, proj, recipe_configs[proj], locations[proj], deps_locs) | 370 api, proj, recipe_configs[proj], locations[proj], deps_locs) |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 api.properties( | 419 api.properties( |
| 402 patches="build:https://f.e.w/1#ps1,build:https://f.e.w/1#ps1") | 420 patches="build:https://f.e.w/1#ps1,build:https://f.e.w/1#ps1") |
| 403 ) | 421 ) |
| 404 | 422 |
| 405 yield ( | 423 yield ( |
| 406 api.test('deps') + | 424 api.test('deps') + |
| 407 api.step_data("Get build deps", project('build', ['recipe_engine'])) + | 425 api.step_data("Get build deps", project('build', ['recipe_engine'])) + |
| 408 api.step_data("Get recipe_engine deps", project('recipe_engine')) | 426 api.step_data("Get recipe_engine deps", project('recipe_engine')) |
| 409 ) | 427 ) |
| 410 | 428 |
| 429 yield ( |
| 430 api.test('tryjob') + |
| 431 api.properties( |
| 432 rietveld="https://fake.code.review", |
| 433 issue=12345678, |
| 434 patchset=1, |
| 435 patch_project="build", |
| 436 ) + |
| 437 api.step_data("Get build deps", project('build', ['recipe_engine'])) + |
| 438 api.step_data("Get recipe_engine deps", project('recipe_engine')) |
| 439 ) |
| 440 |
| OLD | NEW |