OLD | NEW |
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 collections | 5 import collections |
6 import hashlib | 6 import hashlib |
7 import json | 7 import json |
8 import re | 8 import re |
9 | 9 |
10 from recipe_engine import recipe_api | 10 from recipe_engine import recipe_api |
11 | 11 |
12 RECIPE_TRYJOB_BYPASS_REASON_TAG = "Recipe-Tryjob-Bypass-Reason" | 12 RECIPE_TRYJOB_BYPASS_REASON_TAG = "Recipe-Tryjob-Bypass-Reason" |
13 | 13 |
| 14 PATCH_PROJECT_TO_LUCI_CONFIG = { |
| 15 'recipes-py': 'recipe_engine' |
| 16 } |
| 17 |
14 def get_recipes_path(project_config): | 18 def get_recipes_path(project_config): |
15 # Returns a tuple of the path components to traverse from the root of the repo | 19 # Returns a tuple of the path components to traverse from the root of the repo |
16 # to get to the directory containing recipes. | 20 # to get to the directory containing recipes. |
17 return project_config['recipes_path'][0].split('/') | 21 return project_config['recipes_path'][0].split('/') |
18 | 22 |
19 | 23 |
20 def get_deps(project_config): | 24 def get_deps(project_config): |
21 """ Get the recipe engine deps of a project from its recipes.cfg file. """ | 25 """ Get the recipe engine deps of a project from its recipes.cfg file. """ |
22 # "[0]" Since parsing makes every field a list | 26 # "[0]" Since parsing makes every field a list |
23 return [dep['project_id'][0] for dep in project_config.get('deps', [])] | 27 return [dep['project_id'][0] for dep in project_config.get('deps', [])] |
(...skipping 24 matching lines...) Expand all Loading... |
48 RietveldPatch = collections.namedtuple( | 52 RietveldPatch = collections.namedtuple( |
49 'RietveldPatch', 'project server issue patchset') | 53 'RietveldPatch', 'project server issue patchset') |
50 | 54 |
51 | 55 |
52 def parse_patches(failing_step, patches_raw, rietveld, issue, patchset, | 56 def parse_patches(failing_step, patches_raw, rietveld, issue, patchset, |
53 patch_project): | 57 patch_project): |
54 """ | 58 """ |
55 gives mapping of project to patch | 59 gives mapping of project to patch |
56 expect input of | 60 expect input of |
57 project1:https://a.b.c/1342342#ps1,project2:https://d.ce.f/1231231#ps1 | 61 project1:https://a.b.c/1342342#ps1,project2:https://d.ce.f/1231231#ps1 |
| 62 |
| 63 Also looks at properties, which are passed into the rietveld, issue, patchset, |
| 64 and patch_project. |
58 """ | 65 """ |
59 result = {} | 66 result = {} |
60 | 67 |
61 if rietveld and issue and patchset and patch_project: | 68 if rietveld and issue and patchset and patch_project: |
62 # convert to str because recipes don't like unicode as step names | 69 # convert to str because recipes don't like unicode as step names |
| 70 patch_project = PATCH_PROJECT_TO_LUCI_CONFIG.get( |
| 71 patch_project) or patch_project |
| 72 |
63 result[str(patch_project)] = RietveldPatch( | 73 result[str(patch_project)] = RietveldPatch( |
64 patch_project, rietveld, issue, patchset) | 74 patch_project, rietveld, issue, patchset) |
65 | 75 |
66 if not patches_raw: | 76 if not patches_raw: |
67 return result | 77 return result |
68 | 78 |
69 for patch_raw in patches_raw.split(','): | 79 for patch_raw in patches_raw.split(','): |
70 project, url = patch_raw.split(':', 1) | 80 project, url = patch_raw.split(':', 1) |
71 server, issue_and_patchset = url.rsplit('/', 1) | 81 server, issue_and_patchset = url.rsplit('/', 1) |
72 issue, patchset = issue_and_patchset.split('#') | 82 issue, patchset = issue_and_patchset.split('#') |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 except recipe_api.StepFailure: | 300 except recipe_api.StepFailure: |
291 if should_fail_build_mapping.get(proj, True): | 301 if should_fail_build_mapping.get(proj, True): |
292 bad_projects.append(proj) | 302 bad_projects.append(proj) |
293 | 303 |
294 if bad_projects: | 304 if bad_projects: |
295 raise recipe_api.StepFailure( | 305 raise recipe_api.StepFailure( |
296 "One or more projects failed tests: %s" % ( | 306 "One or more projects failed tests: %s" % ( |
297 ','.join(bad_projects))) | 307 ','.join(bad_projects))) |
298 | 308 |
299 | 309 |
OLD | NEW |