OLD | NEW |
---|---|
(Empty) | |
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 | |
3 # found in the LICENSE file. | |
4 | |
5 from recipe_engine import recipe_api | |
6 | |
7 | |
8 class RecipeAutorollerApi(recipe_api.RecipeApi): | |
9 def prepare_checkout(self): | |
martiniss
2016/04/07 18:27:59
Why do we need this exactly?
Paweł Hajdan Jr.
2016/04/07 20:32:15
So that this logic is not duplicated between publi
martiniss
2016/04/07 21:27:12
I guess my question was more existential; I don't
| |
10 """Creates a default checkout for the recipe autoroller.""" | |
11 self.m.gclient.set_config('recipes_py') | |
12 self.m.gclient.checkout() | |
13 self.m.gclient.runhooks() | |
14 | |
15 def roll_projects(self, projects): | |
16 """Attempts to roll each project from the provided list. | |
17 | |
18 If rolling any of the projects leads to failures, other | |
19 projects are not affected. | |
20 """ | |
21 project_data = self.m.luci_config.get_projects() | |
22 with recipe_api.defer_results(): | |
23 for project in projects: | |
24 with self.m.step.nest(str(project)): | |
25 self._roll_project(project_data[project]) | |
26 | |
27 def _roll_project(self, project_data): | |
28 with self.m.tempfile.temp_dir('roll_%s' % project_data['id']) as workdir: | |
29 self.m.git.checkout( | |
30 project_data['repo_url'], dir_path=workdir, submodules=False) | |
31 | |
32 recipes_cfg_path = workdir.join('infra', 'config', 'recipes.cfg') | |
33 | |
34 roll_step = self.m.python('roll', | |
35 self.m.path['checkout'].join('recipes-py', 'recipes.py'), | |
36 ['--package', recipes_cfg_path, 'autoroll', | |
37 '--output-json', self.m.json.output()]) | |
38 roll_result = roll_step.json.output | |
39 | |
40 if roll_result['success']: | |
41 blame = [] | |
42 for project, commits in roll_result[ | |
43 'picked_roll_details']['commit_infos'].iteritems(): | |
44 blame.append('%s:' % project) | |
45 for commit in commits: | |
46 message = commit['message'].splitlines() | |
47 # TODO(phajdan): truncate long messages. | |
48 message = message[0] if message else 'n/a' | |
49 # TODO(phajdan): get clickable links for the commits. | |
50 blame.append(' %s %s (%s)' % ( | |
51 commit['revision'], message, commit['author'])) | |
52 roll_step.presentation.logs['blame'] = blame | |
53 | |
54 if roll_result['trivial']: | |
55 roll_step.presentation.step_text += ' (trivial)' | |
56 else: | |
57 roll_step.presentation.status = self.m.step.WARNING | |
58 else: | |
59 if (not roll_result['roll_details'] and | |
60 not roll_result['rejected_candidates_details']): | |
61 roll_step.presentation.step_text += ' (already at latest revisions)' | |
62 else: | |
63 roll_step.presentation.status = self.m.step.FAILURE | |
64 | |
65 # TODO(phajdan): upload the CL. | |
66 self.m.git('diff', 'HEAD', cwd=workdir) | |
OLD | NEW |