Skip to content

Commit

Permalink
improve coverage calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
muir committed Aug 22, 2022
1 parent 4f2c96a commit 05a2095
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Test and coverage

on: [push]
on: [push, pull_request]

jobs:
build:
Expand All @@ -13,6 +13,11 @@ jobs:
with:
go-version: '1.18'
- name: Run coverage
run: go test ./... -race -coverprofile=coverage.txt -covermode=atomic -coverpkg github.com/muir/xop-go
run: make calculate_coverage

- name: Upload coverage to Codecov
run: bash <(curl -s https://codecov.io/bash)
uses: codecov/codecov-action@v2
with:
verbose: true
flags: go_tests
fail_ci_if_error: true
18 changes: 18 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,21 @@ ${GOBIN}/enumer:;
-chmod -w $@
-rm $@.tmp

calculate_coverage:
echo "mode: atomic" > coverage.txt
for d in $$(go list ./...); do \
go test -race -covermode=atomic -coverprofile=profile.out -coverpkg=github.com/muir/xop-go/... $$d; \
if [ -f profile.out ]; then \
grep -v ^mode profile.out >> coverage.txt; \
rm profile.out; \
fi; \
done


coverage: calculate_coverage
go tool cover -html=coverage.txt

golanglint:
# binary will be $(go env GOPATH)/bin/golangci-lint
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$(go env GOPATH)/bin v1.45.2
golangci-lint --version

0 comments on commit 05a2095

Please sign in to comment.