Files
chromium_depot_tools/recipes/recipe_modules/presubmit/tests/prepare.py
Ben Pastene 33b199ffaf Surface git errors in the build summary for presubmit builds
Occasionally someone will upload a CL whose diff was already landed in
another CL. In the past, the error message from the presubmit build
for their CL has led to confusion. So this tries to clarify it by:
- putting the git stdout from the git cmd in the build summary when it
  fails
- adding a hint about the identical diff in the build summary when it
  sees "nothing to commit" in git's stdout

eg: Before this CL, such builds fail like:
https://ci.chromium.org/ui/p/chromium/builders/try/chromium_presubmit/3035841/infra

With this CL, they'll fail like:
https://ci.chromium.org/ui/p/chromium/builders/try.shadow/chromium_presubmit/3883/infra

Bug: None
Change-Id: I8002e19efce3cae5a11d2e616e4db596afb3b50c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6039934
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Ben Pastene <bpastene@chromium.org>
2024-11-20 23:29:33 +00:00

65 lines
1.9 KiB
Python

# Copyright 2019 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from recipe_engine import post_process
from recipe_engine import recipe_api
PYTHON_VERSION_COMPATIBILITY = 'PY3'
DEPS = [
'gclient',
'presubmit',
'recipe_engine/buildbucket',
'recipe_engine/context',
'recipe_engine/path',
'recipe_engine/properties',
'recipe_engine/raw_io',
'recipe_engine/runtime',
]
PROPERTIES = {
'patch_project': recipe_api.Property(None),
'patch_repository_url': recipe_api.Property(None),
}
def RunSteps(api, patch_project, patch_repository_url):
api.gclient.set_config('infra')
with api.context(cwd=api.path.cache_dir / 'builder'):
bot_update_step = api.presubmit.prepare()
def GenTests(api):
yield (api.test('basic') + api.runtime(is_experimental=False) +
api.buildbucket.try_build(project='infra') +
api.post_process(post_process.StatusSuccess) +
api.post_process(post_process.DropExpectation))
yield (api.test('runhooks') + api.runtime(is_experimental=False) +
api.buildbucket.try_build(project='infra') +
api.presubmit(runhooks=True) +
api.post_process(post_process.MustRun, 'gclient runhooks') +
api.post_process(post_process.StatusSuccess) +
api.post_process(post_process.DropExpectation))
yield api.test(
'failed_commit',
api.runtime(is_experimental=False),
api.buildbucket.try_build(project='infra'),
api.step_data(
'commit-git-patch',
retcode=1,
stdout=api.raw_io.output_text(
'nothing to commit, working tree clean'),
),
api.expect_status('FAILURE'),
api.post_check(
post_process.SummaryMarkdownRE,
'Was an identical diff already submitted elsewhere?',
),
api.post_process(post_process.DropExpectation),
)