| Index: PRESUBMIT.py
|
| diff --git a/PRESUBMIT.py b/PRESUBMIT.py
|
| index 97c54d20eac5812f54d0f5bdd7da75123472f07d..e61b1ebbcd4ce389ce59fe0a815aa602580ce975 100644
|
| --- a/PRESUBMIT.py
|
| +++ b/PRESUBMIT.py
|
| @@ -170,13 +170,10 @@ def _ToolFlags(input_api, output_api):
|
| def _RecipeSimulationTest(input_api, output_api):
|
| """Run the recipe simulation test."""
|
| results = []
|
| - if not any(f.LocalPath().startswith('infra')
|
| - for f in input_api.AffectedFiles()):
|
| - return results
|
| -
|
| recipes_py = os.path.join('infra', 'bots', 'recipes.py')
|
| cmd = ['python', recipes_py, 'simulation_test']
|
| try:
|
| + input_api.logging.debug('Running: %s' % ' '.join(cmd))
|
| subprocess.check_output(cmd)
|
| except subprocess.CalledProcessError as e:
|
| results.append(output_api.PresubmitError(
|
| @@ -187,13 +184,25 @@ def _RecipeSimulationTest(input_api, output_api):
|
| def _GenTasksTest(input_api, output_api):
|
| """Run gen_tasks.go test."""
|
| results = []
|
| - if not any(f.LocalPath().startswith('infra')
|
| - for f in input_api.AffectedFiles()):
|
| +
|
| + # Update the infra Go packages.
|
| + cmd = ['go', 'get', '-u', 'go.skia.org/infra/...']
|
| + try:
|
| + subprocess.check_call(cmd)
|
| + except subprocess.CalledProcessError as e:
|
| + results.append(output_api.PresubmitError(
|
| + 'Failed to run %s: %s' % (' '.join(cmd), e)))
|
| + return results
|
| + except os.OSError:
|
| + results.append(output_api.PresubmitError(
|
| + 'Failed to run "%s"; is Go installed?' % ' '.join(cmd)))
|
| return results
|
|
|
| + # Run gen_tasks.go --test.
|
| gen_tasks = os.path.join('infra', 'bots', 'gen_tasks.go')
|
| cmd = ['go', 'run', gen_tasks, '--test']
|
| try:
|
| + input_api.logging.debug('Running: %s' % ' '.join(cmd))
|
| subprocess.check_output(cmd)
|
| except subprocess.CalledProcessError as e:
|
| results.append(output_api.PresubmitError(
|
| @@ -251,10 +260,12 @@ def CheckChangeOnUpload(input_api, output_api):
|
| """
|
| results = []
|
| results.extend(_CommonChecks(input_api, output_api))
|
| - # Run on upload, not commit, since the presubmit bot apparently doesn't have
|
| - # coverage or Go installed.
|
| - results.extend(_RecipeSimulationTest(input_api, output_api))
|
| - results.extend(_GenTasksTest(input_api, output_api))
|
| +
|
| + # On upload, only run these checks if something in the 'infra' dir changed.
|
| + if any(f.LocalPath().startswith('infra')
|
| + for f in input_api.AffectedFiles()):
|
| + results.extend(_RecipeSimulationTest(input_api, output_api))
|
| + results.extend(_GenTasksTest(input_api, output_api))
|
|
|
| results.extend(_CheckGNFormatted(input_api, output_api))
|
| return results
|
| @@ -648,4 +659,6 @@ def CheckChangeOnCommit(input_api, output_api):
|
| SKIA_TREE_STATUS_URL + '/banner-status?format=json')))
|
| results.extend(_CheckLGTMsForPublicAPI(input_api, output_api))
|
| results.extend(_CheckOwnerIsInAuthorsFile(input_api, output_api))
|
| + results.extend(_RecipeSimulationTest(input_api, output_api))
|
| + results.extend(_GenTasksTest(input_api, output_api))
|
| return results
|
|
|