From 57cc07e0c521d4ac70fb7be276f925cbe09c3d76 Mon Sep 17 00:00:00 2001 From: Daniel Pacak Date: Tue, 30 Jun 2020 17:06:53 +0200 Subject: [PATCH] test(integration): Add scaffold for running integration tests Signed-off-by: Daniel Pacak --- .github/workflows/build.yaml | 17 ++++++++++++++++- .github/workflows/release.yaml | 2 +- Makefile | 5 ++++- test/integration_test.go | 14 ++++++++++++++ 4 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 test/integration_test.go diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 41883f25c..62da14e46 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -34,12 +34,27 @@ jobs: - name: Verify generated code run: GOPATH="$(go env GOPATH)" ./hack/verify-codegen.sh - name: Run unit tests - run: make test + run: make unit-tests - name: Upload code coverage uses: codecov/codecov-action@v1 with: token: ${{ secrets.CODECOV_TOKEN }} file: ./coverage.txt + - name: Setup Kubernetes cluster (KIND) + uses: engineerd/setup-kind@v0.4.0 + - name: Test connection to Kubernetes cluster + run: | + kubectl cluster-info + echo $HOME + - name: Run integration tests + run: | + echo $HOME + pwd + make integration-tests + ./bin/starboard version + ls -R + env: + KUBECONFIG: /home/runner/.kube/config - name: Release snapshot uses: goreleaser/goreleaser-action@v2 with: diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index fd566a9df..74ca7c007 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -17,7 +17,7 @@ jobs: with: fetch-depth: 0 - name: Run unit tests - run: make test + run: make unit-tests - name: Release uses: goreleaser/goreleaser-action@v2 with: diff --git a/Makefile b/Makefile index a1861f455..383d6dbe1 100644 --- a/Makefile +++ b/Makefile @@ -6,5 +6,8 @@ build: starboard $(BINARY): $(SOURCES) CGO_ENABLED=0 go build -o ./bin/$(BINARY) ./cmd/starboard/main.go -test: $(SOURCES) +unit-tests: $(SOURCES) go test -v -short -race -timeout 30s -coverprofile=coverage.txt -covermode=atomic ./... + +integration-tests: build + go test -v test/integration_test.go diff --git a/test/integration_test.go b/test/integration_test.go new file mode 100644 index 000000000..ab377e83a --- /dev/null +++ b/test/integration_test.go @@ -0,0 +1,14 @@ +package test + +import ( + "os" + "testing" +) + +func TestIntegration(t *testing.T) { + if testing.Short() { + t.Skip("Integration test") + } + + t.Logf("Kubeconfig: %v", os.Getenv("KUBECONFIG")) +}