-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
53 lines (49 loc) · 1.37 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
variables:
GOLANG_VERSION: "1.23.0"
GOLINT_VERSION: "v1.60.3"
COVERAGE_FILE: "coverage.out"
COBERTURA_FILE: "coverage.xml"
.gocache:
variables:
GOPATH: ${CI_PROJECT_DIR}/.go
before_script:
- mkdir -p ${GOPATH}
cache:
paths:
- ${GOPATH}/pkg/mod/
- ${GOPATH}/bin
build:
stage: build
image: golang:${GOLANG_VERSION}
extends: .gocache
needs: []
script:
- go mod download
- go build ./...
lint:
stage: test
needs: []
image: golangci/golangci-lint:${GOLINT_VERSION}
extends: .gocache
script:
- "! gofmt -l . | grep -q ."
- golangci-lint run --timeout 5m0s
test:
stage: test
image: golang:${GOLANG_VERSION}
needs: [build]
extends: .gocache
before_script:
- go get github.com/boumenot/gocover-cobertura
script:
- go test -v -coverpkg=github.com/flare-foundation/fdc-client/... -coverprofile=${COVERAGE_FILE} -covermode count ./...
- 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+)%/'