This repository has been archived by the owner on Dec 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
.gitlab-ci.yml
224 lines (204 loc) · 5.62 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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
image: node:16.13.2-alpine
variables:
# Docker image tag: master, 3.0, 3.1, …
DOCKER_NICE_VERSION: 'master'
NICE_TIMEOUT_SECS: '300'
CYPRESS_INSTALL_BINARY: "0"
S3_SECRET_ACCESS_KEY: $S3_SECRET_ACCESS_KEY
CYPRESS_API_KEY: $CYPRESS_API_KEY
CYPRESS_PASSWORD: $CYPRESS_PASSWORD
CYPRESS_USER: $CYPRESS_USER
CYPRESS_USER_API_KEY_HASH: $CYPRESS_USER_API_KEY_HASH
CYPRESS_USER_PASSWORD_HASH: $CYPRESS_USER_PASSWORD_HASH
# Feature flags (https://docs.gitlab.com/runner/configuration/feature-flags.html)
FF_USE_FASTZIP: 'true' # Use faster, concurrent zip implementation for cache/artifacts.
FF_NETWORK_PER_BUILD: 'true' # Create a virtual network for every build.
#
# Expected to be enabled and enforced on our own runners in the near
# future for security reasons.
#
# https://docs.gitlab.com/runner/executors/docker.html#create-a-network-for-each-job
stages:
- chore
- setup
- quality
- build
- pullrequest
- release
- onschedule
.nice-as-service:
services:
- name: registry.gitlab.com/toccoag/nice2/postgres:${DOCKER_NICE_VERSION}
alias: postgres
- name: registry.gitlab.com/toccoag/nice2/nice:${DOCKER_NICE_VERSION}
alias: nice
variables:
hibernate.main.serverName: postgres
hibernate.main.user: nice
hibernate.main.password: nice
hibernate.main.databaseName: nice
hibernate.main.sslMode: disable
nice2.persist.history.persistence.state: DISABLED
nice2.web.core.neverRequireSecureConnection: 'true'
s3.main.accessKeyId: DRRLPEOZW3UPR75MDNKJ
s3.main.bucketName: tocco-ci
s3.main.endpoint: https://objects.rma.cloudscale.ch
s3.main.secretAccessKey: ${S3_SECRET_ACCESS_KEY}
SPRING_PROFILE: test # Remove when https://toccoag.atlassian.net/browse/TOCDEV-5272 is fixed.
before_script:
- apt-get update
- apt-get install -y wget
- apt-get install -y postgresql-client
- apt-get install -y curl
- yarn nice2:wait-for-readyness
yarn_setup:
stage: setup
needs: []
only:
- external_pull_requests
- master
- schedules
cache:
key:
files:
- yarn.lock
- packages/*/*/yarn.lock
paths:
- node_modules/
- packages/*/*/node_modules/
artifacts:
paths:
- node_modules/
- packages/*/*/node_modules/
expire_in: 5 days
script:
- yarn setup:ci
interruptible: true
linting:
stage: quality
dependencies:
- yarn_setup
only:
- external_pull_requests
- master
script:
- yarn lint
formatting:
stage: quality
dependencies:
- yarn_setup
only:
- external_pull_requests
- master
script:
- yarn format:check
test:
stage: quality
dependencies:
- yarn_setup
only:
- external_pull_requests
- master
script:
- yarn test:ci
interruptible: true
storybook:
stage: quality
dependencies:
- yarn_setup
only:
- external_pull_requests
- master
before_script:
- apk update && apk add bash && apk add openssh-client && apk add git
script:
- BACKEND=https://master.tocco.ch yarn build-storybook
- scripts/deploy_storybook_gitlab.sh
storybook-link:
stage: pullrequest
dependencies: []
needs:
- storybook
cache: {}
before_script:
- apk update && apk add bash && apk add curl && apk add jq
only:
- external_pull_requests
script:
- scripts/storybook_link_gitlab.sh
auto-release:
stage: release
dependencies: []
only:
variables:
- $CI_RUN_AUTO_RELEASE == "1"
before_script:
- apk update && apk add bash && apk add curl && apk add git && apk add openssh && apk add jq && apk add ncurses
variables:
TERM: "xterm-256color"
script:
- ./scripts/auto-release.sh
cherrypick:
stage: release
dependencies: []
only:
- /^nice-releases\/[0-9]+$/
before_script:
- apk update && apk add bash && apk add curl && apk add git && apk add openssh && apk add jq && apk add ncurses
variables:
TERM: "xterm-256color"
script:
- ./scripts/cherrypick.sh
cypress:
extends:
- .nice-as-service
stage: onschedule
dependencies:
- yarn_setup
image: cypress/base:16.14.2
variables:
CYPRESS_INSTALL_BINARY: "10.11.0"
HIBERNATE_MAIN_SERVERNAME: "postgres"
HIBERNATE_MAIN_DATABASENAME: "nice"
POSTGRES_USER: "postgres"
CYPRESS_BASE_URL: "http://nice:8080"
BACKEND_URL: "http://nice:8080"
only:
variables:
- $CI_RUN_CYPRESS == "1"
script:
- npm rebuild cypress
- yarn db:prepare
- yarn db:dump
- yarn db:create-template
- yarn widgets:serve &
- yarn widgets:wait-for-readyness
- yarn nice2:wait-for-readyness
- yarn cypress:run
artifacts:
paths:
- cypress/videos
expire_in: 1 week
when: always
tagging:
stage: chore
only:
- master
- /^nice-releases\/[0-9]+$/
before_script:
- apk update && apk add bash && apk add curl && apk add git && apk add openssh-client
script:
- ./scripts/tagging.sh
sonarqube:
stage: onschedule
dependencies:
- yarn_setup
only:
variables:
- $CI_RUN_SONARQUBE == "1"
before_script: # hacky, glibc isn't part of alpine and bundled java fails. we need to tell scanner to use system jre
- apk --update add openjdk11-jre # add jre
- yarn sonarqube || echo 'Sonar fail' # run command once so it downloads sonar scanner
- set -- /root/.sonar/native-sonar-scanner/* && sed -i 's/use_embedded_jre=true/use_embedded_jre=false/g' "$1/bin/sonar-scanner" # tell scanner to use system jre
script:
- yarn sonarqube -Dsonar.login=$SONARQUBE_KEY