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 image: golang:latest
stages: stages:
- test - test
#- build #- build
- deploy
test: test:
stage: test stage: test
before_script:
- export PATH=$PATH:$GOPATH/bin
- go install gotest.tools/gotestsum@latest
script: script:
- go test -race - gotestsum --junitfile tests.xml -- -coverprofile=coverage.txt -covermode atomic .
after_script:
pages: - export PATH=$PATH:$GOPATH/bin
stage: deploy - go install github.com/boumenot/gocover-cobertura@latest
script: - gocover-cobertura < coverage.txt > coverage.xml
- mkdir public - go tool cover -func=coverage.txt | grep "total:"
- echo "<body>go/log page</body>" >public/index.html coverage: '/total:\s+\(statements\)\s+(\d+.\d+\%)/'
artifacts: artifacts:
paths: reports:
- public junit: tests.xml
coverage_report:
coverage_format: cobertura
path: coverage.xml
lint:
stage: test
image: golangci/golangci-lint
script:
- golangci-lint run