diff --git a/.github/workflows/codecov.yaml b/.github/workflows/codecov.yaml index 5f27d53..0dc3bc7 100644 --- a/.github/workflows/codecov.yaml +++ b/.github/workflows/codecov.yaml @@ -15,6 +15,13 @@ jobs: codecov: timeout-minutes: 15 + services: + pulsar: + image: apachepulsar/pulsar-standalone:2.8.4 + ports: + - 6650:6650 + - 8080:8080 + name: Coverage runs-on: ubuntu-latest steps: @@ -32,8 +39,9 @@ jobs: - name: Get dependencies run: go version && go mod download + # sleep to make sure that pulsar container is ready - name: Run tests with coverage - run: make test-coverage + run: sleep 20 && make test-integration-coverage - name: Upload coverage to Codecov uses: codecov/codecov-action@v3 diff --git a/.github/workflows/go.yaml b/.github/workflows/go.yaml index 567fc6e..f08222f 100644 --- a/.github/workflows/go.yaml +++ b/.github/workflows/go.yaml @@ -17,13 +17,6 @@ jobs: matrix: go: ['1.21'] - services: - pulsar: - image: apachepulsar/pulsar-standalone:2.8.4 - ports: - - 6650:6650 - - 8080:8080 - steps: - name: Set up Go 1.x uses: actions/setup-go@v3 @@ -40,9 +33,8 @@ jobs: - name: Get dependencies run: go mod download - # sleep to make sure that pulsar container is ready - name: Run tests - run: sleep 20 && make test-integration + run: make test - name: Run linter run: make lint diff --git a/Makefile b/Makefile index bc01e5e..c026041 100644 --- a/Makefile +++ b/Makefile @@ -12,8 +12,13 @@ test: ## run tests test-integration: ## run integration tests go test -tags integration -race -p 1 ./... +test-integration-coverage: ## run integration tests with coverage + go test -tags integration -race -p 1 ./... -coverprofile .testCoverage -covermode=atomic -coverpkg=./... + go tool cover -func .testCoverage | grep total | awk '{print "Total coverage: "$$3}' + test-coverage: ## run unit tests and create test coverage - go test ./... -coverprofile .testCoverage -covermode=atomic -coverpkg=./... + CGO_ENABLED=0 go test ./... -coverprofile .testCoverage -covermode=atomic -coverpkg=./... + go tool cover -func .testCoverage | grep total | awk '{print "Total coverage: "$$3}' test-coverage-web: test-coverage ## run unit tests and show test coverage in browser go tool cover -func .testCoverage | grep total | awk '{print "Total coverage: "$$3}'