Skip to content

Commit 3dfe8d2

Browse files
authored
Merge pull request #3535 from apostasie/part5
CI adjustments
2 parents 6f64236 + 4f20a14 commit 3dfe8d2

File tree

10 files changed

+116
-74
lines changed

10 files changed

+116
-74
lines changed

.github/workflows/ghcr-image-build-and-publish.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Container Image Build
1+
name: image
22

33
# This workflow uses actions that are not certified by GitHub.
44
# They are provided by a third-party and are governed by
@@ -21,7 +21,6 @@ env:
2121
# github.repository as <account>/<repo>
2222
IMAGE_NAME: ${{ github.repository }}
2323

24-
2524
jobs:
2625
build:
2726

.github/workflows/lint.yml

-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ jobs:
5555
uses: golangci/golangci-lint-action@v6
5656
with:
5757
args: --verbose
58-
5958
other:
6059
timeout-minutes: 5
6160
name: yaml | shell | imports order

.github/workflows/project.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99

1010
jobs:
1111
project:
12-
name: Project Checks
12+
name: checks
1313
runs-on: ubuntu-24.04
1414
timeout-minutes: 20
1515
steps:

.github/workflows/test-canary.yml

+8-4
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,13 @@ jobs:
4444
- name: "Run unit tests"
4545
run: go test -v ./pkg/...
4646
- name: "Run integration tests"
47-
run: docker run -t --rm --privileged test-integration
47+
run: docker run -t --rm --privileged test-integration ./hack/test-integration.sh -test.only-flaky=false
48+
- name: "Run integration tests (flaky)"
49+
run: docker run -t --rm --privileged test-integration ./hack/test-integration.sh -test.only-flaky=true
4850

4951
windows:
50-
runs-on: windows-latest
5152
timeout-minutes: 30
53+
runs-on: windows-latest
5254
defaults:
5355
run:
5456
shell: bash
@@ -74,6 +76,7 @@ jobs:
7476
cache: true
7577
check-latest: true
7678
- run: go install ./cmd/nerdctl
79+
- run: go install -v gotest.tools/gotestsum@v1
7780
# This here is solely to get the cni install script, which has not been modified in 3+ years.
7881
# There is little to no reason to update this to latest containerd
7982
- uses: actions/[email protected]
@@ -91,5 +94,6 @@ jobs:
9194
ctrdVersion: ${{ env.CONTAINERD_VERSION }}
9295
run: powershell hack/configure-windows-ci.ps1
9396
- name: "Run integration tests"
94-
# See https://github.com/containerd/nerdctl/blob/main/docs/testing/README.md#about-parallelization
95-
run: go test -p 1 -v ./cmd/nerdctl/...
97+
run: ./hack/test-integration.sh -test.only-flaky=false
98+
- name: "Run integration tests (flaky)"
99+
run: ./hack/test-integration.sh -test.only-flaky=true

.github/workflows/test-kube.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@ on:
1010
paths-ignore:
1111
- '**.md'
1212

13-
env:
14-
ROOTFUL: true
15-
1613
jobs:
1714
linux:
1815
runs-on: "ubuntu-24.04"
1916
timeout-minutes: 40
17+
env:
18+
ROOTFUL: true
2019
steps:
2120
- uses: actions/[email protected]
2221
with:

.github/workflows/test.yml

+45-53
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,14 @@ on:
1111

1212
env:
1313
GO_VERSION: 1.23.x
14+
SHORT_TIMEOUT: 5
15+
LONG_TIMEOUT: 60
1416

1517
jobs:
1618
test-unit:
19+
# Supposed to work: https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/evaluate-expressions-in-workflows-and-actions#example-returning-a-json-data-type
20+
# Apparently does not
21+
# timeout-minutes: ${{ fromJSON(env.SHORT_TIMEOUT) }}
1722
timeout-minutes: 5
1823
name: unit | ${{ matrix.goos }}
1924
runs-on: "${{ matrix.os }}"
@@ -48,11 +53,12 @@ jobs:
4853
working-directory: containerd
4954
run: GOPATH=$(go env GOPATH) script/setup/install-cni-windows
5055
- name: "Run unit tests"
51-
run: go test -v ./pkg/...
56+
run: make test-unit
5257

