-
Notifications
You must be signed in to change notification settings - Fork 7
/
.gitlab-ci.yml
90 lines (80 loc) · 2.14 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
---
image: golang:1.21
stages:
- check
- test
- build
- sonarqube-check
check missed commits:
stage: check
tags:
- shared
variables:
GIT_SUBMODULE_STRATEGY: recursive
before_script:
- apt-get update
- apt-get install -y python3-venv python3-pip
- python3 -m venv .venv
- .venv/bin/pip install yamllint
script:
# Check install go tools
- make install-go-tools
- echo "Checking missed 'make tidy'"
- make tidy && git diff --exit-code go.mod go.sum
- echo "Checking missed 'make generate-api'"
- make generate-api && git diff --exit-code internal/api/public/
- echo "Checking missed 'make generate-mock'"
- make generate-mock && git diff --exit-code internal/test/mock/
- echo "Checking missed 'go fmt'"
- make go-fmt && git diff --exit-code .
- echo "Checking yaml files"
- .venv/bin/python3 -m yamllint .
run tests:
stage: test
rules:
- when: never
tags:
- shared
needs: []
script:
- go vet $(go list ./... | grep -v /vendor/)
- make test
- go get github.com/boumenot/gocover-cobertura
- go run github.com/boumenot/gocover-cobertura < coverage.out > coverage.xml
- go tool cover -func ./coverage.out
coverage: '/total:\s+\(statements\)(?:\s+)?(\d+(?:\.\d+)?%)/'
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: coverage.xml
compile project:
stage: build
tags:
- shared
script:
- make build
sonarqube-check:
stage: sonarqube-check
tags:
- shared
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_COMMIT_BRANCH == 'main'
- if: $CI_COMMIT_BRANCH == 'sq-test'
image:
name: images.paas.redhat.com/alm/sonar-scanner-alpine:latest
entrypoint: [""]
variables:
SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache
GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task
dependencies:
- compile project
cache:
policy: pull
key: "${CI_COMMIT_SHORT_SHA}"
paths:
- sonar-scanner/
script:
- sonar-scanner
allow_failure: true