From 0a581d64efc80d2582b231f16e3c3e8a130a0d85 Mon Sep 17 00:00:00 2001 From: Dennis Kempin Date: Thu, 21 Apr 2022 12:41:05 -0700 Subject: [PATCH] Kokoro: Add ChromeOS post-submit builder This adds an experimental build script that will build crosvm for ChromeOS. This will allow us to catch issues on the ChromeOS build of crosvm earlier in the process. BUG=b:226975041 TEST=./ci/kokoro/simulate.py ./ci/kokoro/build-chromeos.sh Change-Id: I4a1d906a44191e78f4e656fe76c989bd7e1b6977 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3600764 Reviewed-by: Dmitry Torokhov Tested-by: kokoro Commit-Queue: Dennis Kempin --- ci/kokoro/build-chromeos.sh | 70 +++++++++++++++++++++++++++++++ ci/kokoro/continuous-chromeos.cfg | 3 ++ 2 files changed, 73 insertions(+) create mode 100755 ci/kokoro/build-chromeos.sh create mode 100644 ci/kokoro/continuous-chromeos.cfg diff --git a/ci/kokoro/build-chromeos.sh b/ci/kokoro/build-chromeos.sh new file mode 100755 index 0000000000..13212e38ae --- /dev/null +++ b/ci/kokoro/build-chromeos.sh @@ -0,0 +1,70 @@ +#!/bin/bash +# 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. +# +# Note: To simulate this locally, sudo needs to be passwordless for the duration of the build (~1h). +# This could be achieved by refreshing sudo in the background before running ci/simulate.py: +# +# while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null & +# ./ci/kokoro/simulate.py ./ci/kokoro/build-chromeos.sh + +set -ex + +CROS_ROOT="${KOKORO_ARTIFACTS_DIR}/cros" +CROSVM_ROOT="${KOKORO_ARTIFACTS_DIR}/git/crosvm" +DEPOT_TOOLS="${KOKORO_ARTIFACTS_DIR}/depot_tools" + +BOARD="amd64-generic" +# TODO: Add other packages tracking the crosvm repo. +PACKAGE_LIST=( + 'chromeos-base/crosvm' +) + +setup_depot_tools() { + git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git \ + "$DEPOT_TOOLS" + export PATH="${DEPOT_TOOLS}:${PATH}" +} + +setup_cros_source() { + repo init -q -u https://chromium.googlesource.com/chromiumos/manifest \ + -b stable --depth=1 -c -g minilayout,crosvm + time repo sync -c # ~5min + time cros_sdk --create # ~16min +} + +setup_crosvm_source() { + # Pull kokoro's version of crosvm into the cros monorepo + ( + cd "${CROS_ROOT}/src/platform/crosvm" && + git remote add crosvm "$CROSVM_ROOT" && + git fetch crosvm && + git checkout FETCH_HEAD + ) + # Uprev ebuild files + local colon_separated_packages="$(printf '%s:' "${PACKAGE_LIST[@]}")" + ./chromite/scripts/cros_uprev \ + --package="$colon_separated_packages" \ + --overlay-type=public +} + +build_and_test_crosvm() { + # TODO: We currently build crosvm twice. Once with build_packages, once to run tests. + # ~20min + time cros_sdk build_packages --board "$BOARD" implicit-system "${PACKAGE_LIST[@]}" + # ~6min + time cros_sdk cros_run_unit_tests --board "$BOARD" --packages "${PACKAGE_LIST[@]}" +} + +main() { + mkdir -p "$CROS_ROOT" + cd "$CROS_ROOT" + + setup_depot_tools + setup_cros_source + setup_crosvm_source + build_and_test_crosvm +} + +main diff --git a/ci/kokoro/continuous-chromeos.cfg b/ci/kokoro/continuous-chromeos.cfg new file mode 100644 index 0000000000..3dd19582fd --- /dev/null +++ b/ci/kokoro/continuous-chromeos.cfg @@ -0,0 +1,3 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +build_file: "crosvm/ci/kokoro/build-chromeos.sh"