From 3bf29d835269a04b2d0e1a079d349911020a3506 Mon Sep 17 00:00:00 2001 From: Grigory Efimov Date: Wed, 11 Jan 2023 19:59:54 +0300 Subject: [PATCH] refact --- .github/workflows/coverage.yml | 7 ++++--- Makefile | 16 +++++----------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 8bf31192..27b222a9 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -19,15 +19,16 @@ jobs: - name: deps run: make deps - - name: vet - run: make vet + - name: unit tests - run: make test-coverage + run: make test - name: Quality Gate - Test coverage shall be above threshold env: TESTCOVERAGE_THRESHOLD: 0 run: | + go test ./... -coverprofile coverage.out -covermode count + go tool cover -func coverage.out echo "Quality Gate: checking test coverage is above threshold ..." echo "Threshold : $TESTCOVERAGE_THRESHOLD %" totalCoverage=`go tool cover -func=coverage.out | grep total | grep -Eo '[0-9]+\.[0-9]+'` diff --git a/Makefile b/Makefile index 140356d4..d2229111 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: proto test test-coverage vet deps +.PHONY: proto test deps export GOPRIVATE=github.com/anytypeio export PATH:=deps:$(PATH) @@ -16,17 +16,11 @@ proto: protoc --gogofaster_out=$(PKGMAP):. --go-drpc_out=protolib=github.com/gogo/protobuf:. commonspace/spacesyncproto/protos/*.proto protoc --gogofaster_out=$(PKGMAP):. --go-drpc_out=protolib=github.com/gogo/protobuf:. commonfile/fileproto/protos/*.proto -vet: - go vet ./... - -test: - go test ./... --cover - -test-coverage: - go test ./... -coverprofile coverage.out -covermode count - go tool cover -func coverage.out - deps: go mod download go build -o deps storj.io/drpc/cmd/protoc-gen-go-drpc go build -o deps github.com/gogo/protobuf/protoc-gen-gogofaster + +test: + go test ./... --cover +