From 784ab4b4692ec83e2e8ad9972c0a2c211e143a5a Mon Sep 17 00:00:00 2001 From: Dennis Kempin Date: Wed, 25 May 2022 21:20:32 +0000 Subject: [PATCH] health-check: Add option to run only some checks The default is still to run all of them, but this will allow us to run checks in separate luci steps to provide an easier to read result. BUG=b:233913455 TEST=./tools/health-check python fmt Change-Id: Iddc803f8f423db36ece53a13acfe564560b789a6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3668812 Reviewed-by: Daniel Verkamp Tested-by: kokoro --- tools/health-check | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/tools/health-check b/tools/health-check index cd77f4924f..bde246f0d6 100755 --- a/tools/health-check +++ b/tools/health-check @@ -5,8 +5,9 @@ import doctest import importlib -from pathlib import Path +import argh # type: ignore import sys +from pathlib import Path from impl.common import CROSVM_ROOT, run_main, cmd, chdir, parallel, find_scripts from impl.check_code_hygiene import has_crlf_line_endings @@ -35,13 +36,24 @@ def check_crlf_line_endings(): sys.exit(-1) -def main(): +@argh.arg("checks", choices=["python", "misc", "fmt", "clippy", "all", []]) +def main(*checks: str): chdir(CROSVM_ROOT) - check_python() - check_crlf_line_endings() - cmd("./tools/fmt --check").fg() - cmd("./tools/clippy").fg() + if not checks: + checks = ("all",) + + def should_check(name: str): + return "all" in checks or name in checks + + if should_check("python"): + check_python() + if should_check("misc"): + check_crlf_line_endings() + if should_check("fmt"): + cmd("./tools/fmt --check").fg() + if should_check("clippy"): + cmd("./tools/clippy").fg() if __name__ == "__main__":