From 9630f6322465892246cbec9aca3c976da4f083d2 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Tue, 14 Apr 2020 12:32:31 +0300 Subject: [PATCH 1/2] .circleci: enable -coverpkg=all We want to count test for coverage irregardless of where it is located. Previously error "no non-test Go files" was preventing us from doing so. This commit fixes it. --- .circleci/config.yml | 2 +- .travis.yml | 2 +- Makefile | 2 +- integration/plug.go | 6 ++++++ 4 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 integration/plug.go diff --git a/.circleci/config.yml b/.circleci/config.yml index e4dfc57ae..53744a44b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -82,7 +82,7 @@ jobs: - run: git submodule sync - run: git submodule update --init - gomod - - run: go test -v -race ./... -coverprofile=coverage.txt -covermode=atomic + - run: go test -v -race ./... -coverprofile=coverage.txt -covermode=atomic -coverpkg=all - codecov/upload: file: coverage.txt diff --git a/.travis.yml b/.travis.yml index 86671839c..c6c715776 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ install: - go mod tidy -v script: - golint -set_exit_status ./... - - go test -v -race -coverprofile=coverage.txt -covermode=atomic ./... + - go test -v -race -coverprofile=coverage.txt -covermode=atomic -coverpkg=all ./... after_success: - bash <(curl -s https://codecov.io/bash) matrix: diff --git a/Makefile b/Makefile index 5edcc1484..8d422d062 100644 --- a/Makefile +++ b/Makefile @@ -93,7 +93,7 @@ fmt: @gofmt -l -w -s $$(find . -type f -name '*.go'| grep -v "/vendor/") cover: - @go test -v -race ./... -coverprofile=coverage.txt -covermode=atomic + @go test -v -race ./... -coverprofile=coverage.txt -covermode=atomic -coverpkg=all @go tool cover -html=coverage.txt -o coverage.html # --- Environment --- diff --git a/integration/plug.go b/integration/plug.go new file mode 100644 index 000000000..b496ca5d5 --- /dev/null +++ b/integration/plug.go @@ -0,0 +1,6 @@ +// Package integration contains integration tests. +// See README.md for more info. +// This file exists with the sole purpose to get rid of +// "go build github.com/nspcc-dev/neo-go/integration: no non-test Go files in *" +// when running `go test -coverpkg=all`. +package integration From 86c9bcbffea0e198b515e36c02b5508f93ac9292 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Tue, 14 Apr 2020 15:06:05 +0300 Subject: [PATCH 2/2] .circleci: use a separate job for coverage testing When using -race flag more memory can be consumed. --- .circleci/config.yml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 53744a44b..cb810905a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -82,7 +82,19 @@ jobs: - run: git submodule sync - run: git submodule update --init - gomod - - run: go test -v -race ./... -coverprofile=coverage.txt -covermode=atomic -coverpkg=all + - run: go test -v -race ./... + + test_cover: + working_directory: /go/src/github.com/nspcc-dev/neo-go + executor: go1_14 + environment: + CGO_ENABLED: 0 + steps: + - checkout + - run: git submodule sync + - run: git submodule update --init + - gomod + - run: go test -v ./... -coverprofile=coverage.txt -covermode=atomic -coverpkg=all - codecov/upload: file: coverage.txt @@ -142,6 +154,10 @@ workflows: filters: tags: only: v/[0-9]+\.[0-9]+\.[0-9]+/ + - test_cover: + filters: + tags: + only: v/[0-9]+\.[0-9]+\.[0-9]+/ - build_cli: filters: tags: