diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ad18e908..27821407 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,4 +22,6 @@ jobs: - name: Go mod download and go tidy run: make setup - name: Run tests + env: + USE_KIND: "true" run: make test diff --git a/README.md b/README.md index f4fcf1d5..31cf801a 100644 --- a/README.md +++ b/README.md @@ -340,7 +340,7 @@ If you'd like to fix a bug, contribute a feature or just correct a typo, please 1. Add your forked repo as a fork: `git remote add fork https://github.com/you-are-awesome/kubeaudit` 1. Create your feature branch: `git checkout -b awesome-new-feature` 1. Install [Kind](https://kind.sigs.k8s.io/#installation-and-usage) -1. Run the tests to see everything is working as expected: `make test` (to run tests without Kind: `USE_KIND=false make test`) +1. Run the tests to see everything is working as expected: `USE_KIND=true make test` (to run tests without Kind: `make test`) 1. Commit your changes: `git commit -am 'Adds awesome feature'` 1. Push to the branch: `git push fork` 1. Sign the [Contributor License Agreement](https://cla.shopify.com/) diff --git a/internal/test/test.go b/internal/test/test.go index b7f4e599..0f97d715 100644 --- a/internal/test/test.go +++ b/internal/test/test.go @@ -137,7 +137,7 @@ func GetAllFileNames(t *testing.T, directory string) []string { // UseKind returns true if tests which utilize Kind should run func UseKind() bool { - return os.Getenv("USE_KIND") != "false" + return os.Getenv("USE_KIND") == "true" } func ApplyManifest(t *testing.T, manifestPath, namespace string) { diff --git a/kubeaudit_test.go b/kubeaudit_test.go index 1370707e..6a127ed3 100644 --- a/kubeaudit_test.go +++ b/kubeaudit_test.go @@ -1,7 +1,6 @@ package kubeaudit_test import ( - "os" "testing" "github.com/Shopify/kubeaudit" @@ -29,7 +28,7 @@ func TestNew(t *testing.T) { } func TestAuditLocal(t *testing.T) { - if os.Getenv("USE_KIND") == "false" { + if !test.UseKind() { return } diff --git a/test.sh b/test.sh index f125cd81..1d6ca6b4 100755 --- a/test.sh +++ b/test.sh @@ -5,13 +5,13 @@ set -e echo "Starting tests. This may take a while..." function finish { - if [ "$USE_KIND" != "false" ] ; then + if [ "$USE_KIND" == "true" ] ; then make test-teardown fi } trap finish EXIT -if [ "$USE_KIND" != "false" ] ; then +if [ "$USE_KIND" == "true" ] ; then make test-setup fi