5358
test-integration:
59+
timeout-minutes: 60
60+
name: rootful | ${{ matrix.containerd }} | ${{ matrix.runner }}
5461
runs-on: "${{ matrix.runner }}"
55-
timeout-minutes: 40
5662
strategy:
5763
fail-fast: false
5864
matrix:
@@ -95,23 +101,21 @@ jobs:
95101
docker run --privileged --rm tonistiigi/binfmt --install linux/arm64
96102
docker run --privileged --rm tonistiigi/binfmt --install linux/arm/v7
97103
- name: "Run integration tests"
98-
uses: nick-fields/retry@v3
99-
with:
100-
timeout_minutes: 30
101-
max_attempts: 2
102-
retry_on: error
103-
command: docker run -t --rm --privileged test-integration
104+
run: docker run -t --rm --privileged test-integration ./hack/test-integration.sh -test.only-flaky=false
105+
- name: "Run integration tests (flaky)"
106+
run: docker run -t --rm --privileged test-integration ./hack/test-integration.sh -test.only-flaky=true
104107

105108
test-integration-ipv6:
109+
timeout-minutes: 60
110+
name: ipv6 | ${{ matrix.containerd }} | ${{ matrix.ubuntu }}
106111
runs-on: "ubuntu-${{ matrix.ubuntu }}"
107-
timeout-minutes: 40
108112
strategy:
109113
fail-fast: false
110114
matrix:
111115
# ubuntu-20.04: cgroup v1, ubuntu-22.04 and later: cgroup v2
112116
include:
113117
- ubuntu: 24.04
114-
containerd: v1.7.23
118+
containerd: v2.0.0-rc.5
115119
env:
116120
UBUNTU_VERSION: "${{ matrix.ubuntu }}"
117121
CONTAINERD_VERSION: "${{ matrix.containerd }}"
@@ -129,7 +133,7 @@ jobs:
129133
echo '{"ipv6": true, "fixed-cidr-v6": "2001:db8:1::/64", "experimental": true, "ip6tables": true}' | sudo tee /etc/docker/daemon.json
130134
sudo systemctl restart docker
131135
- name: "Prepare integration test environment"
132-
run: docker build -t test-integration-ipv6 --target test-integration-ipv6 --build-arg UBUNTU_VERSION=${UBUNTU_VERSION} --build-arg CONTAINERD_VERSION=${CONTAINERD_VERSION} .
136+
run: docker build -t test-integration --target test-integration --build-arg UBUNTU_VERSION=${UBUNTU_VERSION} --build-arg CONTAINERD_VERSION=${CONTAINERD_VERSION} .
133137
- name: "Remove snap loopback devices (conflicts with our loopback devices in TestRunDevice)"
134138
run: |
135139
sudo systemctl disable --now snapd.service snapd.socket
@@ -147,20 +151,16 @@ jobs:
147151
docker run --privileged --rm tonistiigi/binfmt --install linux/arm/v7
148152
- name: "Run integration tests"
149153
# The nested IPv6 network inside docker and qemu is complex and needs a bunch of sysctl config.
150-
# Therefore it's hard to debug why the IPv6 tests fail in such an isolation layer.
154+
# Therefore, it's hard to debug why the IPv6 tests fail in such an isolation layer.
151155
# On the other side, using the host network is easier at configuration.
152156
# Besides, each job is running on a different instance, which means using host network here
153157
# is safe and has no side effects on others.
154-
uses: nick-fields/retry@v3
155-
with:
156-
timeout_minutes: 30
157-
max_attempts: 2
158-
retry_on: error
159-
command: docker run --network host -t --rm --privileged test-integration-ipv6
158+
run: docker run --network host -t --rm --privileged test-integration ./hack/test-integration.sh -test.only-ipv6
160159

161160
test-integration-rootless:
162-
runs-on: "ubuntu-${{ matrix.ubuntu }}"
163161
timeout-minutes: 60
162+
name: "${{ matrix.target }} | ${{ matrix.containerd }} | ${{ matrix.rootlesskit }} | ${{ matrix.ubuntu }}"
163+
runs-on: "ubuntu-${{ matrix.ubuntu }}"
164164
strategy:
165165
fail-fast: false
166166
matrix:
@@ -169,24 +169,24 @@ jobs:
169169
- ubuntu: 20.04
170170
containerd: v1.6.36
171171
rootlesskit: v1.1.1 # Deprecated
172-
target: test-integration-rootless
172+
target: rootless
173173
- ubuntu: 22.04
174174
containerd: v1.7.23
175175
rootlesskit: v2.3.1
176-
target: test-integration-rootless
176+
target: rootless
177177
- ubuntu: 24.04
178178
containerd: v2.0.0-rc.5
179179
rootlesskit: v2.3.1
180-
target: test-integration-rootless
180+
target: rootless
181181
- ubuntu: 24.04
182182
containerd: v1.7.23
183183
rootlesskit: v2.3.1
184-
target: test-integration-rootless-port-slirp4netns
184+
target: rootless-port-slirp4netns
185185
env:
186186
UBUNTU_VERSION: "${{ matrix.ubuntu }}"
187187
CONTAINERD_VERSION: "${{ matrix.containerd }}"
188188
ROOTLESSKIT_VERSION: "${{ matrix.rootlesskit }}"
189-
TEST_TARGET: "${{ matrix.target }}"
189+
TEST_TARGET: "test-integration-${{ matrix.target }}"
190190
steps:
191191
- name: "Set up AppArmor"
192192
if: matrix.ubuntu == '24.04'
@@ -226,16 +226,14 @@ jobs:
226226
fi
227227
echo "WORKAROUND_ISSUE_622=${WORKAROUND_ISSUE_622}" >> "$GITHUB_ENV"
228228
- name: "Test (network driver=slirp4netns, port driver=builtin)"
229-
uses: nick-fields/retry@v3
230-
with:
231-
timeout_minutes: 30
232-
max_attempts: 2
233-
retry_on: error
234-
command: docker run -t --rm --privileged -e WORKAROUND_ISSUE_622=${WORKAROUND_ISSUE_622} ${TEST_TARGET}
229+
run: docker run -t --rm --privileged -e WORKAROUND_ISSUE_622=${WORKAROUND_ISSUE_622} ${TEST_TARGET} /test-integration-rootless.sh ./hack/test-integration.sh -test.only-flaky=false
230+
- name: "Test (network driver=slirp4netns, port driver=builtin) (flaky)"
231+
run: docker run -t --rm --privileged -e WORKAROUND_ISSUE_622=${WORKAROUND_ISSUE_622} ${TEST_TARGET} /test-integration-rootless.sh ./hack/test-integration.sh -test.only-flaky=true
235232

236-
cross:
233+
build:
234+
timeout-minutes: 5
235+
name: "build | ${{ matrix.go-version }}"
237236
runs-on: ubuntu-24.04
238-
timeout-minutes: 40
239237
strategy:
240238
matrix:
241239
go-version: ["1.22.x", "1.23.x"]
@@ -248,12 +246,13 @@ jobs:
248246
go-version: ${{ matrix.go-version }}
249247
cache: true
250248
check-latest: true
251-
- name: "Cross"
249+
- name: "build"
252250
run: GO_VERSION="$(echo ${{ matrix.go-version }} | sed -e s/.x//)" make binaries
253251

254252
test-integration-docker-compatibility:
253+
timeout-minutes: 60
254+
name: docker
255255
runs-on: ubuntu-24.04
256-
timeout-minutes: 45
257256
steps:
258257
- uses: actions/[email protected]
259258
with:
@@ -280,26 +279,18 @@ jobs:
280279
- name: "Prepare integration test environment"
281280
run: |
282281
sudo apt-get install -y expect
282+
go install -v gotest.tools/gotestsum@v1
283283
- name: "Ensure that the integration test suite is compatible with Docker"
284-
uses: nick-fields/retry@v3
285-
with:
286-
timeout_minutes: 30
287-
max_attempts: 2
288-
retry_on: error
289-
# See https://github.com/containerd/nerdctl/blob/main/docs/testing/README.md#about-parallelization
290-
command: go test -p 1 -timeout 20m -v -exec sudo ./cmd/nerdctl/... -args -test.target=docker -test.allow-kill-daemon
284+
run: WITH_SUDO=true ./hack/test-integration.sh -test.target=docker
291285
- name: "Ensure that the IPv6 integration test suite is compatible with Docker"
292-
uses: nick-fields/retry@v3
293-
with:
294-
timeout_minutes: 30
295-
max_attempts: 2
296-
retry_on: error
297-
# See https://github.com/containerd/nerdctl/blob/main/docs/testing/README.md#about-parallelization
298-
command: go test -p 1 -timeout 20m -v -exec sudo ./cmd/nerdctl/... -args -test.target=docker -test.allow-kill-daemon -test.only-ipv6
286+
run: WITH_SUDO=true ./hack/test-integration.sh -test.target=docker -test.only-ipv6
287+
- name: "Ensure that the integration test suite is compatible with Docker (flaky only)"
288+
run: WITH_SUDO=true ./hack/test-integration.sh -test.target=docker -test.only-flaky
299289

