Skip to content

Commit

Permalink
Fix regression on Windows; run sanity tests on Windows (#162)
Browse files Browse the repository at this point in the history
  • Loading branch information
viswajithiii authored Apr 25, 2021
1 parent f7e6f6e commit c53952b
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
35 changes: 34 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
orbs:
win: circleci/[email protected]

executors:
custom:
docker:
Expand Down Expand Up @@ -70,6 +73,7 @@ jobs:
root: /home/circleci/kube-linter
paths:
- .gobin/kube-linter
- bin/windows/kube-linter.exe

e2e-test:
executor: custom
Expand All @@ -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:
Expand Down Expand Up @@ -177,6 +206,10 @@ workflows:
<<: *runOnAllTags
requires:
- build
- sanity-test-windows:
<<: *runOnAllTags
requires:
- build
- image:
<<: *runOnAllTags
context: docker-io-push
5 changes: 4 additions & 1 deletion pkg/builtinchecks/built_in_checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package builtinchecks

import (
"embed"
"fmt"
"path/filepath"
"sync"

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c53952b

Please sign in to comment.