infra: Use depot_tools for repo and cros_sdk

The builders do not have depot_tools installed globally, but
the recipes checkout contains them, so look up the proper
paths to the tools.

BUG=b:233913797
TEST=./recipes.py run build_chromeos

Change-Id: I5d50871fa0ccee769704b339a20d3406d23e0510
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3674216
Reviewed-by: Anton Romanov <romanton@google.com>
Tested-by: Dennis Kempin <denniskempin@google.com>
This commit is contained in:
Dennis Kempin 2022-05-27 18:19:30 +00:00
parent cadc84b32a
commit 507ac947ae
4 changed files with 55 additions and 22 deletions

View file

@ -13,7 +13,7 @@ directory in the same commit as changes to other crosvm source.
A few links to relevant documentation needed to write recipes:
- [Recipe Engine](https://chromium.googlesource.com/infra/luci/recipes-py.git/+/HEAD/README.recipes.md)
- [Depot Tools Recipes](https://chromium.googlesource.com/chromium/tools/depot_tools.git/+/HEAD/README.recipes.md))
- [Depot Tools Recipes](https://chromium.googlesource.com/chromium/tools/depot_tools.git/+/HEAD/recipes/README.recipes.md))
- [ChromiumOS Recipes](https://chromium.googlesource.com/chromiumos/infra/recipes.git/+/HEAD/README.recipes.md)
Luci also provides a

View file

@ -43,19 +43,19 @@ Runs a luci step inside the crosvm dev container.
### *recipes* / [build\_chromeos](/infra/recipes/build_chromeos.py)
[DEPS](/infra/recipes/build_chromeos.py#9): [crosvm](#recipe_modules-crosvm), [recipe\_engine/buildbucket][recipe_engine/recipe_modules/buildbucket], [recipe\_engine/context][recipe_engine/recipe_modules/context], [recipe\_engine/file][recipe_engine/recipe_modules/file], [recipe\_engine/path][recipe_engine/recipe_modules/path], [recipe\_engine/properties][recipe_engine/recipe_modules/properties], [recipe\_engine/step][recipe_engine/recipe_modules/step]
[DEPS](/infra/recipes/build_chromeos.py#9): [crosvm](#recipe_modules-crosvm), [depot\_tools/depot\_tools][depot_tools/recipe_modules/depot_tools], [recipe\_engine/buildbucket][recipe_engine/recipe_modules/buildbucket], [recipe\_engine/context][recipe_engine/recipe_modules/context], [recipe\_engine/file][recipe_engine/recipe_modules/file], [recipe\_engine/path][recipe_engine/recipe_modules/path], [recipe\_engine/properties][recipe_engine/recipe_modules/properties], [recipe\_engine/step][recipe_engine/recipe_modules/step]
PYTHON_VERSION_COMPATIBILITY: PY3
&mdash; **def [BuildAndTest](/infra/recipes/build_chromeos.py#73)(api, board):**
&mdash; **def [BuildAndTest](/infra/recipes/build_chromeos.py#76)(api, board):**
&mdash; **def [CleanUp](/infra/recipes/build_chromeos.py#85)(api):**
&mdash; **def [CleanUp](/infra/recipes/build_chromeos.py#89)(api):**
&mdash; **def [PrepareBuild](/infra/recipes/build_chromeos.py#59)(api):**
&mdash; **def [PrepareBuild](/infra/recipes/build_chromeos.py#61)(api):**
&mdash; **def [RunSteps](/infra/recipes/build_chromeos.py#89)(api, properties):**
&mdash; **def [RunSteps](/infra/recipes/build_chromeos.py#94)(api, properties):**
&mdash; **def [SetupSource](/infra/recipes/build_chromeos.py#26)(api, workspace):**
&mdash; **def [SetupSource](/infra/recipes/build_chromeos.py#27)(api, workspace):**
### *recipes* / [build\_linux](/infra/recipes/build_linux.py)
[DEPS](/infra/recipes/build_linux.py#11): [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]
@ -90,6 +90,7 @@ PYTHON_VERSION_COMPATIBILITY: PY3
&mdash; **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/depot_tools]: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+/8a87603683bda769d437e48cc1a7494a2e237ead/recipes/README.recipes.md#recipe_modules-depot_tools
[depot_tools/recipe_modules/gclient]: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+/8a87603683bda769d437e48cc1a7494a2e237ead/recipes/README.recipes.md#recipe_modules-gclient
[recipe_engine/recipe_modules/buildbucket]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/7b42800366a15f34b28e62f6bcb1cddcb2206db0/README.recipes.md#recipe_modules-buildbucket
[recipe_engine/recipe_modules/context]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/7b42800366a15f34b28e62f6bcb1cddcb2206db0/README.recipes.md#recipe_modules-context

View file

@ -16,7 +16,7 @@
},
{
"cmd": [
"repo",
"RECIPE_REPO[depot_tools]/repo",
"init",
"--manifest-url=https://chromium.googlesource.com/chromiumos/manifest",
"--manifest-branch=stable",
@ -25,15 +25,21 @@
"--groups=minilayout,crosvm"
],
"cwd": "[CLEANUP]/workspace",
"env": {
"DEPOT_TOOLS_UPDATE": "0"
},
"name": "Init repo"
},
{
"cmd": [
"repo",
"RECIPE_REPO[depot_tools]/repo",
"sync",
"--current-branch"
],
"cwd": "[CLEANUP]/workspace",
"env": {
"DEPOT_TOOLS_UPDATE": "0"
},
"name": "Sync repo"
},
{
@ -43,6 +49,9 @@
"https://chromium.googlesource.com/crosvm/crosvm"
],
"cwd": "[CLEANUP]/workspace/src/platform/crosvm",
"env": {
"DEPOT_TOOLS_UPDATE": "0"
},
"name": "Fetch upstream crosvm"
},
{
@ -52,6 +61,9 @@
"HEAD"
],
"cwd": "[CLEANUP]/workspace/src/platform/crosvm",
"env": {
"DEPOT_TOOLS_UPDATE": "0"
},
"name": "Checkout upstream revision"
},
{
@ -61,44 +73,59 @@
"--overlay-type=public"
],
"cwd": "[CLEANUP]/workspace",
"env": {
"DEPOT_TOOLS_UPDATE": "0"
},
"name": "Uprev packages"
},
{
"cmd": [
"cros_sdk",
"RECIPE_REPO[depot_tools]/cros_sdk",
"--create"
],
"cwd": "[CLEANUP]/workspace",
"env": {
"DEPOT_TOOLS_UPDATE": "0"
},
"name": "Create SDK chroot"
},
{
"cmd": [
"cros_sdk",
"RECIPE_REPO[depot_tools]/cros_sdk",
"build_packages",
"--board=amd64_generic",
"implicit-system",
"chromeos-base/crosvm"
],
"cwd": "[CLEANUP]/workspace",
"env": {
"DEPOT_TOOLS_UPDATE": "0"
},
"name": "Build packages"
},
{
"cmd": [
"cros_sdk",
"RECIPE_REPO[depot_tools]/cros_sdk",
"cros_run_unit_tests",
"--board=amd64_generic",
"implicit-system",
"chromeos-base/crosvm"
],
"cwd": "[CLEANUP]/workspace",
"env": {
"DEPOT_TOOLS_UPDATE": "0"
},
"name": "Run unit tests"
},
{
"cmd": [
"cros_sdk",
"RECIPE_REPO[depot_tools]/cros_sdk",
"--delete"
],
"cwd": "[CLEANUP]/workspace",
"env": {
"DEPOT_TOOLS_UPDATE": "0"
},
"name": "Deleting SDK chroot"
},
{

View file

@ -8,12 +8,13 @@ PYTHON_VERSION_COMPATIBILITY = "PY3"
DEPS = [
"crosvm",
"depot_tools/depot_tools",
"recipe_engine/buildbucket",
"recipe_engine/context",
"recipe_engine/file",
"recipe_engine/path",
"recipe_engine/properties",
"recipe_engine/step",
"recipe_engine/path",
"recipe_engine/file",
]
PROPERTIES = BuildChromeOsProperties
@ -24,6 +25,7 @@ PACKAGE_LIST = [
def SetupSource(api, workspace):
repo = api.depot_tools.repo_resource("repo")
gitilies = api.buildbucket.build.input.gitiles_commit
upstream_url = "https://chromium.googlesource.com/crosvm/crosvm"
revision = gitilies.id or "HEAD"
@ -32,7 +34,7 @@ def SetupSource(api, workspace):
api.step(
"Init repo",
[
"repo",
repo,
"init",
"--manifest-url=https://chromium.googlesource.com/chromiumos/manifest",
"--manifest-branch=stable",
@ -44,7 +46,7 @@ def SetupSource(api, workspace):
api.step(
"Sync repo",
[
"repo",
repo,
"sync",
"--current-branch",
],
@ -67,30 +69,33 @@ def PrepareBuild(api):
],
)
# Create chroot as a separate step to document the runtime
api.step("Create SDK chroot", ["cros_sdk", "--create"])
cros_sdk = api.depot_tools.repo_resource("cros_sdk")
api.step("Create SDK chroot", [cros_sdk, "--create"])
def BuildAndTest(api, board):
cros_sdk = api.depot_tools.repo_resource("cros_sdk")
# TODO: We currently build crosvm twice. Once with build_packages, once to run tests.
api.step(
"Build packages",
["cros_sdk", "build_packages", "--board=%s" % board, "implicit-system"] + PACKAGE_LIST,
[cros_sdk, "build_packages", "--board=%s" % board, "implicit-system"] + PACKAGE_LIST,
)
api.step(
"Run unit tests",
["cros_sdk", "cros_run_unit_tests", "--board=%s" % board, "implicit-system"] + PACKAGE_LIST,
[cros_sdk, "cros_run_unit_tests", "--board=%s" % board, "implicit-system"] + PACKAGE_LIST,
)
def CleanUp(api):
api.step("Deleting SDK chroot", ["cros_sdk", "--delete"])
cros_sdk = api.depot_tools.repo_resource("cros_sdk")
api.step("Deleting SDK chroot", [cros_sdk, "--delete"])
def RunSteps(api, properties):
workspace = api.path["cleanup"].join("workspace")
api.file.ensure_directory("Ensure workspace exists", workspace)
with api.context(cwd=workspace):
with api.context(cwd=workspace, env={"DEPOT_TOOLS_UPDATE": "0"}):
try:
SetupSource(api, workspace)
PrepareBuild(api)