Skip to content

Commit c05251d

Browse files
authored
Merge pull request containerd#3566 from apostasie/part6
Fix and enable CI unit testing for windows
2 parents 388fe79 + ca76611 commit c05251d

File tree

9 files changed

+69
-4
lines changed

9 files changed

+69
-4
lines changed

.github/workflows/test.yml

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,19 @@ jobs:
4040
make lint-imports
4141
4242
test-unit:
43-
runs-on: ubuntu-24.04
44-
timeout-minutes: 20
43+
timeout-minutes: 5
44+
name: unit | ${{ matrix.goos }}
45+
runs-on: "${{ matrix.os }}"
46+
defaults:
47+
run:
48+
shell: bash
49+
strategy:
50+
matrix:
51+
include:
52+
- os: windows-2022
53+
goos: windows
54+
- os: ubuntu-24.04
55+
goos: linux
4556
steps:
4657
- uses: actions/[email protected]
4758
with:
@@ -51,6 +62,17 @@ jobs:
5162
go-version: ${{ env.GO_VERSION }}
5263
check-latest: true
5364
cache: true
65+
- if: ${{ matrix.goos=='windows' }}
66+
uses: actions/[email protected]
67+
with:
68+
repository: containerd/containerd
69+
ref: v1.7.23
70+
path: containerd
71+
fetch-depth: 1
72+
- if: ${{ matrix.goos=='windows' }}
73+
name: "Set up CNI"
74+
working-directory: containerd
75+
run: GOPATH=$(go env GOPATH) script/setup/install-cni-windows
5476
- name: "Run unit tests"
5577
run: go test -v ./pkg/...
5678

pkg/cmd/builder/build_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
package builder
1818

1919
import (
20+
"fmt"
21+
"path/filepath"
2022
"reflect"
23+
"runtime"
2124
"testing"
2225

2326
specs "github.com/opencontainers/image-spec/specs-go/v1"
@@ -213,6 +216,15 @@ func TestParseBuildctlArgsForOCILayout(t *testing.T) {
213216
},
214217
}
215218

219+
if runtime.GOOS == "windows" {
220+
abspath, err := filepath.Abs("/tmp/oci-layout")
221+
assert.NilError(t, err)
222+
tests[1].expectedErr = fmt.Sprintf(
223+
"open %s\\index.json: The system cannot find the path specified.",
224+
abspath,
225+
)
226+
}
227+
216228
for _, test := range tests {
217229
t.Run(test.name, func(t *testing.T) {
218230
args, err := parseBuildContextFromOCILayout(test.ociLayoutName, test.ociLayoutPath)

pkg/composer/serviceparser/build_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package serviceparser
1818

1919
import (
20+
"runtime"
2021
"testing"
2122

2223
"gotest.tools/v3/assert"
@@ -30,6 +31,11 @@ func lastOf(ss []string) string {
3031

3132
func TestParseBuild(t *testing.T) {
3233
t.Parallel()
34+
35+
if runtime.GOOS == "windows" {
36+
t.Skip("test is not compatible with windows")
37+
}
38+
3339
const dockerComposeYAML = `
3440
services:
3541
foo:

pkg/composer/serviceparser/serviceparser_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"fmt"
2121
"os"
2222
"path/filepath"
23+
"runtime"
2324
"strconv"
2425
"testing"
2526

@@ -79,6 +80,11 @@ var in = strutil.InStringSlice
7980

8081
func TestParse(t *testing.T) {
8182
t.Parallel()
83+
84+
if runtime.GOOS == "windows" {
85+
t.Skip("test is not compatible with windows")
86+
}
87+
8288
const dockerComposeYAML = `
8389
version: '3.1'
8490
@@ -333,6 +339,10 @@ services:
333339

334340
func TestParseRelative(t *testing.T) {
335341
t.Parallel()
342+
343+
if runtime.GOOS == "windows" {
344+
t.Skip("test is not compatible with windows")
345+
}
336346
const dockerComposeYAML = `
337347
services:
338348
foo:
@@ -408,6 +418,9 @@ services:
408418

409419
func TestParseConfigs(t *testing.T) {
410420
t.Parallel()
421+
if runtime.GOOS == "windows" {
422+
t.Skip("test is not compatible with windows")
423+
}
411424
const dockerComposeYAML = `
412425
services:
413426
foo:

pkg/imgutil/dockerconfigresolver/credentialsstore_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ func TestBrokenCredentialsStore(t *testing.T) {
4646
// Anyhow, this test is about extreme cases & conditions (filesystem errors wrt credentials loading).
4747
t.Skip("skipping broken credential store tests for freebsd")
4848
}
49+
if runtime.GOOS == "windows" {
50+
// Same as above
51+
t.Skip("test is not compatible with windows")
52+
}
4953

5054
testCases := []struct {
5155
description string

pkg/inspecttypes/dockercompat/dockercompat_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func TestContainerFromNative(t *testing.T) {
6868
expected: &Container{
6969
Created: "0001-01-01T00:00:00Z",
7070
Platform: runtime.GOOS,
71-
ResolvConfPath: tempStateDir + "/resolv.conf",
71+
ResolvConfPath: filepath.Join(tempStateDir, "resolv.conf"),
7272
State: &ContainerState{
7373
Status: "running",
7474
Running: true,

pkg/logging/cri_logger_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
"os"
3131
"path/filepath"
3232
"reflect"
33+
"runtime"
3334
"testing"
3435
"time"
3536
)
@@ -234,6 +235,9 @@ func TestReadLogsLimitsWithTimestamps(t *testing.T) {
234235

235236
func TestReadRotatedLog(t *testing.T) {
236237
tmpDir := t.TempDir()
238+
if runtime.GOOS == "windows" {
239+
t.Skip("windows implementation does not seem to work right now and should be fixed: https://github.com/containerd/nerdctl/issues/3554")
240+
}
237241
file, err := os.CreateTemp(tmpDir, "logfile")
238242
if err != nil {
239243
t.Errorf("unable to create temp file, error: %s", err.Error())

pkg/logging/json_logger_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,16 @@ import (
2222
"fmt"
2323
"os"
2424
"path/filepath"
25+
"runtime"
2526
"testing"
2627
"time"
2728
)
2829

2930
func TestReadRotatedJSONLog(t *testing.T) {
3031
tmpDir := t.TempDir()
32+
if runtime.GOOS == "windows" {
33+
t.Skip("windows implementation does not seem to work right now and should be fixed: https://github.com/containerd/nerdctl/issues/3554")
34+
}
3135
file, err := os.CreateTemp(tmpDir, "logfile")
3236
if err != nil {
3337
t.Errorf("unable to create temp file, error: %s", err.Error())

pkg/mountutil/mountutil_windows_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func TestParseVolumeOptions(t *testing.T) {
3838
vType: "bind",
3939
src: "dummy",
4040
optsRaw: "rw",
41-
wants: []string{},
41+
wants: nil,
4242
},
4343
{
4444
vType: "volume",

0 commit comments

Comments
 (0)