crosvm/ci/kokoro/simulate.py
Dennis Kempin 1dab58a2cf Update all copyright headers to match new style
This search/replace updates all copyright notices to drop the
"All rights reserved", Use "ChromiumOS" instead of "Chromium OS"
and drops the trailing dots.

This fulfills the request from legal and unifies our notices.

./tools/health-check has been updated to only accept this style.

BUG=b:246579983
TEST=./tools/health-check

Change-Id: I87a80701dc651f1baf4820e5cc42469d7c5f5bf7
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3894243
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-09-13 18:41:29 +00:00

55 lines
1.5 KiB
Python
Executable file

#!/usr/bin/env python3
# Copyright 2022 The ChromiumOS Authors
# 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()