Skip to content

Commit

Permalink
Add Coveralls for testing code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Crosse committed Sep 12, 2022
1 parent e9059a4 commit 53b9fb4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
22 changes: 18 additions & 4 deletions .github/workflows/run-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ./...
# 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/geneva
/geneva.exe
profile.cov
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 53b9fb4

Please sign in to comment.