Skip to content

Commit 7c0d1cd

Browse files
committed
wip
1 parent c1bd618 commit 7c0d1cd

22 files changed

+75
-130
lines changed

.github/workflows/go.yml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,23 @@ jobs:
114114
with:
115115
go-version-file: go.work
116116
id: go
117-
- name: Test all modules
118-
run: make test-unit-non-plugin
117+
## Windows has significant differences from POSIX-compliant OS.
118+
## so it only runs tests for the modules that are released.
119+
- name: Test kyaml
120+
run: make test
121+
working-directory: ./kyaml
122+
- name: Test cmd/config
123+
run: make test
124+
working-directory: ./cmd/config
125+
env:
126+
KUSTOMIZE_DOCKER_E2E: false # docker on windows not working well yet
127+
- name: Test api
128+
run: go test -cover ./... -ldflags "-X sigs.k8s.io/kustomize/api/provenance.buildDate=2023-01-31T23:38:41Z -X sigs.k8s.io/kustomize/api/provenance.version=(test)"
129+
working-directory: ./api
130+
env:
131+
KUSTOMIZE_DOCKER_E2E: false # docker on windows not working well yet
132+
- name: Test kustomize
133+
run: go test -cover ./...
134+
working-directory: ./kustomize
119135
env:
120136
KUSTOMIZE_DOCKER_E2E: false # docker on windows not working well yet

Makefile-modules.mk

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ endif
88
export PATH := $(MYGOBIN):$(PATH)
99

1010
# only set this if not already set, so importing makefiles can override it
11-
export KUSTOMIZE_ROOT ?= $(shell pwd | sed -E 's|(.*\/kustomize)/(.*)|\1|')
11+
export KUSTOMIZE_ROOT ?= $(shell git rev-parse --show-toplevel)
12+
# Calculate the relative path from repo root, removing trailing slash if present
13+
RELATIVE_PATH = $(shell git rev-parse --show-prefix 2>/dev/null | sed 's|/$$||' 2>/dev/null)
1214
include $(KUSTOMIZE_ROOT)/Makefile-tools.mk
1315

1416
.PHONY: lint test fix fmt tidy vet build
@@ -17,7 +19,7 @@ lint: $(MYGOBIN)/golangci-lint
1719
$(MYGOBIN)/golangci-lint cache clean # Workaround for https://github.com/golangci/golangci-lint/issues/3228
1820
$(MYGOBIN)/golangci-lint \
1921
-c $$KUSTOMIZE_ROOT/.golangci.yml \
20-
--path-prefix $(shell pwd | sed -E 's|(.*\/kustomize)/(.*)|\2|') \
22+
--path-prefix $(RELATIVE_PATH) \
2123
run ./...
2224

2325
test:

api/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ test:
77
go test -v -timeout 45m -cover ./... -ldflags "-X sigs.k8s.io/kustomize/api/provenance.buildDate=2023-01-31T23:38:41Z -X sigs.k8s.io/kustomize/api/provenance.version=(test)"
88

99
build:
10-
go build -ldflags "-X sigs.k8s.io/kustomize/api/provenance.buildDate=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")" ./...
10+
go build ./...
1111

1212
generate: $(MYGOBIN)/k8scopy $(MYGOBIN)/stringer
1313
go generate ./...

api/internal/loader/fileloader.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ func (fl *FileLoader) errIfGitContainmentViolation(
238238
"security; bases in kustomizations found in "+
239239
"cloned git repos must be within the repo, "+
240240
"but base '%s' is outside '%s'",
241-
base, containingRepo.CloneDir())
241+
filepath.ToSlash(base.String()), filepath.ToSlash(containingRepo.CloneDir().String()))
242242
}
243243
return nil
244244
}

api/internal/loader/fileloader_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ whatever
401401
require.NoError(err)
402402
repo := l.Repo()
403403
require.Equal(coRoot, repo)
404-
require.Equal(coRoot+"/"+pathInRepo, l.Root())
404+
require.Equal(coRoot+"/"+pathInRepo, filepath.ToSlash(l.Root()))
405405

406406
_, err = l.New(url)
407407
require.Error(err)

api/internal/localizer/localizer_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
// Copyright 2022 The Kubernetes Authors.
22
// SPDX-License-Identifier: Apache-2.0
33

4+
// TODO: Skip on Windows due to this test depends onposix-OS specific filepath.
5+
//go:build !windows
6+
// +build !windows
7+
48
package localizer_test
59

610
import (

api/internal/localizer/locloader_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
// Copyright 2022 The Kubernetes Authors.
22
// SPDX-License-Identifier: Apache-2.0
33

4+
// TODO: Skip on Windows due to this test depends onposix-OS specific filepath.
5+
//go:build !windows
6+
// +build !windows
7+
48
package localizer_test
59

610
import (

api/internal/localizer/util_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,8 @@ func TestLocRootPath_SymlinkPath(t *testing.T) {
317317
}
318318

319319
func TestCleanedRelativePath(t *testing.T) {
320+
// Skip on Windows due to path separator differences
321+
testutil.SkipWindows(t)
320322
fSys := filesys.MakeFsInMemory()
321323
// Use platform-appropriate root path
322324
rootPath := string(filepath.Separator) + "root"

api/internal/target/kusttarget_configplugin.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func (kt *KustTarget) configureBuiltinGenerators() (
4949
generatorOrigin = &resource.Origin{
5050
Repo: kt.origin.Repo,
5151
Ref: kt.origin.Ref,
52-
ConfiguredIn: filepath.Join(kt.origin.Path, kt.kustFileName),
52+
ConfiguredIn: filepath.ToSlash(filepath.Join(kt.origin.Path, kt.kustFileName)),
5353
ConfiguredBy: yaml.ResourceIdentifier{
5454
TypeMeta: yaml.TypeMeta{
5555
APIVersion: "builtin",
@@ -58,7 +58,6 @@ func (kt *KustTarget) configureBuiltinGenerators() (
5858
},
5959
}
6060
}
61-
6261
for i := range r {
6362
result = append(result, &resmap.GeneratorWithProperties{Generator: r[i], Origin: generatorOrigin})
6463
}
@@ -92,7 +91,7 @@ func (kt *KustTarget) configureBuiltinTransformers(
9291
transformerOrigin = &resource.Origin{
9392
Repo: kt.origin.Repo,
9493
Ref: kt.origin.Ref,
95-
ConfiguredIn: filepath.Join(kt.origin.Path, kt.kustFileName),
94+
ConfiguredIn: filepath.ToSlash(filepath.Join(kt.origin.Path, kt.kustFileName)),
9695
ConfiguredBy: yaml.ResourceIdentifier{
9796
TypeMeta: yaml.TypeMeta{
9897
APIVersion: "builtin",

api/krusty/accumulation_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"sigs.k8s.io/kustomize/api/konfig"
1818
"sigs.k8s.io/kustomize/api/krusty"
1919
kusttest_test "sigs.k8s.io/kustomize/api/testutils/kusttest"
20+
"sigs.k8s.io/kustomize/kyaml/testutil"
2021
)
2122

2223
const validResource = `
@@ -184,6 +185,8 @@ spec:
184185
}
185186

186187
func TestAccumulateResourcesErrors(t *testing.T) {
188+
// Skip on Windows due to posix-OS specific error messages.
189+
testutil.SkipWindows(t)
187190
type testcase struct {
188191
name string
189192
resource string

0 commit comments

Comments
 (0)