def RunSteps(api, inputs): try: repo_urls = _get_repo_urls(api, inputs) except _InvalidInput as e: return result_pb.RawResult(status=bb_common_pb.FAILURE, summary_markdown=e.message) work_dir = api.path['cache'].join('builder', 'w') api.file.ensure_directory('ensure work_dir', work_dir) env = { # Turn off the low speed limit, since checkout will be long. 'GIT_HTTP_LOW_SPEED_LIMIT': '0', 'GIT_HTTP_LOW_SPEED_TIME': '0', # Ensure git-number tool can be used. 'CHROME_HEADLESS': '1', } if api.runtime.is_experimental: assert inputs.override_bucket, 'override_bucket required for experiments' if inputs.override_bucket: env['OVERRIDE_BOOTSTRAP_BUCKET'] = inputs.override_bucket opts = [ '--cache-dir', work_dir, '--prune', '--reset-fetch-config', '--verbose', '--ref', 'refs/branch-heads/*', # By default, "refs/heads/*" and refs/tags/* are checked out by # git_cache. However, for heavy branching repos, # 'refs/branch-heads/*' is also very useful (crbug/942169). # This is a noop for repos without refs/branch-heads. ] if inputs.gc_aggressive: opts += ['--gc-aggressive'] with api.context(env=env), api.depot_tools.on_path(): for url in sorted(repo_urls): api.step( name='Updating %s' % url, cmd=['git_cache.py', 'update-bootstrap', url] + opts, # It's fine for this to fail, just move on to the next one. ok_ret='any') return result_pb.RawResult( status=bb_common_pb.SUCCESS, summary_markdown='Updated cache for %d repos' % len(repo_urls), )
def RunSteps(api): raw_result = result_pb2.RawResult() try: result = api.step('step_result', ['cmd', api.json.output()], timeout=480) if result.json.output: raw_result.summary_markdown = result.json.output['summary'] raw_result.status = common_pb2.SUCCESS else: raw_result.summary_markdown = 'No json output.' raw_result.status = common_pb2.FAILURE except api.step.StepFailure: step_data = api.step.active_result if step_data.json.output: raw_result.summary_markdown = step_data.json.output['summary'] if step_data.exc_result.had_timeout: raw_result.summary_markdown += 'Failure : Timeout' raw_result.status = common_pb2.FAILURE if step_data.exc_result.retcode == 1: raw_result.status = common_pb2.FAILURE else: raw_result.status = common_pb2.INFRA_FAILURE if raw_result.summary_markdown == '': raise return raw_result
def execute(self, bot_update_step, skip_owners=False): """Runs presubmit and sets summary markdown if applicable. Args: * bot_update_step: the StepResult from a previously executed bot_update step. * skip_owners: a boolean indicating whether Owners checks should be skipped. Returns: a RawResult object, suitable for being returned from RunSteps. """ relative_root = self.m.gclient.get_gerrit_patch_root().rstrip('/') abs_root = self.m.context.cwd.join(relative_root) got_revision_properties = self.m.bot_update.get_project_revision_properties( # Replace path.sep with '/', since most recipes are written assuming '/' # as the delimiter. This breaks on windows otherwise. relative_root.replace(self.m.path.sep, '/'), self.m.gclient.c) upstream = bot_update_step.json.output['properties'].get( got_revision_properties[0]) presubmit_args = [ '--issue', self.m.tryserver.gerrit_change.change, '--patchset', self.m.tryserver.gerrit_change.patchset, '--gerrit_url', 'https://%s' % self.m.tryserver.gerrit_change.host, '--gerrit_project', self.m.tryserver.gerrit_change.project, '--gerrit_branch', self.m.tryserver.gerrit_change_target_ref, '--gerrit_fetch', ] if self.m.cq.active and self.m.cq.run_mode == self.m.cq.DRY_RUN: presubmit_args.append('--dry_run') presubmit_args.extend([ '--root', abs_root, '--commit', '--verbose', '--verbose', '--skip_canned', 'CheckTreeIsOpen', '--upstream', upstream, # '' if not in bot_update mode. ]) if skip_owners: presubmit_args.extend(['--skip_canned', 'CheckOwners']) raw_result = result_pb2.RawResult() step_json = self( *presubmit_args, timeout=self._timeout_s, # ok_ret='any' causes all exceptions to be ignored in this step ok_ret='any') # Set recipe result values if step_json: raw_result.summary_markdown = _createSummaryMarkdown(step_json) retcode = self.m.step.active_result.retcode if retcode == 0: raw_result.status = common_pb2.SUCCESS return raw_result self.m.step.active_result.presentation.status = 'FAILURE' if self.m.step.active_result.exc_result.had_timeout: raw_result.status = common_pb2.FAILURE raw_result.summary_markdown += ( '\n\nTimeout occurred during presubmit step.') elif retcode == 1: raw_result.status = common_pb2.FAILURE self.m.tryserver.set_test_failure_tryjob_result() else: raw_result.status = common_pb2.INFRA_FAILURE self.m.tryserver.set_invalid_test_results_tryjob_result() # Handle unexpected errors not caught by json output if raw_result.summary_markdown == '': raw_result.status = common_pb2.INFRA_FAILURE raw_result.summary_markdown = ( 'Something unexpected occurred' ' while running presubmit checks.' ' Please [file a bug](https://bugs.chromium.org' '/p/chromium/issues/entry?components=' 'Infra%3EClient%3EChrome&status=Untriaged)') return raw_result