From cb99b70b1d9742c597abc447de985e3b18d4f2db Mon Sep 17 00:00:00 2001 From: Dennis Kempin Date: Wed, 25 May 2022 21:21:31 +0000 Subject: [PATCH] infra: Add health check builder The builder calls ./tools/health-check for fmt/clippy/python checks. BUG=b:233913455 TEST=recipes.py run health_check Change-Id: Ia4b8298ef921b33a687d4e64956fc1f017649e7f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3668814 Tested-by: kokoro Reviewed-by: Daniel Verkamp --- infra/README.recipes.md | 8 ++ .../recipes/health_check.expected/basic.json | 90 +++++++++++++++++++ infra/recipes/health_check.py | 34 +++++++ 3 files changed, 132 insertions(+) create mode 100644 infra/recipes/health_check.expected/basic.json create mode 100644 infra/recipes/health_check.py diff --git a/infra/README.recipes.md b/infra/README.recipes.md index 602b8a1459..06ebca5d22 100644 --- a/infra/README.recipes.md +++ b/infra/README.recipes.md @@ -9,6 +9,7 @@ * [build_linux](#recipes-build_linux) (Python3 ✅) * [crosvm:examples/container](#recipes-crosvm_examples_container) (Python3 ✅) * [crosvm:examples/prepare_source](#recipes-crosvm_examples_prepare_source) (Python3 ✅) + * [health_check](#recipes-health_check) (Python3 ✅) ## Recipe Modules ### *recipe_modules* / [crosvm](/infra/recipe_modules/crosvm) @@ -64,6 +65,13 @@ PYTHON_VERSION_COMPATIBILITY: PY3 PYTHON_VERSION_COMPATIBILITY: PY3 — **def [RunSteps](/infra/recipe_modules/crosvm/examples/prepare_source.py#18)(api):** +### *recipes* / [health\_check](/infra/recipes/health_check.py) + +[DEPS](/infra/recipes/health_check.py#10): [crosvm](#recipe_modules-crosvm), [recipe\_engine/buildbucket][recipe_engine/recipe_modules/buildbucket], [recipe\_engine/context][recipe_engine/recipe_modules/context], [recipe\_engine/properties][recipe_engine/recipe_modules/properties], [recipe\_engine/step][recipe_engine/recipe_modules/step] + +PYTHON_VERSION_COMPATIBILITY: PY3 + +— **def [RunSteps](/infra/recipes/health_check.py#19)(api):** [depot_tools/recipe_modules/bot_update]: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+/8a87603683bda769d437e48cc1a7494a2e237ead/recipes/README.recipes.md#recipe_modules-bot_update [depot_tools/recipe_modules/gclient]: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+/8a87603683bda769d437e48cc1a7494a2e237ead/recipes/README.recipes.md#recipe_modules-gclient diff --git a/infra/recipes/health_check.expected/basic.json b/infra/recipes/health_check.expected/basic.json new file mode 100644 index 0000000000..5b3d6446c7 --- /dev/null +++ b/infra/recipes/health_check.expected/basic.json @@ -0,0 +1,90 @@ +[ + { + "cmd": [ + "./tools/dev_container", + "--verbose", + "./tools/health-check", + "python" + ], + "cwd": "[CACHE]/builder/crosvm", + "luci_context": { + "realm": { + "name": "crosvm/crosvm:ci" + }, + "resultdb": { + "current_invocation": { + "name": "invocations/build:8945511751514863184", + "update_token": "token" + }, + "hostname": "rdbhost" + } + }, + "name": "Checking python" + }, + { + "cmd": [ + "./tools/dev_container", + "--verbose", + "./tools/health-check", + "misc" + ], + "cwd": "[CACHE]/builder/crosvm", + "luci_context": { + "realm": { + "name": "crosvm/crosvm:ci" + }, + "resultdb": { + "current_invocation": { + "name": "invocations/build:8945511751514863184", + "update_token": "token" + }, + "hostname": "rdbhost" + } + }, + "name": "Checking misc" + }, + { + "cmd": [ + "./tools/dev_container", + "--verbose", + "./tools/health-check", + "fmt" + ], + "cwd": "[CACHE]/builder/crosvm", + "luci_context": { + "realm": { + "name": "crosvm/crosvm:ci" + }, + "resultdb": { + "current_invocation": { + "name": "invocations/build:8945511751514863184", + "update_token": "token" + }, + "hostname": "rdbhost" + } + }, + "name": "Checking fmt" + }, + { + "cmd": [ + "./tools/dev_container", + "--verbose", + "./tools/health-check", + "clippy" + ], + "cwd": "[CACHE]/builder/crosvm", + "luci_context": { + "realm": { + "name": "crosvm/crosvm:ci" + }, + "resultdb": { + "current_invocation": { + "name": "invocations/build:8945511751514863184", + "update_token": "token" + }, + "hostname": "rdbhost" + } + }, + "name": "Checking clippy" + } +] \ No newline at end of file diff --git a/infra/recipes/health_check.py b/infra/recipes/health_check.py new file mode 100644 index 0000000000..8b083e82af --- /dev/null +++ b/infra/recipes/health_check.py @@ -0,0 +1,34 @@ +# 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. + +import re +from recipe_engine.post_process import Filter + +PYTHON_VERSION_COMPATIBILITY = "PY3" + +DEPS = [ + "crosvm", + "recipe_engine/buildbucket", + "recipe_engine/context", + "recipe_engine/properties", + "recipe_engine/step", +] + + +def RunSteps(api): + api.crosvm.prepare_source() + api.crosvm.prepare_container() + with api.context(cwd=api.crosvm.source_dir): + for check in ("python", "misc", "fmt", "clippy"): + api.crosvm.step_in_container("Checking %s" % check, ["./tools/health-check", check]) + + +def GenTests(api): + yield ( + api.test( + "basic", + api.buildbucket.ci_build(project="crosvm/crosvm"), + ) + + api.post_process(Filter().include_re(r"Checking.*")) + )