From 2547246f84db364949e5535a597e01d7b3fc8b53 Mon Sep 17 00:00:00 2001 From: Anirudha Bose Date: Mon, 24 Aug 2020 20:58:47 +0200 Subject: [PATCH] GitHub Actions: Enable Go Race detector and code coverage This modifies the goclean.sh script to run tests with the race detector enabled. It also enables code coverage, and uploads the results to coveralls.io. Running tests with -race and -cover flags was disabled in 6487ba1 and 6788df7 respectively, due to some limits on time/goroutines being hit on Travis CI. Since we have migrated to GitHub Actions, it is desirable to bring them back. --- .github/workflows/go.yml | 5 +++++ .gitignore | 4 ++++ README.md | 1 + goclean.sh | 5 +++-- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index f722032b..7573dbe5 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -25,3 +25,8 @@ jobs: GO111MODULE: "on" run: | sh ./goclean.sh + + - name: Send coverage + uses: shogo82148/actions-goveralls@v1 + with: + path-to-profile: profile.cov diff --git a/.gitignore b/.gitignore index 72fb9416..c3effe5f 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,7 @@ _cgo_export.* _testmain.go *.exe + +# Code coverage files +profile.tmp +profile.cov diff --git a/README.md b/README.md index 352252dd..d0ec9924 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ btcd ==== [![Build Status](https://github.com/btcsuite/btcd/workflows/Build%20and%20Test/badge.svg)](https://github.com/btcsuite/btcd/actions) +[![Coverage Status](https://coveralls.io/repos/github/btcsuite/btcd/badge.svg?branch=master)](https://coveralls.io/github/btcsuite/btcd?branch=master) [![ISC License](https://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org) [![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg)](https://godoc.org/github.com/btcsuite/btcd) diff --git a/goclean.sh b/goclean.sh index bb0cd7b6..dad9f8f1 100755 --- a/goclean.sh +++ b/goclean.sh @@ -4,11 +4,12 @@ # 3. go vet (http://golang.org/cmd/vet) # 4. gosimple (https://github.com/dominikh/go-simple) # 5. unconvert (https://github.com/mdempsky/unconvert) -# +# 6. race detector (http://blog.golang.org/race-detector) +# 7. test coverage (http://blog.golang.org/cover) set -ex -go test -tags="rpctest" ./... +env GORACE="halt_on_error=1" go test -race -tags="rpctest" -covermode atomic -coverprofile=profile.cov ./... # Automatic checks golangci-lint run --deadline=10m --disable-all \