blob: cc3039a3b776943373e203ad2a48b2346b1947ce [file] [edit]
# reusable workflow
name: .vm
# TODO: hide reusable workflow from the UI. Tracked in https://github.com/community/community/discussions/12025
permissions:
contents: read
on:
workflow_call:
inputs:
template:
required: true
type: string
integration_dir:
description: If set, only run integration tests from these directories (space-separated)
required: false
type: string
default: ""
env:
GO_VERSION: "1.26.10"
TESTSTAT_VERSION: v0.1.25
TEMPLATE_NAME: ${{ inputs.template }}
jobs:
integration:
runs-on: ubuntu-26.04
timeout-minutes: 60
continue-on-error: ${{ github.event_name != 'pull_request' }}
if: ${{ github.event_name != 'pull_request' || !contains(github.event.pull_request.labels.*.name, 'ci/validate-only') }}
strategy:
fail-fast: false
matrix:
mode:
- ""
- rootless
steps:
-
name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
-
name: Build integration test dependencies
uses: docker/bake-action@018cb6412ab401ebaa809aa5f85966b74628600f # v7.4.0
with:
targets: test-integration-deps
-
name: Set up Lima
uses: lima-vm/lima-actions/setup@55627e31b78637bf254a8b2a14da8ea7d12564e5 # v1.1.0
id: lima-actions-setup
with:
version: v2.2.0
-
name: Cache ~/.cache/lima
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.cache/lima
key: lima-${{ steps.lima-actions-setup.outputs.version }}-${{ inputs.template }}
-
name: Start the guest VM
run: |
set -eux -o pipefail
host_memory_gib=$(awk '/MemTotal/ { print int($2 / 1024 / 1024) }' /proc/meminfo)
lima_memory=$((host_memory_gib - 2))
echo "Lima memory: ${lima_memory} GiB (${host_memory_gib} GiB detected)" >>"${GITHUB_STEP_SUMMARY}"
if [ $lima_memory -lt 1 ]; then
echo "::error::Too little memory!"
exit 2
fi
# --plain is set because the built-in containerd support conflicts with Docker
limactl start \
--name=default \
--memory=${lima_memory} \
--plain \
${INPUTS_TEMPLATE}
env:
INPUTS_TEMPLATE: ${{ inputs.template }}
-
name: Load kernel modules in the guest VM
run: |
lima sudo bash < hack/host/load-kernel-modules.sh
-
name: Install integration test dependencies in the guest VM
run: |
set -eux -o pipefail
lima sudo bash < hack/host/provision.sh
mv bundles/test-integration-deps "${RUNNER_TEMP}/test-integration-deps"
# BuildKit also creates bundles/ with mode 0700, which the harness
# preserves when cleaning its contents. Test daemons need to traverse it.
chmod 0755 bundles
# BuildKit's local exporter creates the output directory with mode 0700
# and assigns files to the runner. Preserve guest directory metadata,
# especially /, and install the dependencies as root.
tar -C "${RUNNER_TEMP}/test-integration-deps" -c . | lima sudo tar -C / -x --no-same-owner --no-overwrite-dir
-
name: Copy the current directory
run: |
set -eux -o pipefail
# /var/tmp, not /tmp: the latter is a tmpfs on some distributions
# (SUSE), which is too small for the test daemons' data roots and
# would consume the guest's memory.
limactl cp -r . default:/var/tmp/docker
# The checkout belongs to the login user, while Go builds run as root.
lima sudo git config --global --add safe.directory /var/tmp/docker
-
name: Test
run: |
set -eux -o pipefail
DOCKER_ROOTLESS=
DOCKER_GRAPHDRIVER=overlay2
if [[ "${{ matrix.mode }}" == *"rootless"* ]]; then
DOCKER_ROOTLESS=1
if lima grep -q "AlmaLinux release 8" /etc/system-release; then
# kernel prior to 5.11 needs fuse-overlayfs
DOCKER_GRAPHDRIVER=fuse-overlayfs
fi
# The absolute path is needed because /usr/sbin is not in the
# login user's PATH on all distributions.
if lima /usr/sbin/selinuxenabled; then
# Rootless overlay2 is unsupported with SELinux.
DOCKER_GRAPHDRIVER=fuse-overlayfs
fi
fi
DOCKER_IGNORE_BR_NETFILTER_ERROR=
if lima grep -q "AlmaLinux release 8" /etc/system-release; then
# DOCKER_IGNORE_BR_NETFILTER_ERROR=1 is set because /proc/sys/net/bridge does not appear in
# a container when the kernel is older than 5.3.
# https://web.archive.org/web/20201123224428/github.com/lxc/lxd/issues/3306#issuecomment-502857864
DOCKER_IGNORE_BR_NETFILTER_ERROR=1
fi
# TODO: just propagate the env from the host: https://github.com/lima-vm/lima/issues/3430
# TODO: enable GHA cache?
LIMA_WORKDIR=/var/tmp/docker lima sudo env \
PATH=/usr/local/go/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin \
DOCKER_GITCOMMIT="${GITHUB_SHA}" \
GITHUB_ACTIONS="${GITHUB_ACTIONS}" \
TEST_SKIP_INTEGRATION_CLI=1 \
TEST_INTEGRATION_DIR="${INPUTS_INTEGRATION_DIR}" \
TEST_INTEGRATION_USE_GRAPHDRIVER=1 \
DOCKER_ROOTLESS=${DOCKER_ROOTLESS} \
DOCKER_GRAPHDRIVER=${DOCKER_GRAPHDRIVER} \
DOCKER_IGNORE_BR_NETFILTER_ERROR=${DOCKER_IGNORE_BR_NETFILTER_ERROR} \
TIMEOUT=15m \
hack/make.sh dynbinary test-integration
env:
INPUTS_INTEGRATION_DIR: ${{ inputs.integration_dir }}
-
name: Prepare reports
if: always()
run: |
set -eux -o pipefail
# Specify --backend=scp to avoid an issue with rsync preinstalled in openSUSE
# Workaround for https://github.com/lima-vm/lima/issues/5500
limactl cp --backend=scp -v -r default:/var/tmp/docker/bundles . || true
reportsName="${{ env.TEMPLATE_NAME }}"
reportsName="${reportsName#template:}"
# Artifact names cannot contain "/", which appears in template
# locators such as "experimental/opensuse-tumbleweed".
reportsName="${reportsName//\//-}"
if [ -n "${{ matrix.mode }}" ]; then
reportsName="$reportsName-${{ matrix.mode }}"
fi
reportsPath="/tmp/reports/$reportsName"
echo "TESTREPORTS_NAME=$reportsName" >> $GITHUB_ENV
mkdir -p bundles $reportsPath
find bundles \( -path '*/root' -o -path '*/root/*' \) -prune -o -type f \( -name '*-report.json' -o -name '*.log' -o -name '*.out' -o -name '*.prof' -o -name '*-report.xml' \) -print0 | sudo tar --null --files-from=- -czf /tmp/reports.tar.gz
tar -xzf /tmp/reports.tar.gz -C $reportsPath
sudo chown -R $(id -u):$(id -g) $reportsPath
tree -nh $reportsPath
-
name: Test daemon logs
if: always()
run: |
cat bundles/test-integration/docker.log
-
name: Upload reports
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: test-reports-integration-${{ env.TESTREPORTS_NAME }}
path: /tmp/reports/*
retention-days: 1
integration-report:
runs-on: ubuntu-26.04
timeout-minutes: 10
continue-on-error: ${{ github.event_name != 'pull_request' }}
if: always() && (github.event_name != 'pull_request' || !contains(github.event.pull_request.labels.*.name, 'ci/validate-only'))
needs:
- integration
steps:
-
name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: ${{ env.GO_VERSION }}
cache: false
-
name: Prepare reports
run: |
TEMPLATE="${{ env.TEMPLATE_NAME }}"
TEMPLATE="${TEMPLATE#template:}"
TEMPLATE="${TEMPLATE//\//-}"
echo "TESTREPORTS_NAME=${TEMPLATE}*" >> $GITHUB_ENV
-
name: Download reports
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
path: /tmp/reports
pattern: test-reports-integration-${{ env.TESTREPORTS_NAME }}
merge-multiple: true
-
name: Install teststat
run: |
go install github.com/vearutop/teststat@${{ env.TESTSTAT_VERSION }}
-
name: Create summary
run: |
if [ -d /tmp/reports ]; then
find /tmp/reports -type f -name '*-go-test-report.json' -exec teststat -markdown {} \+ >> "$GITHUB_STEP_SUMMARY"
fi