-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
150 lines (138 loc) · 3.13 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
variables:
RAILS_ENV: test
IMAGE_NAME: fasibio/micropuzzle
SONAR_NAME: fasibio_micropuzzle_
#SONAR_HOST: https://sonar.server2.fasibio.de
.onlyTags:
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
.goImage:
image: golang:1.17.1
.tags:
tags:
- dockerfasibio
buildWebComponents:
stage: buildFrontend
extends:
- .onlyTags
- .tags
image: node
script:
- cd micropuzzle-components
- yarn
- yarn build
artifacts:
paths:
- micro-lib
vendor:
stage: vendor
extends:
- .onlyTags
- .goImage
- .tags
script:
- go mod vendor
cache:
paths:
- vendor
# Unit and integration tests
test:
stage: test
extends:
- .onlyTags
- .goImage
- .tags
script:
- go test ./... -coverprofile=cov.out
- go tool cover -func cov.out
coverage: /^total:\t+\(statements\)\t+(\d+\.\d+)%/
artifacts:
paths:
- ./cov.out
cache:
paths:
- vendor
# 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
# extends: .onlyTags
# tags:
# - dockerfasibio
# artifacts:
# paths:
# - ./cov.out
# build binary
buildServer:
stage: buildServer
extends:
- .onlyTags
- .goImage
- .tags
script:
- GO111MODULE=on CGO_ENABLED=0 GOOS=linux go build -mod vendor -a -installsuffix cgo -o micropuzzle .
artifacts:
paths:
- micropuzzle
cache:
paths:
- vendor
# 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}).*/
extends:
- .tags
image: docker
script:
- docker build --build-arg commit_sha=${CI_COMMIT_SHORT_SHA} --build-arg application_build_id=${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}).*/
extends:
- .tags
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
extends:
- .tags
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
extends:
- .tags
script:
- docker login -u ${dockerhubuser} -p ${dockerhubpassword}
- docker push ${IMAGE_NAME}:latest
stages:
- vendor
- buildFrontend
- test
# - sonarqube
- buildServer
- buildImage
- publish