diff --git a/.circleci/config.yml b/.circleci/config.yml index 5498b1e08..5fcd0659f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,3 +1,6 @@ +orbs: + win: circleci/windows@2.4.0 + executors: custom: docker: @@ -70,6 +73,7 @@ jobs: root: /home/circleci/kube-linter paths: - .gobin/kube-linter + - bin/windows/kube-linter.exe e2e-test: executor: custom @@ -82,7 +86,32 @@ jobs: name: Run E2E tests command: | make e2e-test - + + sanity-test-windows: + executor: + name: win/default # references orb defined above. + size: "medium" + + steps: + - checkout + - attach_workspace: + at: /home/circleci/kube-linter + + - run: + name: Run E2E tests + shell: bash.exe + command: | + # In Windows, the workspace is attached relative to the current directory. + tag="$(./get-tag)" + cd home/circleci/kube-linter/bin/windows + version_from_bin="$(./kube-linter.exe version)" + echo "Expected tag ${tag}, got ${version_from_bin}" + [[ "${tag}" == "${version_from_bin}" ]] + + # Make sure the lint command can run without errors. + # TODO: run the full suite of E2E tests on Windows. + ./kube-linter.exe lint . + image: executor: custom steps: @@ -177,6 +206,10 @@ workflows: <<: *runOnAllTags requires: - build + - sanity-test-windows: + <<: *runOnAllTags + requires: + - build - image: <<: *runOnAllTags context: docker-io-push diff --git a/pkg/builtinchecks/built_in_checks.go b/pkg/builtinchecks/built_in_checks.go index 30c2979dc..293a51d3f 100644 --- a/pkg/builtinchecks/built_in_checks.go +++ b/pkg/builtinchecks/built_in_checks.go @@ -2,6 +2,7 @@ package builtinchecks import ( "embed" + "fmt" "path/filepath" "sync" @@ -47,7 +48,9 @@ func List() ([]config.Check, error) { loadErr = errors.Errorf("found unexpected entry %s in yamls directory", entry.Name()) return } - contents, err := yamlFiles.ReadFile(filepath.Join("yamls", entry.Name())) + // Do NOT use filepath.Join here, because embed always uses `/` as the separator, + // irrespective of the OS we're running. + contents, err := yamlFiles.ReadFile(fmt.Sprintf("yamls/%s", entry.Name())) if err != nil { loadErr = errors.Wrapf(err, "loading file %s", entry.Name()) return