From bbfc1792699db07602df4fabea177b93fa92487e Mon Sep 17 00:00:00 2001 From: Bruno Carlin Date: Tue, 31 May 2022 12:30:30 +0200 Subject: [PATCH] ci: add linting and coverage --- .gitlab-ci.yml | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8600570..5dfd147 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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 "go/log page" >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