Allow running single steps in presubmit.
Add ability to run individual presubmit checks using --step.
Bug: 3
Change-Id: Ibcea8e54de2deb2e8159ae1389b86a5c82da0d14
diff --git a/pw_presubmit/py/pw_presubmit/pigweed_presubmit.py b/pw_presubmit/py/pw_presubmit/pigweed_presubmit.py
index f3bbc44..a0c4ded 100755
--- a/pw_presubmit/py/pw_presubmit/pigweed_presubmit.py
+++ b/pw_presubmit/py/pw_presubmit/pigweed_presubmit.py
@@ -347,6 +347,8 @@
def argument_parser(parser=None) -> argparse.ArgumentParser:
+ """Create argument parser."""
+
if parser is None:
parser = argparse.ArgumentParser(description=__doc__)
@@ -370,6 +372,14 @@
choices=PROGRAMS,
default='full',
help='Which presubmit program to run')
+
+ exclusive.add_argument(
+ '--step',
+ choices=[x.__name__ for x in PROGRAMS['full']],
+ action='append',
+ help='Provide explicit steps instead of running a predefined program.',
+ )
+
pw_presubmit.add_arguments(parser)
return parser
@@ -381,8 +391,11 @@
clean_py: bool,
install: bool,
repository: str,
+ step: Sequence[str],
**presubmit_args,
) -> int:
+ """Entry point for presubmit."""
+
environment = pw_presubmit.git_repo_path(PRESUBMIT_PREFIX, repo=repository)
_LOG.debug('Using environment at %s', environment)
@@ -396,7 +409,11 @@
presubmit_args['repository'])
return 0
- if pw_presubmit.run_presubmit(PROGRAMS[program],
+ program = PROGRAMS[program]
+ if step:
+ program = [x for x in PROGRAMS['full'] if x.__name__ in step]
+
+ if pw_presubmit.run_presubmit(program,
repository=repository,
**presubmit_args):
return 0