OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 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 | 5 |
6 """Recipe module to ensure a checkout is consistant on a bot.""" | 6 """Recipe module to ensure a checkout is consistant on a bot.""" |
7 | 7 |
8 | 8 |
9 from slave import recipe_api | 9 from slave import recipe_api |
10 | 10 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 self.m.properties.get('revision')) | 83 self.m.properties.get('revision')) |
84 # Issue and patchset must come together. | 84 # Issue and patchset must come together. |
85 if issue: | 85 if issue: |
86 assert patchset | 86 assert patchset |
87 if patchset: | 87 if patchset: |
88 assert issue | 88 assert issue |
89 if patch_url: | 89 if patch_url: |
90 # If patch_url is present, bot_update will actually ignore issue/ps. | 90 # If patch_url is present, bot_update will actually ignore issue/ps. |
91 issue = patchset = None | 91 issue = patchset = None |
92 | 92 |
| 93 rev_map = {} |
| 94 if self.m.gclient.c: |
| 95 rev_map = self.m.gclient.c.got_revision_mapping.as_jsonish() |
| 96 |
93 flags = [ | 97 flags = [ |
94 # 1. Do we want to run? (master/builder/slave). | 98 # 1. Do we want to run? (master/builder/slave). |
95 ['--master', master], | 99 ['--master', master], |
96 ['--builder', builder], | 100 ['--builder', builder], |
97 ['--slave', slave], | 101 ['--slave', slave], |
98 | 102 |
99 # 2. What do we want to check out (spec/root/rev/rev_map). | 103 # 2. What do we want to check out (spec/root/rev/rev_map). |
100 ['--spec', spec_string], | 104 ['--spec', spec_string], |
101 ['--root', root], | 105 ['--root', root], |
102 ['--revision', revision], | 106 ['--revision', revision], |
103 ['--revision_mapping', self.m.properties.get('revision_mapping')], | 107 ['--revision_mapping_file', self.m.json.input(rev_map)], |
104 | 108 |
105 # 3. How to find the patch, if any (issue/patchset/patch_url). | 109 # 3. How to find the patch, if any (issue/patchset/patch_url). |
106 ['--issue', issue], | 110 ['--issue', issue], |
107 ['--patchset', patchset], | 111 ['--patchset', patchset], |
108 ['--patch_url', patch_url], | 112 ['--patch_url', patch_url], |
109 | 113 |
110 # 4. Hookups to JSON output back into recipes. | 114 # 4. Hookups to JSON output back into recipes. |
111 ['--output_json', self.m.json.output()],] | 115 ['--output_json', self.m.json.output()],] |
112 | 116 |
113 # Filter out flags that are None. | 117 # Filter out flags that are None. |
114 cmd = [item for flag_set in flags | 118 cmd = [item for flag_set in flags |
115 for item in flag_set if flag_set[1] is not None] | 119 for item in flag_set if flag_set[1] is not None] |
116 | 120 |
117 # Inject Json output for testing. | 121 # Inject Json output for testing. |
118 try: | |
119 revision_map_data = self.m.gclient.c.got_revision_mapping | |
120 except AttributeError: | |
121 revision_map_data = {} | |
122 git_mode = self.m.properties.get('mastername') in GIT_MASTERS | 122 git_mode = self.m.properties.get('mastername') in GIT_MASTERS |
123 first_sln = cfg.solutions[0].name | 123 first_sln = cfg.solutions[0].name |
124 step_test_data = lambda : self.test_api.output_json(master, | 124 step_test_data = lambda: self.test_api.output_json( |
125 builder, | 125 master, builder, slave, root, first_sln, rev_map, git_mode) |
126 slave, | |
127 root, | |
128 first_sln, | |
129 revision_map_data, | |
130 git_mode) | |
131 | 126 |
132 def followup_fn(step_result): | 127 def followup_fn(step_result): |
133 if update_presentation: | 128 if update_presentation: |
134 # Set properties such as got_revision. | 129 # Set properties such as got_revision. |
135 if 'properties' in step_result.json.output: | 130 if 'properties' in step_result.json.output: |
136 properties = step_result.json.output['properties'] | 131 properties = step_result.json.output['properties'] |
137 for prop_name, prop_value in properties.iteritems(): | 132 for prop_name, prop_value in properties.iteritems(): |
138 step_result.presentation.properties[prop_name] = prop_value | 133 step_result.presentation.properties[prop_name] = prop_value |
139 # Add helpful step description in the step UI. | 134 # Add helpful step description in the step UI. |
140 if 'step_text' in step_result.json.output: | 135 if 'step_text' in step_result.json.output: |
(...skipping 14 matching lines...) Expand all Loading... |
155 # Set the "checkout" path for the main solution. | 150 # Set the "checkout" path for the main solution. |
156 # This is used by the Chromium module to figure out where to look for | 151 # This is used by the Chromium module to figure out where to look for |
157 # the checkout. | 152 # the checkout. |
158 bot_update_step = self.m.step_history.last_step() | 153 bot_update_step = self.m.step_history.last_step() |
159 # bot_update actually just sets root to be the folder name of the | 154 # bot_update actually just sets root to be the folder name of the |
160 # first solution. | 155 # first solution. |
161 if bot_update_step.json.output['did_run']: | 156 if bot_update_step.json.output['did_run']: |
162 co_root = bot_update_step.json.output['root'] | 157 co_root = bot_update_step.json.output['root'] |
163 cwd = kwargs.get('cwd', self.m.path['slave_build']) | 158 cwd = kwargs.get('cwd', self.m.path['slave_build']) |
164 self.m.path['checkout'] = cwd.join(*co_root.split(self.m.path.sep)) | 159 self.m.path['checkout'] = cwd.join(*co_root.split(self.m.path.sep)) |
OLD | NEW |