Add CI configuration
This commit is contained in:
parent
c3ac87ae9b
commit
5611558820
1 changed files with 60 additions and 0 deletions
60
.gitlab-ci.yml
Normal file
60
.gitlab-ci.yml
Normal file
|
@ -0,0 +1,60 @@
|
|||
image: golang:latest
|
||||
|
||||
stages:
|
||||
- test
|
||||
- build
|
||||
- release
|
||||
|
||||
variables:
|
||||
GOPATH: "${CI_PROJECT_DIR}/.gocache"
|
||||
GOLANGCI_LINT_CACHE: "${GOPATH}/golangci-lint_cache"
|
||||
GOCACHE: "${GOPATH}/go-build"
|
||||
|
||||
.cache: &depscache
|
||||
key: $CI_COMMIT_REF_SLUG
|
||||
paths:
|
||||
- $CI_PROJECT_DIR/.gocache
|
||||
|
||||
lint:
|
||||
stage: test
|
||||
image: golangci/golangci-lint:latest
|
||||
script:
|
||||
- golangci-lint cache status
|
||||
- golangci-lint run --timeout 5m --out-format junit-xml > lint.junit.xml
|
||||
cache:
|
||||
<<: *depscache
|
||||
policy: pull-push
|
||||
artifacts:
|
||||
reports:
|
||||
junit: lint.junit.xml
|
||||
|
||||
tests:
|
||||
stage: test
|
||||
script:
|
||||
- go install gotest.tools/gotestsum@latest
|
||||
- gotestsum --junitfile tests.junit.xml -- -coverprofile=coverage.txt -covermode atomic -race ./...
|
||||
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+\%)/'
|
||||
cache:
|
||||
<<: *depscache
|
||||
policy: pull-push
|
||||
artifacts:
|
||||
reports:
|
||||
cobertura: coverage.xml
|
||||
junit: tests.junit.xml
|
||||
|
||||
release:
|
||||
stage: release
|
||||
image: registry.gitlab.com/gitlab-org/release-cli:latest
|
||||
rules:
|
||||
- if: $CI_COMMIT_TAG
|
||||
script:
|
||||
- |
|
||||
release-cli create \
|
||||
--name "${CI_COMMIT_TAG}" \
|
||||
--tag-name "${CI_COMMIT_TAG}" \
|
||||
--milestone "${CI_COMMIT_TAG}"
|
Loading…
Reference in a new issue