|
| 1 | +# This currently test docker and nerdctl on windows (w/o canary) |
| 2 | +# Structure is in to allow testing nerdctl on linux as well, though more work is required to make it functional. |
| 3 | +name: job-test-in-host |
| 4 | + |
| 5 | +on: |
| 6 | + workflow_call: |
| 7 | + inputs: |
| 8 | + timeout: |
| 9 | + required: true |
| 10 | + type: number |
| 11 | + runner: |
| 12 | + required: true |
| 13 | + type: string |
| 14 | + canary: |
| 15 | + required: false |
| 16 | + default: false |
| 17 | + type: boolean |
| 18 | + binary: |
| 19 | + required: false |
| 20 | + default: nerdctl |
| 21 | + type: string |
| 22 | + go-version: |
| 23 | + required: true |
| 24 | + type: string |
| 25 | + containerd-version: |
| 26 | + required: true |
| 27 | + type: string |
| 28 | + containerd-sha: |
| 29 | + required: true |
| 30 | + type: string |
| 31 | + containerd-service-sha: |
| 32 | + required: true |
| 33 | + type: string |
| 34 | + windows-cni-version: |
| 35 | + required: true |
| 36 | + type: string |
| 37 | + linux-cni-version: |
| 38 | + required: true |
| 39 | + type: string |
| 40 | + linux-cni-sha: |
| 41 | + required: true |
| 42 | + type: string |
| 43 | + |
| 44 | +env: |
| 45 | + GOTOOLCHAIN: local |
| 46 | + |
| 47 | +jobs: |
| 48 | + test: |
| 49 | + name: | |
| 50 | + ${{ inputs.binary != 'nerdctl' && format('{0} < ', inputs.binary) || '' }} |
| 51 | + ${{ contains(inputs.runner, 'ubuntu') && ' linux' || ' windows' }} |
| 52 | + ${{ contains(inputs.runner, 'arm') && '(arm)' || '' }} |
| 53 | + ${{ contains(inputs.runner, '22.04') && '(old ubuntu)' || '' }} |
| 54 | + ${{ inputs.canary && ' (canary)' || '' }} |
| 55 | + timeout-minutes: ${{ inputs.timeout }} |
| 56 | + runs-on: "${{ inputs.runner }}" |
| 57 | + defaults: |
| 58 | + run: |
| 59 | + shell: bash |
| 60 | + |
| 61 | + env: |
| 62 | + SHOULD_RUN: "yes" |
| 63 | + GO_VERSION: ${{ inputs.go-version }} |
| 64 | + # Both Docker and nerdctl on linux need rootful right now |
| 65 | + WITH_SUDO: ${{ contains(inputs.runner, 'ubuntu') }} |
| 66 | + CONTAINERD_VERSION: ${{ inputs.containerd-version }} |
| 67 | + CONTAINERD_SHA: ${{ inputs.containerd-sha }} |
| 68 | + |
| 69 | + steps: |
| 70 | + - name: "Init: checkout" |
| 71 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 72 | + with: |
| 73 | + fetch-depth: 1 |
| 74 | + |
| 75 | + - if: ${{ inputs.canary }} |
| 76 | + name: "Init (canary): retrieve latest go and containerd" |
| 77 | + run: | |
| 78 | + latest_go="$(. ./hack/provisioning/version/fetch.sh; go::canary::for::go-setup)" |
| 79 | + latest_containerd="$(. ./hack/provisioning/version/fetch.sh; github::project::latest "containerd/containerd")" |
| 80 | +
|
| 81 | + [ "$latest_go" == "" ] || \ |
| 82 | + printf "GO_VERSION=%s\n" "$latest_go" >> "$GITHUB_ENV" |
| 83 | + [ "${latest_containerd:1}" == "$CONTAINERD_VERSION" ] || { |
| 84 | + printf "CONTAINERD_VERSION=%s\n" "${latest_containerd:1}" >> "$GITHUB_ENV" |
| 85 | + printf "CONTAINERD_SHA=canary is volatile and I accept the risk\n" >> "$GITHUB_ENV" |
| 86 | + } |
| 87 | + if [ "$latest_go" == "" ] && [ "${latest_containerd:1}" == "$CONTAINERD_VERSION" ]; then |
| 88 | + echo "::warning title=No canary::There is currently no canary versions to test. Steps will not run."; |
| 89 | + printf "SHOULD_RUN=no\n" >> "$GITHUB_ENV" |
| 90 | + fi |
| 91 | +
|
| 92 | + - if: ${{ env.SHOULD_RUN == 'yes' }} |
| 93 | + name: "Init: install go" |
| 94 | + uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.0 |
| 95 | + with: |
| 96 | + go-version: ${{ env.GO_VERSION }} |
| 97 | + check-latest: true |
| 98 | + |
| 99 | + # XXX RUNNER_OS and generally env is too unreliable |
| 100 | + # - if: ${{ env.RUNNER_OS == 'Linux' }} |
| 101 | + - if: ${{ contains(inputs.runner, 'ubuntu') && env.SHOULD_RUN == 'yes' }} |
| 102 | + name: "Init (linux): prepare host" |
| 103 | + run: | |
| 104 | + if [ "${{ contains(inputs.binary, 'docker') }}" == true ]; then |
| 105 | + echo "::group:: configure cdi for docker" |
| 106 | + sudo mkdir -p /etc/docker |
| 107 | + sudo jq '.features.cdi = true' /etc/docker/daemon.json | sudo tee /etc/docker/daemon.json.tmp && sudo mv /etc/docker/daemon.json.tmp /etc/docker/daemon.json |
| 108 | + sudo systemctl restart docker |
| 109 | + echo "::endgroup::" |
| 110 | + else |
| 111 | + # FIXME: this is missing runc (see top level workflow note about the state of this) |
| 112 | + echo "::group:: install dependencies" |
| 113 | + sudo ./hack/provisioning/linux/containerd.sh uninstall |
| 114 | + ./hack/provisioning/linux/containerd.sh rootful "$CONTAINERD_VERSION" "amd64" "$CONTAINERD_SHA" "${{ inputs.containerd-service-sha }}" |
| 115 | + sudo ./hack/provisioning/linux/cni.sh uninstall |
| 116 | + ./hack/provisioning/linux/cni.sh install "${{ inputs.linux-cni-version }}" "amd64" "${{ inputs.linux-cni-sha }}" |
| 117 | + echo "::endgroup::" |
| 118 | +
|
| 119 | + echo "::group:: build nerctl" |
| 120 | + go install ./cmd/nerdctl |
| 121 | + echo "$HOME/go/bin" >> "$GITHUB_PATH" |
| 122 | + # Since tests are going to run root, we need nerdctl to be in a PATH that will survive `sudo` |
| 123 | + sudo cp "$(which nerdctl)" /usr/local/bin |
| 124 | + echo "::endgroup::" |
| 125 | + fi |
| 126 | +
|
| 127 | + # Register QEMU (tonistiigi/binfmt) |
| 128 | + # `--install all` will only install emulation for architectures that cannot be natively executed |
| 129 | + # Since some arm64 platforms do provide native fallback execution for 32 bits, |
| 130 | + # armv7 emulation may or may not be installed, causing variance in the result of `uname -m`. |
| 131 | + # To avoid that, we explicitly list the architectures we do want emulation for. |
| 132 | + docker run --privileged --rm tonistiigi/binfmt --install linux/amd64 |
| 133 | + docker run --privileged --rm tonistiigi/binfmt --install linux/arm64 |
| 134 | + docker run --privileged --rm tonistiigi/binfmt --install linux/arm/v7 |
| 135 | +
|
| 136 | + # FIXME: remove expect when we are done removing unbuffer from tests |
| 137 | + sudo apt-get install -qq expect |
| 138 | +
|
| 139 | + - if: ${{ contains(inputs.runner, 'windows') && env.SHOULD_RUN == 'yes' }} |
| 140 | + name: "Init (windows): prepare host" |
| 141 | + env: |
| 142 | + ctrdVersion: ${{ env.CONTAINERD_VERSION }} |
| 143 | + run: | |
| 144 | + # Install WinCNI |
| 145 | + echo "::group:: install wincni" |
| 146 | + GOPATH=$(go env GOPATH) WINCNI_VERSION=${{ inputs.windows-cni-version }} ./hack/provisioning/windows/cni.sh |
| 147 | + echo "::endgroup::" |
| 148 | +
|
| 149 | + # Install containerd |
| 150 | + echo "::group:: install containerd" |
| 151 | + powershell hack/provisioning/windows/containerd.ps1 |
| 152 | + echo "::endgroup::" |
| 153 | +
|
| 154 | + # Install nerdctl |
| 155 | + echo "::group:: build nerctl" |
| 156 | + go install ./cmd/nerdctl |
| 157 | + echo "::endgroup::" |
| 158 | +
|
| 159 | + - if: ${{ env.SHOULD_RUN == 'yes' }} |
| 160 | + name: "Init: install dev tools" |
| 161 | + run: | |
| 162 | + echo "::group:: make install-dev-tools" |
| 163 | + make install-dev-tools |
| 164 | + echo "::endgroup::" |
| 165 | +
|
| 166 | + # ipv6 is tested only on linux |
| 167 | + - if: ${{ contains(inputs.runner, 'ubuntu') && env.SHOULD_RUN == 'yes' }} |
| 168 | + name: "Run (linux): integration tests (IPv6)" |
| 169 | + run: | |
| 170 | + ./hack/test-integration.sh -test.target=${{ inputs.binary }} -test.only-ipv6 |
| 171 | +
|
| 172 | + - if: ${{ env.SHOULD_RUN == 'yes' }} |
| 173 | + name: "Run: integration tests" |
| 174 | + run: | |
| 175 | + ./hack/test-integration.sh -test.target=${{ inputs.binary }} -test.only-flaky=false |
| 176 | +
|
| 177 | + # FIXME: this must go |
| 178 | + - if: ${{ env.SHOULD_RUN == 'yes' }} |
| 179 | + name: "Run: integration tests (flaky)" |
| 180 | + run: | |
| 181 | + ./hack/test-integration.sh -test.target=${{ inputs.binary }} -test.only-flaky=true |
0 commit comments