Commit e6bbb3a2 authored by Bruce Dawson's avatar Bruce Dawson Committed by LUCI CQ

Avoid redundant global presubmit checks

PanProjectChecks is called twice, once from the root PRESUBMIT.py and
once from third_party/blink/PRESUBMIT.py. For the file-based checks a
series of filters avoids redundant reporting, but certain global checks
were being run twice, potentially causing duplicate reporting.

This adds an optional global_checks flag which can be set to false in
the blink PRESUBMIT.

Bug: 1309977
Change-Id: Ia43a7a0f29cf7b58ac9bab0e9aa374e9bf0155a3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3611409
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
Reviewed-by: 's avatarJesse McKenna <jessemckenna@google.com>
parent 7f39e3d1
......@@ -1342,7 +1342,7 @@ def CheckSingletonInHeaders(input_api, output_api, source_file_filter=None):
def PanProjectChecks(input_api, output_api,
excluded_paths=None, text_files=None,
license_header=None, project_name=None,
owners_check=True, maxlen=80):
owners_check=True, maxlen=80, global_checks=True):
"""Checks that ALL chromium orbit projects should use.
These are checks to be run on all Chromium orbit project, including:
......@@ -1357,6 +1357,11 @@ def PanProjectChecks(input_api, output_api,
text_files: Which file are to be treated as documentation text files.
license_header: What license header should be on files.
project_name: What is the name of the project as it appears in the license.
global_checks: If True run checks that are unaffected by other options or by
the PRESUBMIT script's location, such as CheckChangeHasDescription.
global_checks should be passed as False when this function is called from
locations other than the project's root PRESUBMIT.py, to avoid redundant
checking.
Returns:
A list of warning or error objects.
"""
......@@ -1414,21 +1419,26 @@ def PanProjectChecks(input_api, output_api,
source_file_filter=sources))
if input_api.is_committing:
snapshot("checking was uploaded")
results.extend(input_api.canned_checks.CheckChangeWasUploaded(
input_api, output_api))
snapshot("checking description")
results.extend(input_api.canned_checks.CheckChangeHasDescription(
input_api, output_api))
results.extend(input_api.canned_checks.CheckDoNotSubmitInDescription(
input_api, output_api))
if global_checks:
# These changes verify state that is global to the tree and can therefore
# be skipped when run from PRESUBMIT.py scripts deeper in the tree.
# Skipping these saves a bit of time and avoids having redundant output.
# This was initially designed for use by third_party/blink/PRESUBMIT.py.
snapshot("checking was uploaded")
results.extend(input_api.canned_checks.CheckChangeWasUploaded(
input_api, output_api))
snapshot("checking description")
results.extend(input_api.canned_checks.CheckChangeHasDescription(
input_api, output_api))
results.extend(input_api.canned_checks.CheckDoNotSubmitInDescription(
input_api, output_api))
if input_api.change.scm == 'git':
snapshot("checking for commit objects in tree")
results.extend(input_api.canned_checks.CheckForCommitObjects(
input_api, output_api))
snapshot("checking do not submit in files")
results.extend(input_api.canned_checks.CheckDoNotSubmitInFiles(
input_api, output_api))
if input_api.change.scm == 'git':
snapshot("checking for commit objects in tree")
results.extend(input_api.canned_checks.CheckForCommitObjects(
input_api, output_api))
snapshot("done")
return results
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment