Skip to content

Commit 2bd1b18

Browse files
authored
Merge pull request containerd#4161 from apostasie/ci-2025-04-ci-cleanup-b3
[CI]: cleanup, breakout 3: separate jobs
2 parents f289b99 + 20b67dd commit 2bd1b18

File tree

5 files changed

+117
-40
lines changed

5 files changed

+117
-40
lines changed

.github/workflows/job-test-unit.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Note: freebsd tests are not ran here (see integration instead)
2+
name: test-unit
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
timeout:
8+
required: true
9+
type: number
10+
go-version:
11+
required: true
12+
type: string
13+
runner:
14+
required: true
15+
type: string
16+
canary:
17+
required: false
18+
default: false
19+
type: boolean
20+
windows-cni-version:
21+
required: true
22+
type: string
23+
linux-cni-version:
24+
required: true
25+
type: string
26+
linux-cni-sha:
27+
required: true
28+
type: string
29+
30+
env:
31+
GOTOOLCHAIN: local
32+
# Windows fails without this
33+
CGO_ENABLED: 0
34+
35+
jobs:
36+
test-unit:
37+
name: ${{ format('{0}{1}', inputs.runner, inputs.canary && ' (go canary)' || '') }}
38+
timeout-minutes: ${{ inputs.timeout }}
39+
runs-on: "${{ inputs.runner }}"
40+
defaults:
41+
run:
42+
shell: bash
43+
44+
env:
45+
GO_VERSION: ${{ inputs.go-version }}
46+
47+
steps:
48+
- name: "Init: checkout"
49+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
50+
with:
51+
fetch-depth: 1
52+
53+
# If canary is requested, check for the latest unstable release
54+
- if: ${{ inputs.canary }}
55+
name: "Init (canary): retrieve GO_VERSION"
56+
run: |
57+
latest_go="$(. ./hack/provisioning/version/fetch.sh; go::canary::for::go-setup)"
58+
printf "GO_VERSION=%s\n" "$latest_go" >> "$GITHUB_ENV"
59+
[ "$latest_go" != "" ] || \
60+
echo "::warning title=No canary go::There is currently no canary go version to test. Following steps will not run."
61+
62+
- if: ${{ env.GO_VERSION != '' }}
63+
name: "Init: install go"
64+
uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.0
65+
with:
66+
go-version: ${{ env.GO_VERSION }}
67+
check-latest: true
68+
69+
# Install CNI
70+
- if: ${{ env.GO_VERSION != '' }}
71+
name: "Init: set up CNI"
72+
run: |
73+
if [ "$RUNNER_OS" == "Windows" ]; then
74+
GOPATH=$(go env GOPATH) WINCNI_VERSION=${{ inputs.windows-cni-version }} ./hack/provisioning/windows/cni.sh
75+
elif [ "$RUNNER_OS" == "Linux" ]; then
76+
./hack/provisioning/linux/cni.sh "${{ inputs.linux-cni-version }}" "amd64" "${{ inputs.linux-cni-sha }}"
77+
fi
78+
79+
- if: ${{ env.GO_VERSION != '' }}
80+
name: "Run"
81+
run: |
82+
make test-unit
83+
84+
# On linux, also run with root
85+
- if: ${{ env.GO_VERSION != '' && env.RUNNER_OS == 'Linux' }}
86+
name: "Run: with root"
87+
run: |
88+
sudo make test-unit

.github/workflows/test-canary.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ jobs:
4141
docker run --privileged --rm tonistiigi/binfmt --install linux/amd64
4242
docker run --privileged --rm tonistiigi/binfmt --install linux/arm64
4343
docker run --privileged --rm tonistiigi/binfmt --install linux/arm/v7
44-
- name: "Run unit tests"
45-
run: go test -v ./pkg/...
4644
- name: "Run integration tests"
4745
run: docker run -t --rm --privileged test-integration ./hack/test-integration.sh -test.only-flaky=false
4846
- name: "Run integration tests (flaky)"

