ci: add linting and coverage
This commit is contained in:
parent
344505ea9d
commit
bbfc179269
1 changed files with 21 additions and 11 deletions
|
@ -1,21 +1,31 @@
|
|||
# This file is a template, and might need editing before it works on your project.
|
||||
image: golang:latest
|
||||
|
||||
stages:
|
||||
- test
|
||||
#- build
|
||||
- deploy
|
||||
|
||||
test:
|
||||
stage: test
|
||||
before_script:
|
||||
- export PATH=$PATH:$GOPATH/bin
|
||||
- go install gotest.tools/gotestsum@latest
|
||||
script:
|
||||
- go test -race
|
||||
|
||||
pages:
|
||||
stage: deploy
|
||||
script:
|
||||
- mkdir public
|
||||
- echo "<body>go/log page</body>" >public/index.html
|
||||
- gotestsum --junitfile tests.xml -- -coverprofile=coverage.txt -covermode atomic .
|
||||
after_script:
|
||||
- export PATH=$PATH:$GOPATH/bin
|
||||
- go install github.com/boumenot/gocover-cobertura@latest
|
||||
- gocover-cobertura < coverage.txt > coverage.xml
|
||||
- go tool cover -func=coverage.txt | grep "total:"
|
||||
coverage: '/total:\s+\(statements\)\s+(\d+.\d+\%)/'
|
||||
artifacts:
|
||||
paths:
|
||||
- public
|
||||
reports:
|
||||
junit: tests.xml
|
||||
coverage_report:
|
||||
coverage_format: cobertura
|
||||
path: coverage.xml
|
||||
|
||||
lint:
|
||||
stage: test
|
||||
image: golangci/golangci-lint
|
||||
script:
|
||||
- golangci-lint run
|
||||
|
|
Loading…
Reference in a new issue