From 53b9fb424f249614d97002ac259a7144ae04980d Mon Sep 17 00:00:00 2001 From: Seth Wright Date: Mon, 12 Sep 2022 11:03:16 -0400 Subject: [PATCH] Add Coveralls for testing code coverage --- .github/workflows/run-tests.yaml | 22 ++++++++++++++++++---- .gitignore | 1 + Makefile | 6 ++++++ 3 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 Makefile diff --git a/.github/workflows/run-tests.yaml b/.github/workflows/run-tests.yaml index 15112b3..b11f79c 100644 --- a/.github/workflows/run-tests.yaml +++ b/.github/workflows/run-tests.yaml @@ -15,7 +15,21 @@ jobs: with: go-version: 1.18 - uses: actions/checkout@v3 - - name: Build - run: go build -v ./... - - name: Test - run: go test -v ./... \ No newline at end of file + # Install gotestfmt on the VM running the action. + - name: Set up gotestfmt + uses: haveyoudebuggedit/gotestfmt-action@v2 + with: + # Optional: pass GITHUB_TOKEN to avoid rate limiting. + token: ${{ secrets.GITHUB_TOKEN }} + + # Run tests with nice formatting. Save the original log in /tmp/gotest.log + - name: Run tests + run: make test-and-cover 2>&1 | tee /tmp/gotest.log | grep '"Time"' | gotestfmt + - name: Install goveralls + env: + GO111MODULE: "off" + run: go get github.com/mattn/goveralls + - name: Send coverage + env: + COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: goveralls -coverprofile=profile.cov -service=github diff --git a/.gitignore b/.gitignore index 9eec2c3..4439b62 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /geneva /geneva.exe +profile.cov diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..2b6854d --- /dev/null +++ b/Makefile @@ -0,0 +1,6 @@ + +test-and-cover: + @TP=$$(go list ./...) && \ + CP=$$(echo $$TP | tr ' ', ',') && \ + set -x && \ + GO111MODULE=on go test -json -race -failfast -covermode=atomic -coverprofile=profile.cov -coverpkg "$$CP" $$TP