-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
123 lines (114 loc) · 3.11 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
variables:
RAILS_ENV: test
IMAGE_NAME: fasibio/funk_server
SONAR_NAME: fasibio_funk_server_
SONAR_HOST: https://sonar.server2.fasibio.de
# Unit and integration tests
test:
stage: test
only:
- /^([0-9]{0,3})\.([0-9]{0,3})\.([0-9]{0,3})$/
- /^rc_([0-9]{0,3})\.([0-9]{0,3})\.([0-9]{0,3}).*/
- master
services:
- name: elasticsearch:7.2.0
alias: elasticsearch
command: ["bin/elasticsearch", "-Expack.security.enabled=false", "-Ediscovery.type=single-node"]
tags:
- dockerfasibio
image: golang:1.12.8
script:
- echo "Sleeping for 15 seconds.."; sleep 15;
- ELASTICSEARCH=http://elasticsearch:9200 go test -mod=vendor -short -tags=integration -coverprofile=cov.out
- go tool cover -func cov.out
coverage: /^total:\t+\(statements\)\t+(\d+\.\d+)%/
artifacts:
paths:
- ./cov.out
# sonar upload
uploadSonarqube:
image: ciricihq/gitlab-sonar-scanner
stage: sonarqube
script:
- sonar-scanner -Dsonar.projectKey=${SONAR_NAME}${CI_COMMIT_REF_NAME} -Dsonar.sources=. -Dsonar.host.url=${SONAR_HOST} -Dsonar.login=$sonarqubelogin
only:
- /^([0-9]{0,3})\.([0-9]{0,3})\.([0-9]{0,3})$/
- /^rc_([0-9]{0,3})\.([0-9]{0,3})\.([0-9]{0,3}).*/
- master
tags:
- dockerfasibio
artifacts:
paths:
- ./cov.out
# build binary
buildBin:
stage: buildBin
only:
- /^([0-9]{0,3})\.([0-9]{0,3})\.([0-9]{0,3})$/
- /^rc_([0-9]{0,3})\.([0-9]{0,3})\.([0-9]{0,3}).*/
- master
tags:
- dockerfasibio
image: golang:1.12.8-alpine3.9
script:
- apk add make
- GO111MODULE=on CGO_ENABLED=0 GOOS=linux go build -mod vendor -a -installsuffix cgo -o funk_server .
cache:
paths:
- funk_server
# build Docker Image for explizit versions and release candidates
buildImageTag:
stage: buildImage
only:
- /^([0-9]{0,3})\.([0-9]{0,3})\.([0-9]{0,3})$/
- /^rc_([0-9]{0,3})\.([0-9]{0,3})\.([0-9]{0,3}).*/
tags:
- dockerfasibio
image: docker
cache:
paths:
- funk_server
script:
- docker build --build-arg buildNumber=${CI_PIPELINE_IID} -t ${IMAGE_NAME}:${CI_COMMIT_REF_NAME} .
# push docker image to hub.docker.com for explizit versions and release candidates
publishTag:
stage: publish
image: docker
only:
- /^([0-9]{0,3})\.([0-9]{0,3})\.([0-9]{0,3})$/
- /^rc_([0-9]{0,3})\.([0-9]{0,3})\.([0-9]{0,3}).*/
tags:
- dockerfasibio
script:
- docker login -u ${dockerhubuser} -p ${dockerhubpassword}
- docker push ${IMAGE_NAME}:${CI_COMMIT_REF_NAME}
# build latest stable version of docker image
buildImageMaster:
stage: buildImage
only:
- master
tags:
- dockerfasibio
image: docker
cache:
paths:
- funk_server
script:
- docker build --build-arg buildNumber=${CI_PIPELINE_IID} -t ${IMAGE_NAME}:latest .
# publish latest stable version to hub.docker.com
publishMaster:
stage: publish
image: docker
only:
- master
tags:
- dockerfasibio
script:
- docker login -u ${dockerhubuser} -p ${dockerhubpassword}
- docker push ${IMAGE_NAME}:latest
stages:
- test
- sonarqube
- buildBin
- buildImage
- publish