mirror of
https://github.com/lima-vm/lima.git
synced 2026-10-28 11:44:35 +08:00
CI: add upgrade test
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
This commit is contained in:
6 files changed
+166
-37
No files matched your search
@@ -140,6 +140,35 @@ jobs:
|
||||
# GHA macOS is slow and flaky, so we only test a few YAMLS here.
|
||||
# Other yamls are tested on Linux instances of Cirrus.
|
||||
|
||||
upgrade:
|
||||
name: "Upgrade test"
|
||||
runs-on: macos-11
|
||||
timeout-minutes: 120
|
||||
strategy:
|
||||
matrix:
|
||||
oldver: ["v0.8.0"]
|
||||
steps:
|
||||
- uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.17.x
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Install test dependencies
|
||||
run: brew install qemu bash coreutils
|
||||
- name: Cache ~/Library/Caches/lima/download
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/Library/Caches/lima/download
|
||||
key: ${{ runner.os }}-upgrade-${{ matrix.oldver }}
|
||||
- name: Test
|
||||
uses: nick-invision/retry@v2
|
||||
with:
|
||||
timeout_minutes: 30
|
||||
retry_on: error
|
||||
max_attempts: 3
|
||||
command: ./hack/test-upgrade.sh ${{ matrix.oldver }} ${{ github.sha }}
|
||||
|
||||
artifacts-darwin:
|
||||
name: Artifacts Darwin
|
||||
runs-on: macos-11
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
source-path=SCRIPTDIR
|
||||
@@ -0,0 +1,24 @@
|
||||
# shellcheck shell=bash
|
||||
cleanup_cmd=""
|
||||
trap 'eval ${cleanup_cmd}' EXIT
|
||||
function defer {
|
||||
[ -n "${cleanup_cmd}" ] && cleanup_cmd="${cleanup_cmd}; "
|
||||
cleanup_cmd="${cleanup_cmd}$1"
|
||||
}
|
||||
|
||||
function INFO() {
|
||||
echo "TEST| [INFO] $*"
|
||||
}
|
||||
|
||||
function WARNING() {
|
||||
echo >&2 "TEST| [WARNING] $*"
|
||||
}
|
||||
|
||||
function ERROR() {
|
||||
echo >&2 "TEST| [ERROR] $*"
|
||||
}
|
||||
|
||||
if [[ ${BASH_VERSINFO:-0} -lt 4 ]]; then
|
||||
ERROR "Bash version is too old: ${BASH_VERSION}"
|
||||
exit 1
|
||||
fi
|
||||
+3
-37
@@ -2,30 +2,8 @@
|
||||
set -eu -o pipefail
|
||||
|
||||
scriptdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
cleanup_cmd=""
|
||||
trap 'eval ${cleanup_cmd}' EXIT
|
||||
function defer {
|
||||
[ -n "${cleanup_cmd}" ] && cleanup_cmd="${cleanup_cmd}; "
|
||||
cleanup_cmd="${cleanup_cmd}$1"
|
||||
}
|
||||
|
||||
function INFO() {
|
||||
echo "TEST| [INFO] $*"
|
||||
}
|
||||
|
||||
function WARNING() {
|
||||
echo >&2 "TEST| [WARNING] $*"
|
||||
}
|
||||
|
||||
function ERROR() {
|
||||
echo >&2 "TEST| [ERROR] $*"
|
||||
}
|
||||
|
||||
if [[ ${BASH_VERSINFO:-0} -lt 4 ]]; then
|
||||
ERROR "Bash version is too old: ${BASH_VERSION}"
|
||||
exit 1
|
||||
fi
|
||||
# shellcheck source=common.inc.sh
|
||||
source "${scriptdir}/common.inc.sh"
|
||||
|
||||
if [ "$#" -ne 1 ]; then
|
||||
ERROR "Usage: $0 FILE.yaml"
|
||||
@@ -153,19 +131,7 @@ if [[ -n ${CHECKS["systemd"]} ]]; then
|
||||
fi
|
||||
|
||||
if [[ -n ${CHECKS["mount-home"]} ]]; then
|
||||
hometmp="$HOME/lima-test-tmp"
|
||||
INFO "Testing home access (\"$hometmp\")"
|
||||
rm -rf "$hometmp"
|
||||
mkdir -p "$hometmp"
|
||||
defer "rm -rf \"$hometmp\""
|
||||
echo "random-content-${RANDOM}" >"$hometmp/random"
|
||||
expected="$(cat "$hometmp/random")"
|
||||
got="$(limactl shell "$NAME" cat "$hometmp/random")"
|
||||
INFO "$hometmp/random: expected=${expected}, got=${got}"
|
||||
if [ "$got" != "$expected" ]; then
|
||||
ERROR "Home directory is not shared?"
|
||||
exit 1
|
||||
fi
|
||||
"${scriptdir}"/test-mount-home.sh "$NAME"
|
||||
fi
|
||||
|
||||
# Use GHCR to avoid hitting Docker Hub rate limit
|
||||
|
||||
Executable
+26
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eu -o pipefail
|
||||
|
||||
scriptdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
# shellcheck source=common.inc.sh
|
||||
source "${scriptdir}/common.inc.sh"
|
||||
|
||||
if [ "$#" -ne 1 ]; then
|
||||
ERROR "Usage: $0 NAME"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
NAME="$1"
|
||||
hometmp="$HOME/lima-test-tmp"
|
||||
INFO "Testing home access (\"$hometmp\")"
|
||||
rm -rf "$hometmp"
|
||||
mkdir -p "$hometmp"
|
||||
defer "rm -rf \"$hometmp\""
|
||||
echo "random-content-${RANDOM}" >"$hometmp/random"
|
||||
expected="$(cat "$hometmp/random")"
|
||||
got="$(limactl shell "$NAME" cat "$hometmp/random")"
|
||||
INFO "$hometmp/random: expected=${expected}, got=${got}"
|
||||
if [ "$got" != "$expected" ]; then
|
||||
ERROR "Home directory is not shared?"
|
||||
exit 1
|
||||
fi
|
||||
Executable
+83
@@ -0,0 +1,83 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eu -o pipefail
|
||||
|
||||
scriptdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
# shellcheck source=common.inc.sh
|
||||
source "${scriptdir}/common.inc.sh"
|
||||
cd "${scriptdir}/.."
|
||||
|
||||
if [ "$#" -ne 2 ]; then
|
||||
ERROR "Usage: $0 OLDVER NEWVER"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
OLDVER="$1"
|
||||
NEWVER="$2"
|
||||
|
||||
PREFIX="/usr/local"
|
||||
function install_lima() {
|
||||
ver="$1"
|
||||
git checkout "${ver}"
|
||||
make clean
|
||||
make
|
||||
if [ -w "${PREFIX}/bin" ] && [ -w "${PREFIX}/share" ]; then
|
||||
make install
|
||||
else
|
||||
sudo make install
|
||||
fi
|
||||
}
|
||||
|
||||
function uninstall_lima() {
|
||||
files="${PREFIX}/bin/lima ${PREFIX}/bin/limactl ${PREFIX}/share/lima ${PREFIX}/share/doc/lima"
|
||||
if [ -w "${PREFIX}/bin" ] && [ -w "${PREFIX}/share" ]; then
|
||||
# shellcheck disable=SC2086
|
||||
rm -rf $files
|
||||
else
|
||||
# shellcheck disable=SC2086
|
||||
sudo rm -rf $files
|
||||
fi
|
||||
}
|
||||
|
||||
INFO "Uninstalling lima"
|
||||
uninstall_lima
|
||||
|
||||
INFO "Installing the old Lima ${OLDVER}"
|
||||
install_lima "${OLDVER}"
|
||||
|
||||
export LIMA_INSTANCE="test-upgrade"
|
||||
|
||||
INFO "Creating an instance \"${LIMA_INSTANCE}\" with the old Lima"
|
||||
defer "limactl delete -f \"${LIMA_INSTANCE}\""
|
||||
limactl start --tty=false "${LIMA_INSTANCE}"
|
||||
lima nerdctl info
|
||||
|
||||
image_name="lima-test-upgrade-containerd-${RANDOM}"
|
||||
image_context="${HOME}/${image_name}"
|
||||
INFO "Building containerd image \"${image_name}\" from \"${image_context}\""
|
||||
defer "rm -rf \"${image_context}\""
|
||||
mkdir -p "${image_context}"
|
||||
cat <<EOF >"${image_context}"/Dockerfile
|
||||
# Use GHCR to avoid hitting Docker Hub rate limit
|
||||
FROM ghcr.io/containerd/alpine:3.14.0
|
||||
CMD ["echo", "Built with Lima ${OLDVER}"]
|
||||
EOF
|
||||
lima nerdctl build -t "${image_name}" "${image_context}"
|
||||
lima nerdctl run --rm "${image_name}"
|
||||
|
||||
INFO "Stopping the instance"
|
||||
limactl stop "${LIMA_INSTANCE}"
|
||||
|
||||
INFO "=============================================================================="
|
||||
|
||||
INFO "Installing the new Lima ${NEWVER}"
|
||||
install_lima "${NEWVER}"
|
||||
|
||||
INFO "Restarting the instance"
|
||||
limactl start --tty=false "${LIMA_INSTANCE}"
|
||||
lima nerdctl info
|
||||
|
||||
INFO "Confirming that the host filesystem is still mounted"
|
||||
"${scriptdir}"/test-mount-home.sh "${LIMA_INSTANCE}"
|
||||
|
||||
INFO "Confirming that the image \"${image_name}\" still exists"
|
||||
lima nerdctl run --rm "${image_name}"
|
||||
Reference in new issue
Block a user