fea: make: output coverage html

This commit is contained in:
Daniel Ding
2022-09-24 10:18:32 +08:00
parent d5b1a7fc30
commit aa147bfed2
3 changed files with 11 additions and 8 deletions

View File

@@ -24,6 +24,6 @@ jobs:
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: ./coverage.cov
files: ./coverage.out
name: codecov
verbose: true

3
.gitignore vendored
View File

@@ -11,7 +11,8 @@
# Test binary, build with `go test -c`
*.test
*.idea
*.cov
coverage.out
coverage.html
# Output of the go coverage tool, specifically when used with LiteIDE
*.out

View File

@@ -64,7 +64,6 @@ vendor: update
env:
@mkdir -p $(BD)
@mkdir -p $(CD)
@go version
@gofmt -w -s ./pkg ./cmd ./misc
@@ -197,9 +196,12 @@ test: ## execute unit test
## coverage
cover: env ## execute unit test and output coverage
go test -mod=vendor github.com/luscis/openlan/pkg/access -coverprofile=$(CD)/access.txt -race -covermode=atomic
go test -mod=vendor github.com/luscis/openlan/pkg/libol -coverprofile=$(CD)/libol.txt -race -covermode=atomic
go test -mod=vendor github.com/luscis/openlan/pkg/models -coverprofile=$(CD)/models.txt -race -covermode=atomic
@rm -rvf $(CD)
@mkdir -p $(CD)
go test -mod=vendor github.com/luscis/openlan/pkg/access -coverprofile=$(CD)/access.out -race -covermode=atomic
go test -mod=vendor github.com/luscis/openlan/pkg/libol -coverprofile=$(CD)/libol.out -race -covermode=atomic
go test -mod=vendor github.com/luscis/openlan/pkg/models -coverprofile=$(CD)/models.out -race -covermode=atomic
echo 'mode: atomic' > $(SD)/coverage.cov
tail -q -n +2 $(CD)/*.txt >> $(SD)/coverage.cov
echo 'mode: atomic' > $(SD)/coverage.out
tail -q -n +2 $(CD)/*.out >> $(SD)/coverage.out
go tool cover -html=coverage.out -o coverage.html