github.com/containerd/nerdctl@v1.7.7/.github/workflows/test.yml (about)

     1  name: test
     2  
     3  on:
     4    push:
     5      branches:
     6        - main
     7        - 'release/**'
     8    pull_request:
     9  
    10  env:
    11    GO_VERSION: 1.23.x
    12  
    13  jobs:
    14    project:
    15      name: Project Checks
    16      runs-on: ubuntu-24.04
    17      timeout-minutes: 20
    18      steps:
    19        - uses: actions/checkout@v4.1.1
    20          with:
    21            path: src/github.com/containerd/nerdctl
    22            fetch-depth: 100
    23        - uses: actions/setup-go@v5
    24          with:
    25            go-version: ${{ env.GO_VERSION }}
    26            cache-dependency-path: src/github.com/containerd/nerdctl
    27        - uses: containerd/project-checks@v1.1.0
    28          with:
    29            working-directory: src/github.com/containerd/nerdctl
    30            repo-access-token: ${{ secrets.GITHUB_TOKEN }}
    31        - run: ./hack/verify-no-patent.sh
    32          working-directory: src/github.com/containerd/nerdctl
    33        - run: ./hack/verify-pkg-isolation.sh
    34          working-directory: src/github.com/containerd/nerdctl
    35  
    36    lint:
    37      runs-on: ubuntu-24.04
    38      timeout-minutes: 20
    39      steps:
    40        - uses: actions/checkout@v4.1.1
    41          with:
    42            fetch-depth: 1
    43        - uses: actions/setup-go@v5
    44          with:
    45            go-version: ${{ env.GO_VERSION }}
    46            check-latest: true
    47            cache: true
    48        - name: golangci-lint
    49          uses: golangci/golangci-lint-action@v6.1.0
    50          with:
    51            version: v1.60.1
    52            args: --verbose
    53        - name: yamllint-lint
    54          run: yamllint .
    55  
    56    test-unit:
    57      runs-on: ubuntu-24.04
    58      timeout-minutes: 20
    59      steps:
    60        - uses: actions/checkout@v4.1.1
    61          with:
    62            fetch-depth: 1
    63        - uses: actions/setup-go@v5
    64          with:
    65            go-version: ${{ env.GO_VERSION }}
    66            check-latest: true
    67            cache: true
    68        - name: "Run unit tests"
    69          run: go test -v ./pkg/...
    70  
    71    test-integration:
    72      runs-on: "ubuntu-${{ matrix.ubuntu }}"
    73      timeout-minutes: 40
    74      strategy:
    75        fail-fast: false
    76        matrix:
    77          # ubuntu-20.04: cgroup v1, ubuntu-22.04 and later: cgroup v2
    78          include:
    79            - ubuntu: 20.04
    80              containerd: v1.6.31
    81            - ubuntu: 20.04
    82              containerd: v1.7.22
    83            - ubuntu: 22.04
    84              containerd: v1.7.22
    85            - ubuntu: 22.04
    86              containerd: main
    87            - ubuntu: 24.04
    88              containerd: v1.7.22
    89            - ubuntu: 24.04
    90              containerd: main
    91      env:
    92        UBUNTU_VERSION: "${{ matrix.ubuntu }}"
    93        CONTAINERD_VERSION: "${{ matrix.containerd }}"
    94      steps:
    95        - uses: actions/checkout@v4.1.1
    96          with:
    97            fetch-depth: 1
    98        - name: "Prepare integration test environment"
    99          run: DOCKER_BUILDKIT=1 docker build -t test-integration --target test-integration --build-arg UBUNTU_VERSION=${UBUNTU_VERSION} --build-arg CONTAINERD_VERSION=${CONTAINERD_VERSION} .
   100        - name: "Remove snap loopback devices (conflicts with our loopback devices in TestRunDevice)"
   101          run: |
   102            sudo systemctl disable --now snapd.service snapd.socket
   103            sudo apt-get purge -y snapd
   104            sudo losetup -Dv
   105            sudo losetup -lv
   106        - name: "Register QEMU (tonistiigi/binfmt)"
   107          run: docker run --privileged --rm tonistiigi/binfmt --install all
   108        - name: "Run integration tests"
   109          run: docker run -t --rm --privileged test-integration
   110  
   111    test-integration-ipv6:
   112      runs-on: "ubuntu-${{ matrix.ubuntu }}"
   113      timeout-minutes: 40
   114      strategy:
   115        fail-fast: false
   116        matrix:
   117          # ubuntu-20.04: cgroup v1, ubuntu-22.04 and later: cgroup v2
   118          include:
   119            - ubuntu: 24.04
   120              containerd: v1.7.22
   121      env:
   122        UBUNTU_VERSION: "${{ matrix.ubuntu }}"
   123        CONTAINERD_VERSION: "${{ matrix.containerd }}"
   124      steps:
   125        - uses: actions/checkout@v4.1.1
   126          with:
   127            fetch-depth: 1
   128        - name: Enable ipv4 and ipv6 forwarding
   129          run: |
   130            sudo sysctl -w net.ipv6.conf.all.forwarding=1
   131            sudo sysctl -w net.ipv4.ip_forward=1
   132        - name: Enable IPv6 for Docker
   133          run: |
   134            sudo mkdir -p /etc/docker
   135            echo '{"ipv6": true, "fixed-cidr-v6": "2001:db8:1::/64", "experimental": true, "ip6tables": true}' | sudo tee /etc/docker/daemon.json
   136            sudo systemctl restart docker
   137        - name: "Prepare integration test environment"
   138          run: DOCKER_BUILDKIT=1 docker build -t test-integration-ipv6 --target test-integration-ipv6 --build-arg UBUNTU_VERSION=${UBUNTU_VERSION} --build-arg CONTAINERD_VERSION=${CONTAINERD_VERSION} .
   139        - name: "Remove snap loopback devices (conflicts with our loopback devices in TestRunDevice)"
   140          run: |
   141            sudo systemctl disable --now snapd.service snapd.socket
   142            sudo apt-get purge -y snapd
   143            sudo losetup -Dv
   144            sudo losetup -lv
   145        - name: "Register QEMU (tonistiigi/binfmt)"
   146          run: docker run --privileged --rm tonistiigi/binfmt --install all
   147        - name: "Run integration tests"
   148          # The nested IPv6 network inside docker and qemu is complex and needs a bunch of sysctl config.
   149          # Therefore it's hard to debug why the IPv6 tests fail in such an isolation layer.
   150          # On the other side, using the host network is easier at configuration.
   151          # Besides, each job is running on a different instance, which means using host network here
   152          # is safe and has no side effects on others.
   153          run: docker run --network host -t --rm --privileged test-integration-ipv6
   154  
   155    test-integration-rootless:
   156      runs-on: "ubuntu-${{ matrix.ubuntu }}"
   157      timeout-minutes: 60
   158      strategy:
   159        fail-fast: false
   160        matrix:
   161          # ubuntu-20.04: cgroup v1, ubuntu-22.04 and later: cgroup v2
   162          include:
   163            - ubuntu: 20.04
   164              containerd: v1.6.31
   165              rootlesskit: v1.1.1
   166              target: test-integration-rootless
   167            - ubuntu: 20.04
   168              containerd: v1.7.22
   169              rootlesskit: v2.3.1
   170              target: test-integration-rootless
   171            - ubuntu: 22.04
   172              containerd: v1.7.22
   173              rootlesskit: v1.1.1
   174              target: test-integration-rootless
   175            - ubuntu: 22.04
   176              containerd: main  # v2.0.0-rc.X
   177              rootlesskit: v2.3.1
   178              target: test-integration-rootless
   179            - ubuntu: 24.04
   180              containerd: v1.7.22
   181              rootlesskit: v1.1.1
   182              target: test-integration-rootless
   183            - ubuntu: 24.04
   184              containerd: main  # v2.0.0-rc.X
   185              rootlesskit: v2.3.1
   186              target: test-integration-rootless
   187            - ubuntu: 20.04
   188              containerd: v1.6.31
   189              rootlesskit: v1.1.1
   190              target: test-integration-rootless-port-slirp4netns
   191            - ubuntu: 20.04
   192              containerd: v1.7.22
   193              rootlesskit: v2.3.1
   194              target: test-integration-rootless-port-slirp4netns
   195            - ubuntu: 22.04
   196              containerd: v1.7.22
   197              rootlesskit: v1.1.1
   198              target: test-integration-rootless-port-slirp4netns
   199            - ubuntu: 22.04
   200              containerd: main  # v2.0.0-rc.X
   201              rootlesskit: v2.3.1
   202              target: test-integration-rootless-port-slirp4netns
   203            - ubuntu: 24.04
   204              containerd: v1.7.22
   205              rootlesskit: v1.1.1
   206              target: test-integration-rootless-port-slirp4netns
   207            - ubuntu: 24.04
   208              containerd: main  # v2.0.0-rc.X
   209              rootlesskit: v2.3.1
   210              target: test-integration-rootless-port-slirp4netns
   211      env:
   212        UBUNTU_VERSION: "${{ matrix.ubuntu }}"
   213        CONTAINERD_VERSION: "${{ matrix.containerd }}"
   214        ROOTLESSKIT_VERSION: "${{ matrix.rootlesskit }}"
   215        TEST_TARGET: "${{ matrix.target }}"
   216      steps:
   217        - name: "Set up AppArmor"
   218          if: matrix.ubuntu == '24.04'
   219          run: |
   220            cat <<EOT | sudo tee "/etc/apparmor.d/usr.local.bin.rootlesskit"
   221            abi <abi/4.0>,
   222            include <tunables/global>
   223  
   224            /usr/local/bin/rootlesskit flags=(unconfined) {
   225              userns,
   226  
   227              # Site-specific additions and overrides. See local/README for details.
   228              include if exists <local/usr.local.bin.rootlesskit>
   229            }
   230            EOT
   231            sudo systemctl restart apparmor.service
   232        - uses: actions/checkout@v4.1.7
   233          with:
   234            fetch-depth: 1
   235        - name: "Register QEMU (tonistiigi/binfmt)"
   236          run: docker run --privileged --rm tonistiigi/binfmt --install all
   237        - name: "Prepare (network driver=slirp4netns, port driver=builtin)"
   238          run: DOCKER_BUILDKIT=1 docker build -t ${TEST_TARGET} --target ${TEST_TARGET} --build-arg UBUNTU_VERSION=${UBUNTU_VERSION} --build-arg CONTAINERD_VERSION=${CONTAINERD_VERSION} --build-arg ROOTLESSKIT_VERSION=${ROOTLESSKIT_VERSION} .
   239        - name: "Test (network driver=slirp4netns, port driver=builtin)"
   240          run: docker run -t --rm --privileged -e WORKAROUND_ISSUE_622=1 ${TEST_TARGET}
   241  
   242    cross:
   243      runs-on: ubuntu-24.04
   244      timeout-minutes: 40
   245      strategy:
   246        matrix:
   247          go-version: ["1.22.x", "1.23.x"]
   248      steps:
   249        - uses: actions/checkout@v4.1.1
   250          with:
   251            fetch-depth: 1
   252        - uses: actions/setup-go@v5
   253          with:
   254            go-version: ${{ matrix.go-version }}
   255            cache: true
   256            check-latest: true
   257        - name: "Cross"
   258          run: GO_VERSION="$(echo ${{ matrix.go-version }} | sed -e s/.x//)" make artifacts
   259  
   260    test-integration-docker-compatibility:
   261      runs-on: ubuntu-22.04  # TODO: ubuntu-24.04
   262      timeout-minutes: 45
   263      steps:
   264        - uses: actions/checkout@v4.1.1
   265          with:
   266            fetch-depth: 1
   267        - uses: actions/setup-go@v5
   268          with:
   269            go-version: ${{ env.GO_VERSION }}
   270            cache: true
   271            check-latest: true
   272        - name: "Install Docker v24"
   273          run: |
   274            set -eux -o pipefail
   275            # Uninstall the preinstalled Docker
   276            sudo apt-get remove docker-* containerd.io
   277            # Enable BuildKit explicitly
   278            sudo apt-get install -y moreutils
   279            cat /etc/docker/daemon.json
   280            jq '.features.buildkit = true' </etc/docker/daemon.json  | sudo sponge /etc/docker/daemon.json
   281            cat /etc/docker/daemon.json
   282            # Download Docker packages
   283            curl -OSL https://download.docker.com/linux/ubuntu/dists/jammy/pool/stable/amd64/containerd.io_1.6.33-1_amd64.deb
   284            curl -OSL https://download.docker.com/linux/ubuntu/dists/jammy/pool/stable/amd64/docker-ce_24.0.9-1~ubuntu.22.04~jammy_amd64.deb
   285            curl -OSL https://download.docker.com/linux/ubuntu/dists/jammy/pool/stable/amd64/docker-ce-cli_24.0.9-1~ubuntu.22.04~jammy_amd64.deb
   286            curl -OSL https://download.docker.com/linux/ubuntu/dists/jammy/pool/stable/amd64/docker-buildx-plugin_0.13.1-1~ubuntu.22.04~jammy_amd64.deb
   287            curl -OSL https://download.docker.com/linux/ubuntu/dists/jammy/pool/stable/amd64/docker-compose-plugin_2.25.0-1~ubuntu.22.04~jammy_amd64.deb
   288            # Install Docker
   289            sudo apt-get install -y ./*.deb
   290            rm -f ./*.deb
   291            # Print docker info
   292            docker info
   293            docker version
   294        - name: "Register QEMU (tonistiigi/binfmt)"
   295          run: docker run --privileged --rm tonistiigi/binfmt --install all
   296        - name: "Prepare integration test environment"
   297          run: |
   298            sudo apt-get install -y expect
   299        - name: "Ensure that the integration test suite is compatible with Docker"
   300          run: go test -timeout 20m -v -exec sudo ./cmd/nerdctl/... -args -test.target=docker -test.kill-daemon
   301        - name: "Ensure that the IPv6 integration test suite is compatible with Docker"
   302          run: go test -timeout 20m -v -exec sudo ./cmd/nerdctl/... -args -test.target=docker -test.kill-daemon -test.ipv6
   303  
   304    test-integration-windows:
   305      # A "larger" runner is used for enabling Hyper-V containers
   306      runs-on: windows-2022-8-cores
   307      timeout-minutes: 30
   308      defaults:
   309        run:
   310          shell: bash
   311      steps:
   312        - uses: actions/checkout@v4.1.1
   313          with:
   314            fetch-depth: 1
   315        - uses: actions/setup-go@v5
   316          with:
   317            go-version: ${{ env.GO_VERSION }}
   318            cache: true
   319            check-latest: true
   320        - run: go install ./cmd/nerdctl
   321        - uses: actions/checkout@v4.1.1
   322          with:
   323            repository: containerd/containerd
   324            ref: v1.7.22
   325            path: containerd
   326            fetch-depth: 1
   327        - name: "Set up CNI"
   328          working-directory: containerd
   329          run: GOPATH=$(go env GOPATH) script/setup/install-cni-windows
   330        - name: "Set up containerd"
   331          env:
   332            ctrdVersion: 1.7.22
   333          run: powershell hack/configure-windows-ci.ps1
   334        # TODO: Run unit tests
   335        - name: "Run integration tests"
   336          run: go test -v ./cmd/...
   337  
   338    test-integration-freebsd:
   339      name: FreeBSD
   340      # ubuntu-24.04 lacks the vagrant package
   341      runs-on: ubuntu-22.04
   342      timeout-minutes: 20
   343  
   344      steps:
   345        - uses: actions/checkout@v4.1.1
   346        - uses: actions/cache@v3
   347          with:
   348            path: /root/.vagrant.d
   349            key: vagrant-${{ matrix.box }}
   350        - name: Set up vagrant
   351          run: |
   352            sudo apt-get update
   353            sudo apt-get install -y libvirt-daemon libvirt-daemon-system vagrant vagrant-libvirt
   354            sudo systemctl enable --now libvirtd
   355        - name: Boot VM
   356          run: |
   357            ln -sf Vagrantfile.freebsd Vagrantfile
   358            sudo vagrant up --no-tty
   359        - name: test-unit
   360          run: sudo vagrant up --provision-with=test-unit
   361        - name: test-integration
   362          run: sudo vagrant up --provision-with=test-integration