mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-05 02:02:52 +00:00
ba4adc0efb
This change adds python type and formatting checks and consolidates code health checks in ./tools/health-check. Dealing with relative imports in python is tricky, so we are making ./tools/impl a proper package with no directly executable files. Some of the bash shorthands in ./tools had to be converted to python for this. To make the new checks pass, we run the formatter and fix some mypy type checks. TEST=./tools/health-check BUG=b:218559722,b:219965702 Change-Id: Ie18d3d6dd2f5a033141e167a6e1aa762791941d6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3558592 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Dennis Kempin <denniskempin@google.com>
55 lines
1.5 KiB
Python
Executable file
55 lines
1.5 KiB
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.
|
|
|
|
from pathlib import Path
|
|
import argparse
|
|
import os
|
|
import subprocess
|
|
import tempfile
|
|
|
|
USAGE = """
|
|
Simulates a Kokoro run executing one of the build-* scripts.
|
|
|
|
Example:
|
|
$ cd ./ci/kokoro
|
|
$ ./simulate.py build-aarch64.sh
|
|
"""
|
|
|
|
CROSVM_ROOT = Path(__file__).parent.parent.parent.resolve()
|
|
|
|
|
|
def git_clone_source(source: Path, destination: Path):
|
|
destination.mkdir(parents=True, exist_ok=True)
|
|
print(f"Cloning {source} into {destination}:")
|
|
subprocess.check_call(["git", "clone", "-q", source, destination])
|
|
|
|
|
|
def run_kokoro_build_script(kokoro_root: Path, script_path: Path):
|
|
print(f"Running {script_path}:")
|
|
env = os.environ.copy()
|
|
env["KOKORO_ARTIFACTS_DIR"] = str(kokoro_root / "src")
|
|
subprocess.check_call([script_path.resolve()], cwd=kokoro_root, env=env)
|
|
|
|
|
|
def simulate_kokoro(kokoro_root: Path, script_path: Path):
|
|
git_clone_source(CROSVM_ROOT, kokoro_root / "src/git/crosvm")
|
|
run_kokoro_build_script(kokoro_root, script_path)
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(usage=USAGE)
|
|
parser.add_argument("script_name", type=Path)
|
|
args = parser.parse_args()
|
|
|
|
script_path: Path = args.script_name
|
|
if not script_path.exists():
|
|
raise ValueError(f"Script '{script_path} not found.")
|
|
|
|
with tempfile.TemporaryDirectory() as temp_dir:
|
|
simulate_kokoro(Path(temp_dir), script_path)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|