Skip to content

Commit c53952b

Browse files
authored
Fix regression on Windows; run sanity tests on Windows (#162)
1 parent f7e6f6e commit c53952b

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

.circleci/config.yml

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
orbs:
2+
win: circleci/[email protected]
3+
14
executors:
25
custom:
36
docker:
@@ -70,6 +73,7 @@ jobs:
7073
root: /home/circleci/kube-linter
7174
paths:
7275
- .gobin/kube-linter
76+
- bin/windows/kube-linter.exe
7377

7478
e2e-test:
7579
executor: custom
@@ -82,7 +86,32 @@ jobs:
8286
name: Run E2E tests
8387
command: |
8488
make e2e-test
85-
89+
90+
sanity-test-windows:
91+
executor:
92+
name: win/default # references orb defined above.
93+
size: "medium"
94+
95+
steps:
96+
- checkout
97+
- attach_workspace:
98+
at: /home/circleci/kube-linter
99+
100+
- run:
101+
name: Run E2E tests
102+
shell: bash.exe
103+
command: |
104+
# In Windows, the workspace is attached relative to the current directory.
105+
tag="$(./get-tag)"
106+
cd home/circleci/kube-linter/bin/windows
107+
version_from_bin="$(./kube-linter.exe version)"
108+
echo "Expected tag ${tag}, got ${version_from_bin}"
109+
[[ "${tag}" == "${version_from_bin}" ]]
110+
111+
# Make sure the lint command can run without errors.
112+
# TODO: run the full suite of E2E tests on Windows.
113+
./kube-linter.exe lint .
114+
86115
image:
87116
executor: custom
88117
steps:
@@ -177,6 +206,10 @@ workflows:
177206
<<: *runOnAllTags
178207
requires:
179208
- build
209+
- sanity-test-windows:
210+
<<: *runOnAllTags
211+
requires:
212+
- build
180213
- image:
181214
<<: *runOnAllTags
182215
context: docker-io-push

pkg/builtinchecks/built_in_checks.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package builtinchecks
22

33
import (
44
"embed"
5+
"fmt"
56
"path/filepath"
67
"sync"
78

@@ -47,7 +48,9 @@ func List() ([]config.Check, error) {
4748
loadErr = errors.Errorf("found unexpected entry %s in yamls directory", entry.Name())
4849
return
4950
}
50-
contents, err := yamlFiles.ReadFile(filepath.Join("yamls", entry.Name()))
51+
// Do NOT use filepath.Join here, because embed always uses `/` as the separator,
52+
// irrespective of the OS we're running.
53+
contents, err := yamlFiles.ReadFile(fmt.Sprintf("yamls/%s", entry.Name()))
5154
if err != nil {
5255
loadErr = errors.Wrapf(err, "loading file %s", entry.Name())
5356
return

0 commit comments

Comments
 (0)