|
| 1 | +# Currently, Lima job test only for EL8, though in the future it could be used to also test FreeBSD |
| 2 | +# EL8 is used for testing compatibility with cgroup v1. |
| 3 | +# Do not upgrade this to EL9 (cgroup v2). |
| 4 | +name: test-in-lima |
| 5 | + |
| 6 | +on: |
| 7 | + workflow_call: |
| 8 | + inputs: |
| 9 | + timeout: |
| 10 | + required: true |
| 11 | + type: number |
| 12 | + runner: |
| 13 | + required: true |
| 14 | + type: string |
| 15 | + |
| 16 | +jobs: |
| 17 | + test: |
| 18 | + name: "${{ matrix.mode }} (cgroup v1)" |
| 19 | + timeout-minutes: ${{ inputs.timeout }} |
| 20 | + runs-on: "${{ inputs.runner }}" |
| 21 | + strategy: |
| 22 | + fail-fast: false |
| 23 | + matrix: |
| 24 | + mode: ["rootful", "rootless"] |
| 25 | + env: |
| 26 | + MODE: ${{ matrix.mode }} |
| 27 | + steps: |
| 28 | + - name: "Init: checkout" |
| 29 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 30 | + with: |
| 31 | + fetch-depth: 1 |
| 32 | + |
| 33 | + - name: "Init: lima" |
| 34 | + uses: lima-vm/lima-actions/setup@be564a1408f84557d067b099a475652288074b2e # v1.0.0 |
| 35 | + id: lima-actions-setup |
| 36 | + |
| 37 | + - name: "Init: Cache" |
| 38 | + uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 |
| 39 | + with: |
| 40 | + path: ~/.cache/lima |
| 41 | + key: lima-${{ steps.lima-actions-setup.outputs.version }} |
| 42 | + |
| 43 | + - name: "Init: start the guest VM" |
| 44 | + run: | |
| 45 | + set -eux |
| 46 | + # containerd=none is set because the built-in containerd support conflicts with Docker |
| 47 | + limactl start \ |
| 48 | + --name=default \ |
| 49 | + --cpus=4 \ |
| 50 | + --memory=12 \ |
| 51 | + --containerd=none \ |
| 52 | + --set '.mounts=null | .portForwards=[{"guestSocket":"/var/run/docker.sock","hostSocket":"{{.Dir}}/sock/docker.sock"}]' \ |
| 53 | + template://almalinux-8 |
| 54 | +
|
| 55 | + # FIXME: the tests should be directly executed in the VM without nesting Docker inside it |
| 56 | + # https://github.com/containerd/nerdctl/issues/3858 |
| 57 | + - name: "Init: install dockerd in the guest VM" |
| 58 | + run: | |
| 59 | + set -eux |
| 60 | + lima sudo mkdir -p /etc/systemd/system/docker.socket.d |
| 61 | + cat <<-EOF | lima sudo tee /etc/systemd/system/docker.socket.d/override.conf |
| 62 | + [Socket] |
| 63 | + SocketUser=$(whoami) |
| 64 | + EOF |
| 65 | + lima sudo dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo |
| 66 | + lima sudo dnf -q -y install docker-ce --nobest |
| 67 | + lima sudo systemctl enable --now docker |
| 68 | +
|
| 69 | + - name: "Init: configure the host to use dockerd in the guest VM" |
| 70 | + run: | |
| 71 | + set -eux |
| 72 | + sudo systemctl disable --now docker.service docker.socket |
| 73 | + export DOCKER_HOST="unix://$(limactl ls --format '{{.Dir}}/sock/docker.sock' default)" |
| 74 | + echo "DOCKER_HOST=${DOCKER_HOST}" >>$GITHUB_ENV |
| 75 | + docker info |
| 76 | + docker version |
| 77 | +
|
| 78 | + - name: "Init: expose GitHub Runtime variables for gha" |
| 79 | + uses: crazy-max/ghaction-github-runtime@3cb05d89e1f492524af3d41a1c98c83bc3025124 # v3.1.0 |
| 80 | + |
| 81 | + - name: "Init: prepare integration tests" |
| 82 | + run: | |
| 83 | + set -eux |
| 84 | +
|
| 85 | + sudo losetup -Dv |
| 86 | + sudo losetup -lv |
| 87 | +
|
| 88 | + TARGET=test-integration |
| 89 | + [ "$MODE" = "rootless" ] && TARGET=test-integration-rootless |
| 90 | + docker buildx create --name with-gha --use |
| 91 | + docker buildx build \ |
| 92 | + --output=type=docker \ |
| 93 | + --cache-from type=gha,scope=test-integration-dependencies-amd64 \ |
| 94 | + -t test-integration --target "${TARGET}" \ |
| 95 | + . |
| 96 | +
|
| 97 | + - name: "Run integration tests" |
| 98 | + # Presumably, something is broken with the way docker exposes /dev to the container, as it appears to only |
| 99 | + # randomly work. Mounting /dev does workaround the issue. |
| 100 | + # This might be due to the old kernel shipped with Alma (4.18), or something else between centos/docker. |
| 101 | + run: | |
| 102 | + set -eux |
| 103 | + if [ "$MODE" = "rootless" ]; then |
| 104 | + echo "rootless" |
| 105 | + docker run -t -v /dev:/dev --rm --privileged test-integration /test-integration-rootless.sh ./hack/test-integration.sh -test.only-flaky=false |
| 106 | + else |
| 107 | + echo "rootful" |
| 108 | + docker run -t -v /dev:/dev --rm --privileged test-integration ./hack/test-integration.sh -test.only-flaky=false |
| 109 | + fi |
| 110 | + - name: "Run: integration tests (flaky)" |
| 111 | + run: | |
| 112 | + set -eux |
| 113 | + if [ "$MODE" = "rootless" ]; then |
| 114 | + echo "rootless" |
| 115 | + docker run -t -v /dev:/dev --rm --privileged test-integration /test-integration-rootless.sh ./hack/test-integration.sh -test.only-flaky=true |
| 116 | + else |
| 117 | + echo "rootful" |
| 118 | + docker run -t -v /dev:/dev --rm --privileged test-integration ./hack/test-integration.sh -test.only-flaky=true |
| 119 | + fi |
0 commit comments