crosvm/tools/fmt
Dennis Kempin 92f804e3f8 tools/health-check: Revamp script to run on git delta only
The updated health-check will by default only run on modified
files. If you do not make changes to python code, python checks
won't run, etc.

The script also simplifies the writing of those checks so we can
start adding more of them.

Luci will be updated to make use of the --list-checks function to
run each check in a separate luci step. In the meantime, we
keep a compatibility layer to translate the old arguments
to the new style.

BUG=b:239255137
TEST=./tools/health-check in all it's variations

Change-Id: I21b986b46c7cfccf3d13f4c76bbd3d0ec7240c26
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3827174
Tested-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-08-15 18:52:02 +00:00

38 lines
839 B
Python
Executable file

#!/usr/bin/env python3
# Copyright 2022 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Run `rustfmt` on all Rust code contained in the crosvm workspace, including
# all commmon/* crates as well.
#
# Usage:
#
# $ bin/fmt
#
# To print a diff and exit 1 if code is not formatted, but without changing any
# files, use:
#
# $ bin/fmt --check
#
from impl.common import (
CROSVM_ROOT,
run_main,
cmd,
chdir,
)
def main(check: bool = False, nightly: bool = False):
chdir(CROSVM_ROOT)
cmd(
"./tools/health-check --all rust_format python_format markdown_format",
"--fix" if not check else None,
"--nightly" if nightly else None,
).fg()
if __name__ == "__main__":
run_main(main)