pw_presubmit: Reorder steps; quick pre-push hook - Set PW_ROOT if it's not set to allow running outside of the Pigweed environment. - Reorder the steps in the full program to put quicker steps first. - Have the Git pre-push hook run the quick program instead of the default full program. Change-Id: I28c3a5a62bf61e4ed2d889fa9bea17003fcdeab7
diff --git a/pw_presubmit/py/pw_presubmit/pigweed_presubmit.py b/pw_presubmit/py/pw_presubmit/pigweed_presubmit.py index 1377b42..1c180d5 100755 --- a/pw_presubmit/py/pw_presubmit/pigweed_presubmit.py +++ b/pw_presubmit/py/pw_presubmit/pigweed_presubmit.py
@@ -460,16 +460,17 @@ # QUICK_PRESUBMIT: Sequence = ( *INIT, - *PYTHON, - gn_clang_build, - pw_presubmit.pragma_once, *CODE_FORMAT, *GENERAL, + *CC, + gn_clang_build, + gn_arm_build, + *PYTHON, ) PROGRAMS: Dict[str, Sequence] = { 'broken': BROKEN, - 'full': INIT + GN + CC + PYTHON + CMAKE + BAZEL + CODE_FORMAT + GENERAL, + 'full': INIT + CODE_FORMAT + GENERAL + CC + GN + PYTHON + CMAKE + BAZEL, 'quick': QUICK_PRESUBMIT, } @@ -537,6 +538,9 @@ ) -> int: """Entry point for presubmit.""" + os.environ.setdefault('PW_ROOT', + str(pw_presubmit.git_repo_path(repo=repository))) + if not output_directory: output_directory = pw_presubmit.git_repo_path('.presubmit', repo=repository) @@ -549,7 +553,8 @@ shutil.rmtree(environment.joinpath('init_virtualenv')) if install: - install_hook(__file__, 'pre-push', ['--base', 'origin/master..HEAD'], + install_hook(__file__, 'pre-push', + ['--base', 'origin/master..HEAD', '--program', 'quick'], repository) return 0