| # Copyright (c) 2020, the Dart project authors. All rights reserved. Use of this |
| # source code is governed by a BSD-style license that can be found in the |
| # LICENSE file. |
| # |
| # This recipe runs the presubmit. It checks that presubmit checks still pass |
| # when a CL is rebased (other changes may have landed and cause it to fail even |
| # though all checks passed when the CL was uploaded). |
| from recipe_engine import post_process |
| |
| DEPS = [ |
| 'depot_tools/gclient', |
| 'depot_tools/presubmit', |
| 'depot_tools/tryserver', |
| 'recipe_engine/buildbucket', |
| 'recipe_engine/context', |
| 'recipe_engine/json', |
| 'recipe_engine/path', |
| ] |
| |
| |
| def RunSteps(api): |
| # prepare() runs bot_update, which requires a gclient config. This creates a |
| # synthethic gclient config so that the recipe also works for projects that |
| # don't use gclient. |
| gclient_config = api.gclient.make_config() |
| solution = gclient_config.solutions.add() |
| solution.url = api.tryserver.gerrit_change_repo_url |
| solution.name = api.tryserver.gerrit_change.project |
| gclient_config.got_revision_mapping[solution.name] = 'got_revision' |
| api.gclient.c = gclient_config |
| |
| with api.context(cwd=api.path['cache'].join('builder')): |
| bot_update = api.presubmit.prepare() |
| # execute() doesn't raise a StepFailure on error, but returns an error code. |
| return api.presubmit.execute(bot_update, skip_owners=True) |
| |
| |
| def GenTests(api): |
| yield api.test( |
| 'success', |
| api.buildbucket.try_build( |
| build_number=1357, |
| builder='presubmit-try', |
| git_repo='https://dart.googlesource.com/sdk', |
| project='dart', |
| ), |
| api.step_data( |
| 'presubmit', |
| api.json.output({ |
| 'errors': [], |
| 'notifications': [], |
| 'warnings': [] |
| })), |
| api.post_process(post_process.StatusSuccess), |
| ) |
| |
| yield api.test( |
| 'failure', |
| api.buildbucket.try_build( |
| build_number=1357, |
| builder='presubmit-try', |
| git_repo='https://dart.googlesource.com/sdk', |
| project='dart', |
| ), |
| api.step_data( |
| 'presubmit', |
| api.json.output({ |
| 'errors': [{ |
| 'message': 'ERROR', |
| 'long_text': 'ERROR: occured' |
| }], |
| 'notifications': [], |
| 'warnings': [] |
| }), |
| retcode=1), |
| api.post_process(post_process.StatusFailure), |
| ) |