1
0
Fork 0

👷 Improved GitLab CI/CD configuration

This commit is contained in:
Maxim Lebedev 2021-08-01 22:18:19 +05:00
parent b7e9bf3a5c
commit f172e54b12
Signed by: toby3d
GPG Key ID: 1F14E25B7C119FC5
1 changed files with 29 additions and 18 deletions

View File

@ -1,39 +1,50 @@
---
image: golang:alpine
variables:
GO111MOD: "on"
REPO_NAME: gitlab.com/$CI_PROJECT_PATH
CGO_ENABLED: "0"
GOOS: "linux"
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- /var/cache/apk
- /go/pkg/mod
- /var/cache/apk
before_script:
- mkdir -p $GOPATH/src/$(dirname $REPO_NAME)
- ln -svf $CI_PROJECT_DIR $GOPATH/src/$REPO_NAME
- cd $GOPATH/src/$REPO_NAME
stages:
- test
- review
before_script:
- apk add --no-cache git make
- go get github.com/golangci/golangci-lint/cmd/golangci-lint
- go install github.com/golangci/golangci-lint/cmd/golangci-lint
- make tidy
unit_tests:
test:
stage: test
before_script:
- go get gotest.tools/gotestsum
script:
- make test
- gotestsum --junitfile report.xml --format testname
artifacts:
when: always
reports:
junit: report.xml
code_coverage:
cover:
stage: test
before_script:
- go get github.com/t-yuki/gocover-cobertura
script:
- make coverage
coverage: '/^coverage:\s(\d+(?:\.\d+)?%)/'
- go test -coverprofile=coverage.txt -covermode count $REPO_NAME/...
- gocover-cobertura < coverage.txt > coverage.xml
artifacts:
reports:
cobertura: coverage.xml
lint_code:
stage: review
lint:
stage: test
before_script:
- wget -O- -nv https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.41.1
script:
- make lint
- ./bin/golangci-lint run
allow_failure: true