300290
test-integration-windows:
301-
runs-on: windows-2022
302291
timeout-minutes: 30
292+
name: windows
293+
runs-on: windows-2022
303294
defaults:
304295
run:
305296
shell: bash
@@ -313,6 +304,7 @@ jobs:
313304
cache: true
314305
check-latest: true
315306
- run: go install ./cmd/nerdctl
307+
- run: go install -v gotest.tools/gotestsum@v1
316308
- uses: actions/[email protected]
317309
with:
318310
repository: containerd/containerd
@@ -326,16 +318,16 @@ jobs:
326318
env:
327319
ctrdVersion: 1.7.23
328320
run: powershell hack/configure-windows-ci.ps1
329-
# TODO: Run unit tests
330321
- name: "Run integration tests"
331-
# See https://github.com/containerd/nerdctl/blob/main/docs/testing/README.md#about-parallelization
332-
run: go test -p 1 -v ./cmd/nerdctl/...
322+
run: ./hack/test-integration.sh -test.only-flaky=false
323+
- name: "Run integration tests (flaky)"
324+
run: ./hack/test-integration.sh -test.only-flaky=true
333325

334326
test-integration-freebsd:
327+
timeout-minutes: 60
335328
name: FreeBSD
336329
# ubuntu-24.04 lacks the vagrant package
337330
runs-on: ubuntu-22.04
338-
timeout-minutes: 20
339331

340332
steps:
341333
- uses: actions/[email protected]

Dockerfile

+4-10
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,8 @@ ARG DEBIAN_FRONTEND=noninteractive
276276
# `expect` package contains `unbuffer(1)`, which is used for emulating TTY for testing
277277
RUN apt-get update -qq && apt-get install -qq --no-install-recommends \
278278
expect \
279-
git
279+
git \
280+
make
280281
COPY --from=goversion /GOVERSION /GOVERSION
281282
ARG TARGETARCH
282283
RUN curl -fsSL --proto '=https' --tlsv1.2 https://golang.org/dl/$(cat /GOVERSION).linux-${TARGETARCH:-amd64}.tar.gz | tar xzvC /usr/local
@@ -314,8 +315,7 @@ RUN curl -o nydus-static.tgz -fsSL --proto '=https' --tlsv1.2 "https://github.co
314315
tar xzf nydus-static.tgz && \
315316
mv nydus-static/nydus-image nydus-static/nydusd nydus-static/nydusify /usr/bin/ && \
316317
rm nydus-static.tgz
317-
CMD ["gotestsum", "--format=testname", "--rerun-fails=2", "--packages=./cmd/nerdctl/...", \
318-
"--", "-timeout=60m", "-p", "1", "-args", "-test.allow-kill-daemon"]
318+
CMD ["./hack/test-integration.sh"]
319319

320320
FROM test-integration AS test-integration-rootless
321321
# Install SSH for creating systemd user session.
@@ -338,17 +338,11 @@ RUN systemctl disable test-integration-ipfs-offline
338338
VOLUME /home/rootless/.local/share
339339
COPY ./Dockerfile.d/test-integration-rootless.sh /
340340
RUN chmod a+rx /test-integration-rootless.sh
341-
CMD ["/test-integration-rootless.sh", \
342-
"gotestsum", "--format=testname", "--rerun-fails=2", "--packages=./cmd/nerdctl/...", \
343-
"--", "-timeout=60m", "-p", "1", "-args", "-test.allow-kill-daemon"]
341+
CMD ["/test-integration-rootless.sh", "./hack/test-integration.sh"]
344342

345343
# test for CONTAINERD_ROOTLESS_ROOTLESSKIT_PORT_DRIVER=slirp4netns
346344
FROM test-integration-rootless AS test-integration-rootless-port-slirp4netns
347345
COPY ./Dockerfile.d/home_rootless_.config_systemd_user_containerd.service.d_port-slirp4netns.conf /home/rootless/.config/systemd/user/containerd.service.d/port-slirp4netns.conf
348346
RUN chown -R rootless:rootless /home/rootless/.config
349347

350-
FROM test-integration AS test-integration-ipv6
351-
CMD ["gotestsum", "--format=testname", "--rerun-fails=2", "--packages=./cmd/nerdctl/...", \
352-
"--", "-timeout=60m", "-p", "1", "-args", "-test.allow-kill-daemon", "-test.only-ipv6"]
353-
354348
FROM base AS demo

Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ lint-yaml:
8686
lint-shell: $(call recursive_wildcard,$(MAKEFILE_DIR)/,*.sh)
8787
shellcheck -a -x $^
8888

89+
test-unit:
90+
go test -v $(MAKEFILE_DIR)/pkg/...
91+
8992
binaries: nerdctl
9093

9194
install:

0 commit comments

Comments
 (0)