-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
64 lines (57 loc) · 1.52 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
variables:
GOPATH: /go
GOLANG_VERSION: "1.23.0"
GOLINT_VERSION: "v1.60.3"
GOPRIVATE: "gitlab.com/flarenetwork/*,gitlab.com/ryancollingham/*"
COVERAGE_FILE: "coverage.out"
COBERTURA_FILE: "coverage.xml"
.gocache:
key: ${CI_COMMIT_REF_SLUG}
policy: pull-push
paths:
- ${GOPATH}/pkg/mod
- ${GOPATH}/bin
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_COMMIT_TAG
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
default:
before_script:
- echo -e "machine gitlab.com\nlogin gitlab-ci-token\npassword ${CI_JOB_TOKEN}" > ~/.netrc
build:
stage: build
image: golang:${GOLANG_VERSION}
needs: []
cache: !reference [.gocache]
script:
- go mod download
- go build ./...
lint:
stage: test
needs: [build]
image: golangci/golangci-lint:${GOLINT_VERSION}
cache: !reference [.gocache]
script:
- ./gofmt_check.sh
- golangci-lint run --timeout 5m0s
test:
stage: test
image: golang:${GOLANG_VERSION}
needs: [build]
cache: !reference [.gocache]
before_script:
- go get github.com/boumenot/gocover-cobertura
script:
- go mod download
- go test -coverpkg=./... -coverprofile=${COVERAGE_FILE} ./...
- go tool cover -func=${COVERAGE_FILE}
- go run github.com/boumenot/gocover-cobertura < ${COVERAGE_FILE} > ${COBERTURA_FILE}
artifacts:
paths:
- ${COVERAGE_FILE}
reports:
coverage_report:
coverage_format: cobertura
path: ${COBERTURA_FILE}
coverage: '/total:\s+\(statements\)\s+(\d+\.\d+)%/'