-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
233 lines (191 loc) · 5.76 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
225
226
227
228
229
230
231
232
233
stages:
- docker # Docker images necessary for the next stages
- build # Binary generation
- docker-bin # Docker images that contain binaries
- test # Tests, documentation
- deploy # Final container generation
variables:
jdk_image: "openjdk:17-bullseye"
server_bin: "$CI_REGISTRY_IMAGE/server"
include:
- remote: https://gitlab.com/opensavvy/ci-templates/-/raw/main/docker.gitlab-ci.yml
- remote: https://gitlab.com/opensavvy/ci-templates/-/raw/main/gradle.gitlab-ci.yml
- remote: https://gitlab.com/opensavvy/ci-templates/-/raw/main/version.gitlab-ci.yml
- local: helm/.gitlab-ci.yml
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_PIPELINE_SOURCE == 'schedule'
- if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
- if: $CI_COMMIT_TAG
# Build the necessary images
chromium:build:
extends: [ .os.docker.build ]
needs: [ ]
stage: docker
variables:
dockerfile: .gitlab/chromium.dockerfile
context: .gitlab
image: chromium
interruptible: true
chromium:publish:
extends: [ .os.docker.rename ]
needs: [ chromium:build ]
stage: deploy
variables:
image: chromium
rules:
- if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
interruptible: true
# Documentation
dokka:
image: $jdk_image
stage: build
extends: [ .os.gradle ]
needs: [ ]
script:
- "./gradlew dokkaHtmlMultiModule"
- mkdir -p docs
- mv build/dokka/htmlMultiModule/* docs
artifacts:
paths:
- docs
expose_as: 'Documentation'
environment:
name: review/$CI_COMMIT_REF_SLUG/documentation
url: https://$CI_PROJECT_NAMESPACE.$CI_PAGES_DOMAIN/-/$CI_PROJECT_NAME/-/jobs/$CI_JOB_ID/artifacts/docs/index.html
deployment_tier: development
interruptible: true
# Production image
backend:compile:
image: $jdk_image
stage: build
extends: [ .os.gradle ]
needs: [ ]
script:
- "./gradlew backend:assembleDist"
- "mv backend/build/distributions/backend-*.tar backend.tar"
- "mv backend/build/distributions/backend-*.zip backend.zip"
artifacts:
paths:
- backend.tar
- backend.zip
interruptible: true
backend:container:
stage: docker-bin
extends: [ .os.docker.build ]
needs:
- job: backend:compile
artifacts: true
variables:
dockerfile: .gitlab/backend.dockerfile
context: .
image: server
interruptible: true
backend:container:publish:
stage: deploy
extends: [ .os.docker.rename ]
needs: [ backend:container, os.version ]
variables:
image: server
rules:
- if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
- if: $CI_COMMIT_TAG
variables:
new_version: $project_version
interruptible: false
# Tests
test-jvm:
image: $jdk_image
stage: test
extends: [ .os.gradle ]
needs: [ ]
services:
- mongo:latest
variables:
MONGO_INITDB_ROOT_USERNAME: "root"
MONGO_INITDB_ROOT_PASSWORD: "development-password"
script:
- "./gradlew jvmTest backend:test mongo:test remote-server:test koverMergedVerify koverMergedReport --continue"
- mkdir -p kover
- mv build/reports/kover/merged/html/* kover
- values=$(<build/reports/kover/merged/xml/report.xml tail -7 | head -5 | grep 'INSTRUCTION' | cut -d ' ' -f 3,4 | sed 's/missed="//;s/" covered="/ /;s/"\/>//')
- missed=$(<<<$values cut -d ' ' -f 1)
- covered=$(<<<$values cut -d ' ' -f 2)
- percent=$(awk "{print ($covered * 100) / ($covered + $missed)}" <<<"")
- echo "Coverage $percent"
- mv build/reports/kover/merged/xml/report.xml report.xml
after_script:
- mkdir -p test-output
- |
for project in $(find . -type d -exec test -e '{}'/build.gradle.kts -a -e '{}'/build/test-results/jvmTest \; -print)
do
echo "Found test results in $project"
cp -r $project/build/test-results/jvmTest/* test-output
done
- |
for project in $(find . -type d -exec test -e '{}'/build.gradle.kts -a -e '{}'/build/test-results/test \; -print)
do
echo "Found test results in $project"
cp -r $project/build/test-results/test/* test-output
done
coverage: '/Coverage \d+\.\d+/'
artifacts:
paths:
- kover
- report.xml
expose_as: 'Coverage JVM'
reports:
junit: test-output/TEST-*.xml
environment:
name: review/$CI_COMMIT_REF_SLUG/coverage
url: https://$CI_PROJECT_NAMESPACE.$CI_PAGES_DOMAIN/-/$CI_PROJECT_NAME/-/jobs/$CI_JOB_ID/artifacts/kover/index.html
deployment_tier: development
interruptible: true
test-js:
image: $CI_REGISTRY_IMAGE/chromium:build-$CI_PIPELINE_IID
stage: test
extends: [ .os.gradle ]
needs: [ chromium:build ]
script:
- "./gradlew jsBrowserTest --continue"
after_script:
- mkdir -p test-output
- |
for project in $(find . -type d -exec test -e '{}'/build.gradle.kts -a -e '{}'/build/test-results/jsBrowserTest \; -print)
do
echo "Found test results in $project"
cp -r $project/build/test-results/jsBrowserTest/* test-output
done
artifacts:
reports:
junit: test-output/TEST-*.xml
# TODO: remove when https://gitlab.com/opensavvy/formulaide/-/issues/295 is fixed
allow_failure: true
interruptible: true
pages:
image: alpine:latest
stage: deploy
dependencies: [ dokka ]
needs: [ dokka ]
script:
- mkdir -p public/documentation
- mv docs/* public/documentation/
artifacts:
paths:
- public
rules:
- if: $CI_COMMIT_TAG
interruptible: false
telegram:
stage: deploy
image: registry.gitlab.com/clovis-ai/dotfiles:latest
needs: [ ]
script:
- git changelog --format telegram-html --incoming >changelog
- announce-telegram changelog "$CHAT_IDS"
rules:
- if: $CHAT_IDS == null || $BOT_TOKEN == null
when: never
- if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
interruptible: false