ci: add linting and coverage

This commit is contained in:
Bruno Carlin 2022-05-31 12:30:30 +02:00
parent 344505ea9d
commit bbfc179269

View file

@ -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