.github/workflows/test.yml renamed to .github/workflows/workflow-test.yml

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -52,40 +52,31 @@ jobs:
5252
--target build-dependencies --build-arg CONTAINERD_VERSION=${CONTAINERD_VERSION} .
5353
5454
test-unit:
55-
# FIXME:
56-
# 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
57-
# Apparently does not
58-
# timeout-minutes: ${{ fromJSON(env.SHORT_TIMEOUT) }}
59-
timeout-minutes: 10
60-
name: unit | ${{ matrix.goos }}
61-
runs-on: "${{ matrix.os }}"
62-
defaults:
63-
run:
64-
shell: bash
55+
name: "unit${{ inputs.hack }}"
56+
uses: ./.github/workflows/job-test-unit.yml
6557
strategy:
6658
fail-fast: false
6759
matrix:
60+
# Run on all supported platforms but freebsd
61+
# Additionally run on canary for linux
6862
include:
69-
- os: windows-2022
70-
goos: windows
71-
- os: ubuntu-24.04
72-
goos: linux
73-
- os: macos-15
74-
goos: darwin
75-
steps:
76-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
77-
with:
78-
fetch-depth: 1
79-
- name: "Install go"
80-
uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.0
81-
with:
82-
go-version: ${{ env.GO_VERSION }}
83-
check-latest: true
84-
- if: ${{ matrix.goos=='windows' }}
85-
name: "Set up CNI"
86-
run: GOPATH=$(go env GOPATH) ./hack/provisioning/windows/cni.sh
87-
- name: "Run unit tests"
88-
run: make test-unit
63+
- runner: "ubuntu-24.04"
64+
canary: false
65+
- runner: "macos-15"
66+
canary: false
67+
- runner: "windows-2025"
68+
canary: false
69+
- runner: "ubuntu-24.04"
70+
canary: true
71+
with:
72+
runner: ${{ matrix.runner }}
73+
canary: ${{ matrix.canary }}
74+
# Windows routinely go over 5 minutes
75+
timeout: 10
76+
go-version: 1.24
77+
windows-cni-version: v0.3.1
78+
linux-cni-version: v1.7.1
79+
linux-cni-sha: 1a28a0506bfe5bcdc981caf1a49eeab7e72da8321f1119b7be85f22621013098
8980

9081
test-integration:
9182
needs: build-dependencies

pkg/imgutil/dockerconfigresolver/credentialsstore_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ import (
2525
"testing"
2626

2727
"gotest.tools/v3/assert"
28+
29+
"github.com/containerd/nerdctl/v2/pkg/rootlessutil"
2830
)
2931

3032
func createTempDir(t *testing.T, mode os.FileMode) string {
@@ -40,12 +42,10 @@ func createTempDir(t *testing.T, mode os.FileMode) string {
4042
}
4143

4244
func TestBrokenCredentialsStore(t *testing.T) {
43-
if runtime.GOOS == "freebsd" {
44-
// It is unclear why these tests are failing on FreeBSD, and if it is a problem with Vagrant or differences
45-
// with FreeBSD
46-
// Anyhow, this test is about extreme cases & conditions (filesystem errors wrt credentials loading).
47-
t.Skip("skipping broken credential store tests for freebsd")
45+
if !rootlessutil.IsRootless() {
46+
t.Skip("test is for rootless")
4847
}
48+
4949
if runtime.GOOS == "windows" {
5050
// Same as above
5151
t.Skip("test is not compatible with windows")

pkg/netutil/netutil_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import (
3434
"github.com/containerd/nerdctl/v2/pkg/testutil"
3535
)
3636

37-
const testBridgeIP = "10.1.100.1/24" // nolint:unused
37+
const testBridgeIP = "10.42.100.1/24" // nolint:unused
3838

3939
const preExistingNetworkConfigTemplate = `
4040
{
@@ -278,8 +278,8 @@ func testDefaultNetworkCreationWithBridgeIP(t *testing.T) {
278278
// Assert on bridge plugin configuration
279279
assert.Equal(t, "bridge", bridgeConfig.Type)
280280
// Assert on IPAM configuration
281-
assert.Equal(t, "10.1.100.1", bridgeConfig.IPAM.Ranges[0][0].Gateway)
282-
assert.Equal(t, "10.1.100.0/24", bridgeConfig.IPAM.Ranges[0][0].Subnet)
281+
assert.Equal(t, "10.42.100.1", bridgeConfig.IPAM.Ranges[0][0].Gateway)
282+
assert.Equal(t, "10.42.100.0/24", bridgeConfig.IPAM.Ranges[0][0].Subnet)
283283
assert.Equal(t, "0.0.0.0/0", bridgeConfig.IPAM.Routes[0].Dst)
284284
assert.Equal(t, "host-local", bridgeConfig.IPAM.Type)
285285

0 commit comments

Comments
 (0)