From e73307449a99e62e3310e7571be2d7843b99e7ec Mon Sep 17 00:00:00 2001 From: khanhtc1202 Date: Wed, 19 Jul 2023 21:48:01 +0700 Subject: [PATCH 1/3] Update go test command Signed-off-by: khanhtc1202 --- .gitignore | 1 + Makefile | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 24bdd499ed..144a47fcf2 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ # Output of the go coverage tool, specifically when used with LiteIDE *.out +coverage.txt .DS_Store diff --git a/Makefile b/Makefile index 8637c3772a..953572684e 100644 --- a/Makefile +++ b/Makefile @@ -74,7 +74,7 @@ test: test/go test/web .PHONY: test/go test/go: - go test ./pkg/... ./cmd/... + go test -failfast -race -covermode=atomic -coverprofile=coverage.txt ./pkg/... ./cmd/... .PHONY: test/web test/web: From c82853c08fe3542310eadc9cbfa14b59a8c368ae Mon Sep 17 00:00:00 2001 From: khanhtc1202 Date: Wed, 19 Jul 2023 22:28:55 +0700 Subject: [PATCH 2/3] Update makefile and github action command Signed-off-by: khanhtc1202 --- .github/workflows/test.yaml | 2 +- Makefile | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index c6137ad21b..15aabbe4c6 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -24,7 +24,7 @@ jobs: go-version: ${{ env.GO_VERSION }} cache: true - name: Run unit tests - run: make test/go + run: make test/go COVERAGE=true - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v3 env: diff --git a/Makefile b/Makefile index 953572684e..b027b328df 100644 --- a/Makefile +++ b/Makefile @@ -73,8 +73,17 @@ push/chart: test: test/go test/web .PHONY: test/go +test/go: COVERAGE ?= false +test/go: COVERAGE_OPTS ?= -covermode=atomic +test/go: COVERAGE_OUTPUT ?= coverage.out test/go: - go test -failfast -race -covermode=atomic -coverprofile=coverage.txt ./pkg/... ./cmd/... +ifeq ($(COVERAGE), true) + go test -failfast -race $(COVERAGE_OPTS) -coverprofile=$(COVERAGE_OUTPUT).tmp ./pkg/... ./cmd/... + cat $(COVERAGE_OUTPUT).tmp | grep -v ".pb.go\|.pb.validate.go" > $(COVERAGE_OUTPUT) + rm -rf $(COVERAGE_OUTPUT).tmp +else + go test -failfast -race ./pkg/... ./cmd/... +endif .PHONY: test/web test/web: From 51744bdbb58a2692ab1fd07dd7692014b8c9f46d Mon Sep 17 00:00:00 2001 From: khanhtc1202 Date: Thu, 20 Jul 2023 08:28:39 +0700 Subject: [PATCH 3/3] Revert gitignore Signed-off-by: khanhtc1202 --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 144a47fcf2..24bdd499ed 100644 --- a/.gitignore +++ b/.gitignore @@ -10,7 +10,6 @@ # Output of the go coverage tool, specifically when used with LiteIDE *.out -coverage.txt .DS_Store