crosvm/ci/kokoro/common.sh
Dennis Kempin 0dbb9808a6 Add Kokoro for ci/builders
Adds the crosvm-side infrastructure to build and test
in kokoro.
There is a build script for testing on x86, aarch64
and a separte script for analysis (clippy, fmt).
These will run in parallel on Kokoro. To test the
scripts locally, a simulate script is provided.

Runtime on my workstation:
- aarch64: 10m
- x86: 2:30m
- analysis: 1:40m

BUG=b:177951955
TEST=./ci/kokoro/simulate_all

Change-Id: I2f666ec768e6c3391a258dc7f0cbd999ad9b2fb1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2654413
Tested-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
2021-02-05 03:01:55 +00:00

58 lines
1.7 KiB
Bash
Executable file

#!/bin/bash
# Copyright 2021 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.
crosvm_root="${KOKORO_ARTIFACTS_DIR}"/git/crosvm
setup_source() {
if [ -z "${KOKORO_ARTIFACTS_DIR}" ]; then
echo "This script must be run in kokoro"
exit 1
fi
cd "${KOKORO_ARTIFACTS_DIR}"
echo ""
echo "Downloading crosvm dependencies to $(pwd)/cros..."
mkdir cros
cd cros
# repo gets confused by pyenv, make sure we select 3.6.1 as our default
# version.
if command -v pyenv; then
echo "Selecting Python 3.6.1"
pyenv global 3.6.1
fi
curl -s https://storage.googleapis.com/git-repo-downloads/repo >repo
chmod +x repo
./repo init --depth 1 -u https://chromium.googlesource.com/chromiumos/manifest.git \
--repo-url https://chromium.googlesource.com/external/repo.git -g crosvm || return 1
./repo sync -j8 -c -m "${crosvm_root}/ci/kokoro/manifest.xml" || return 1
# Bind mount source into cros checkout.
echo ""
echo "Mounting crosvm source to $(pwd)/src/platform/crosvm..."
rm -rf src/platform/crosvm && mkdir -p src/platform/crosvm
if command -v bindfs; then
bindfs "${crosvm_root}" src/platform/crosvm || return 1
else
sudo mount --bind "${crosvm_root}" src/platform/crosvm || return 1
fi
}
cleanup() {
if command -v bindfs; then
fusermount -uz "${KOKORO_ARTIFACTS_DIR}/cros/src/platform/crosvm"
else
sudo umount --lazy "${KOKORO_ARTIFACTS_DIR}/cros/src/platform/crosvm"
fi
}
# Setup source when the script is loaded. Clean up on exit.
trap cleanup EXIT
setup_source || {
echo "Failed to setup_source"
exit 1
}
cd "${KOKORO_ARTIFACTS_DIR}/cros/src/platform/crosvm"