.gitlab-ci.yml 21 KB
Newer Older
Piotr Gawron's avatar
Piotr Gawron committed
1
image: node:14
Piotr Gawron's avatar
Piotr Gawron committed
2

3
4
stages:
  - build
Piotr Gawron's avatar
Piotr Gawron committed
5
  - packaging
6
  - test
Piotr Gawron's avatar
Piotr Gawron committed
7

Piotr Gawron's avatar
Piotr Gawron committed
8
9
10
11
cache:
  paths:
    - maven.repository/

12
13
14
15
variables:
  POSTGRES_DB: map_viewer
  POSTGRES_USER: map_viewer
  POSTGRES_PASSWORD: "123qweasdzxc"
Piotr Gawron's avatar
Piotr Gawron committed
16
  MAVEN_OPTS: "-Dmaven.repo.local=maven.repository"
17

18
before_script:
19
#by default we configure postgres database
20
  - mkdir /etc/minerva/
21
  - cp test-postgres-db-ci.properties /etc/minerva/db.properties
22

Piotr Gawron's avatar
Piotr Gawron committed
23
test:frontend:
24
  stage: test
25
  coverage: '/Statements[:\ ]+(\d+.\d+)\%/'
Piotr Gawron's avatar
Piotr Gawron committed
26
27
  script:
    - cd frontend-js
28
    - npm install  
Piotr Gawron's avatar
Piotr Gawron committed
29
    - npm test
30

Piotr Gawron's avatar
Piotr Gawron committed
31
.jdk_8_template: &jdk_8_definition
Piotr Gawron's avatar
Piotr Gawron committed
32
  image: maven:3.6.0-jdk-8
Piotr Gawron's avatar
Piotr Gawron committed
33
34
  services:
    - postgres:9.6
35
  stage: test
36
  coverage: '/(\d+.\d+) \% covered/'
37
38
  before_script:
    - mvn dependency:purge-local-repository -DmanualInclude="lcsb.mapviewer"
Piotr Gawron's avatar
Piotr Gawron committed
39
40
41
42
43
44
45

.jdk_11_template: &jdk_11_definition
  image: maven:3.6.0-jdk-11
  services:
    - postgres:9.6
  stage: test
  coverage: '/(\d+.\d+) \% covered/'
46
47
  before_script:
    - mvn dependency:purge-local-repository -DmanualInclude="lcsb.mapviewer"
Piotr Gawron's avatar
Piotr Gawron committed
48

49
50
51
52
53
54
55
56
57
58
.hsql_template: &hsql_definition
  image: maven:3.6.0-jdk-11
  stage: test
  coverage: '/(\d+.\d+) \% covered/'
  before_script:
    #by default we configure postgres database
    - rm -rf /etc/minerva/
    - mkdir /etc/minerva/
    - cp test-hsql-db-ci.properties /etc/minerva/db.properties

59
.test_backend_commons_template:
Piotr Gawron's avatar
Piotr Gawron committed
60
  script: &test_backend_commons_definition
61
#xvfb is for X11 connection used by some parts of the java code: https://stackoverflow.com/a/47575851/1127920
Piotr Gawron's avatar
Piotr Gawron committed
62
    - apt-get update
63
    - DEBIAN_FRONTEND=noninteractive apt-get install -y xvfb
64
65
    - Xvfb :99 &
    - export DISPLAY=:99
66
67
68

    - mvn -DskipTests=true clean install -pl commons -am
    - mvn test -pl commons
Piotr Gawron's avatar
Piotr Gawron committed
69
    - awk -F"," '{ instructions += $4 + $5; covered += $5 } END { print covered, "/", instructions, "instructions covered"; print 100*covered/instructions,"% covered" }' commons/target/site/jacoco/jacoco.csv
70

Piotr Gawron's avatar
Piotr Gawron committed
71
72
.test_backend_annotation_template:
  script: &test_backend_annotation_definition
73
74
    - mvn -DskipTests=true clean install -pl annotation -am
    - mvn test -pl annotation
Piotr Gawron's avatar
Piotr Gawron committed
75
    - awk -F"," '{ instructions += $4 + $5; covered += $5 } END { print covered, "/", instructions, "instructions covered"; print 100*covered/instructions,"% covered" }' annotation/target/site/jacoco/jacoco.csv
76

Piotr Gawron's avatar
Piotr Gawron committed
77
78
79

.test_backend_CellDesigner-plugin_template:
  script: &test_backend_CellDesigner_plugin_definition
Piotr Gawron's avatar
Piotr Gawron committed
80
81
82
83
84
85
#xvfb is for X11 connection used by some parts of the java code: https://stackoverflow.com/a/47575851/1127920
    - apt-get update
    - apt-get install -y xvfb
    - Xvfb :99 &
    - export DISPLAY=:99

86
87
    - mvn -DskipTests=true clean install -pl CellDesigner-plugin -am
    - mvn test -pl CellDesigner-plugin
Piotr Gawron's avatar
Piotr Gawron committed
88
    - awk -F"," '{ instructions += $4 + $5; covered += $5 } END { print covered, "/", instructions, "instructions covered"; print 100*covered/instructions,"% covered" }' CellDesigner-plugin/target/site/jacoco/jacoco.csv
89

Piotr Gawron's avatar
Piotr Gawron committed
90
91
.test_backend_converter_template:
  script: &test_backend_converter_definition
92
93
    - mvn -DskipTests=true clean install -pl converter -am
    - mvn test -pl converter
Piotr Gawron's avatar
Piotr Gawron committed
94
    - awk -F"," '{ instructions += $4 + $5; covered += $5 } END { print covered, "/", instructions, "instructions covered"; print 100*covered/instructions,"% covered" }' converter/target/site/jacoco/jacoco.csv
95

Piotr Gawron's avatar
Piotr Gawron committed
96
97
.test_backend_converter_graphics_template:
  script: &test_backend_converter_graphics_definition
98
99
    - mvn -DskipTests=true clean install -pl converter-graphics -am
    - mvn test -pl converter-graphics
Piotr Gawron's avatar
Piotr Gawron committed
100
    - awk -F"," '{ instructions += $4 + $5; covered += $5 } END { print covered, "/", instructions, "instructions covered"; print 100*covered/instructions,"% covered" }' converter-graphics/target/site/jacoco/jacoco.csv
101

Piotr Gawron's avatar
Piotr Gawron committed
102
103
.test_backend_converter_CellDesigner_template:
  script: &test_backend_converter_CellDesigner_definition
104
    - mvn -DskipTests=true clean install -pl converter-CellDesigner -am
Piotr Gawron's avatar
Piotr Gawron committed
105
    - mvn test -pl converter-CellDesigner
Piotr Gawron's avatar
Piotr Gawron committed
106
    - awk -F"," '{ instructions += $4 + $5; covered += $5 } END { print covered, "/", instructions, "instructions covered"; print 100*covered/instructions,"% covered" }' converter-CellDesigner/target/site/jacoco/jacoco.csv
107

Piotr Gawron's avatar
Piotr Gawron committed
108
109
.test_backend_converter_SBGNML_template:
  script: &test_backend_converter_SBGNML_definition
110
111
    - mvn -DskipTests=true clean install -pl converter-SBGNML -am
    - mvn test -pl converter-SBGNML
Piotr Gawron's avatar
Piotr Gawron committed
112
    - awk -F"," '{ instructions += $4 + $5; covered += $5 } END { print covered, "/", instructions, "instructions covered"; print 100*covered/instructions,"% covered" }' converter-SBGNML/target/site/jacoco/jacoco.csv
113

Piotr Gawron's avatar
Piotr Gawron committed
114
115
.test_backend_converter_SBML_template:
  script: &test_backend_converter_SBML_definition
116
117
    - mvn -DskipTests=true clean install -pl converter-sbml -am
    - mvn test -pl converter-sbml
Piotr Gawron's avatar
Piotr Gawron committed
118
    - awk -F"," '{ instructions += $4 + $5; covered += $5 } END { print covered, "/", instructions, "instructions covered"; print 100*covered/instructions,"% covered" }' converter-sbml/target/site/jacoco/jacoco.csv
119

Piotr Gawron's avatar
Piotr Gawron committed
120
121
.test_backend_model_template:
  script: &test_backend_model_definition
122
123
    - mvn -DskipTests=true clean install -pl model -am
    - mvn test -pl model
Piotr Gawron's avatar
Piotr Gawron committed
124
    - awk -F"," '{ instructions += $4 + $5; covered += $5 } END { print covered, "/", instructions, "instructions covered"; print 100*covered/instructions,"% covered" }' model/target/site/jacoco/jacoco.csv
125

Piotr Gawron's avatar
Piotr Gawron committed
126
127
.test_backend_model_command_template:
  script: &test_backend_model_command_definition
128
129
    - mvn -DskipTests=true clean install -pl model-command -am
    - mvn test -pl model-command
Piotr Gawron's avatar
Piotr Gawron committed
130
    - awk -F"," '{ instructions += $4 + $5; covered += $5 } END { print covered, "/", instructions, "instructions covered"; print 100*covered/instructions,"% covered" }' model-command/target/site/jacoco/jacoco.csv
131

Piotr Gawron's avatar
Piotr Gawron committed
132
133
.test_backend_pathvisio_template:
  script: &test_backend_pathvisio_definition
134
135
    - mvn -DskipTests=true clean install -pl pathvisio -am
    - mvn test -pl pathvisio
Piotr Gawron's avatar
Piotr Gawron committed
136
    - awk -F"," '{ instructions += $4 + $5; covered += $5 } END { print covered, "/", instructions, "instructions covered"; print 100*covered/instructions,"% covered" }' pathvisio/target/site/jacoco/jacoco.csv
137

Piotr Gawron's avatar
Piotr Gawron committed
138
139
.test_backend_persist_template:
  script: &test_backend_persist_definition
140
141
    - mvn -DskipTests=true clean install -pl persist -am
    - mvn test -pl persist
Piotr Gawron's avatar
Piotr Gawron committed
142
    - awk -F"," '{ instructions += $4 + $5; covered += $5 } END { print covered, "/", instructions, "instructions covered"; print 100*covered/instructions,"% covered" }' persist/target/site/jacoco/jacoco.csv
143

Piotr Gawron's avatar
Piotr Gawron committed
144
145
.test_backend_rest_template:
  script: &test_backend_rest_definition
146
147
    - mvn -DskipTests=true clean install -pl rest-api -am
    - mvn test -pl rest-api
Piotr Gawron's avatar
Piotr Gawron committed
148
    - awk -F"," '{ instructions += $4 + $5; covered += $5 } END { print covered, "/", instructions, "instructions covered"; print 100*covered/instructions,"% covered" }' rest-api/target/site/jacoco/jacoco.csv
149

Piotr Gawron's avatar
Piotr Gawron committed
150
151
.test_backend_web_template:
  script: &test_backend_web_definition
152
153
154
155
    - apt-get update
    - DEBIAN_FRONTEND=noninteractive apt-get install -y curl gnupg git ant
    - curl -sL https://deb.nodesource.com/setup_9.x | bash -
    - DEBIAN_FRONTEND=noninteractive apt-get install -y nodejs
156
157
    - mvn -DskipTests=true clean install -pl web -am
    - mvn test -pl web
Piotr Gawron's avatar
Piotr Gawron committed
158
    - awk -F"," '{ instructions += $4 + $5; covered += $5 } END { print covered, "/", instructions, "instructions covered"; print 100*covered/instructions,"% covered" }' web/target/site/jacoco/jacoco.csv
159

Piotr Gawron's avatar
Piotr Gawron committed
160
161
.test_backend_service_template:
  script: &test_backend_service_definition
162
163
    - mvn -DskipTests=true clean install -pl service -am
    - mvn test -pl service
Piotr Gawron's avatar
Piotr Gawron committed
164
    - awk -F"," '{ instructions += $4 + $5; covered += $5 } END { print covered, "/", instructions, "instructions covered"; print 100*covered/instructions,"% covered" }' service/target/site/jacoco/jacoco.csv
165

Piotr Gawron's avatar
Piotr Gawron committed
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182

test:backend:commons:jdk-8:
  <<: *jdk_8_definition
  script: *test_backend_commons_definition

test:backend:commons:jdk-11:
  <<: *jdk_11_definition
  script: *test_backend_commons_definition

test:backend:annotation:jdk-8:
  <<: *jdk_8_definition
  script: *test_backend_annotation_definition

test:backend:annotation:jdk-11:
  <<: *jdk_11_definition
  script: *test_backend_annotation_definition

183
184
185
186
test:backend:annotation:jdk-11-hsql:
  <<: *hsql_definition
  script: *test_backend_annotation_definition

Piotr Gawron's avatar
Piotr Gawron committed
187
188
189
190
test:backend:CellDesigner_plugin:jdk-8:
  <<: *jdk_8_definition
  script: *test_backend_CellDesigner_plugin_definition

191
192
193
194
#CellDesigner is working on java 8 and is incompatible with java 11
#test:backend:CellDesigner_plugin:jdk-11:
#  <<: *jdk_11_definition
#  script: *test_backend_CellDesigner_plugin_definition
Piotr Gawron's avatar
Piotr Gawron committed
195
196
197
198
199
200
201
202
203

test:backend:converter:jdk-8:
  <<: *jdk_8_definition
  script: *test_backend_converter_definition

test:backend:converter:jdk-11:
  <<: *jdk_11_definition
  script: *test_backend_converter_definition

204
205
206
207
208
209
210
211
test:backend:converter_CellDesigner:jdk-8:
  <<: *jdk_8_definition
  script: *test_backend_converter_CellDesigner_definition

test:backend:converter_CellDesigner:jdk-11:
  <<: *jdk_11_definition
  script: *test_backend_converter_CellDesigner_definition

Piotr Gawron's avatar
Piotr Gawron committed
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
test:backend:converter_graphics:jdk-8:
  <<: *jdk_8_definition
  script: *test_backend_converter_graphics_definition

test:backend:converter_graphics:jdk-11:
  <<: *jdk_11_definition
  script: *test_backend_converter_graphics_definition

test:backend:converter_SBGNML:jdk-8:
  <<: *jdk_8_definition
  script: *test_backend_converter_SBGNML_definition

test:backend:converter_SBGNML:jdk-11:
  <<: *jdk_11_definition
  script: *test_backend_converter_SBGNML_definition

228
229
230
231
test:backend:converter_SBGNML:jdk-11-hsql:
  <<: *hsql_definition
  script: *test_backend_converter_SBGNML_definition

Piotr Gawron's avatar
Piotr Gawron committed
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
test:backend:converter_SBML:jdk-8:
  <<: *jdk_8_definition
  script: *test_backend_converter_SBML_definition

test:backend:converter_SBML:jdk-11:
  <<: *jdk_11_definition
  script: *test_backend_converter_SBML_definition

test:backend:model:jdk-8:
  <<: *jdk_8_definition
  script: *test_backend_model_definition

test:backend:model:jdk-11:
  <<: *jdk_11_definition
  script: *test_backend_model_definition

test:backend:model_command:jdk-8:
  <<: *jdk_8_definition
  script: *test_backend_model_command_definition

test:backend:model_command:jdk-11:
  <<: *jdk_11_definition
  script: *test_backend_model_command_definition

test:backend:pathvisio:jdk-8:
  <<: *jdk_8_definition
  script: *test_backend_pathvisio_definition

test:backend:pathvisio:jdk-11:
  <<: *jdk_11_definition
  script: *test_backend_pathvisio_definition

test:backend:persist:jdk-8:
  <<: *jdk_8_definition
  script: *test_backend_persist_definition

test:backend:persist:jdk-11:
  <<: *jdk_11_definition
  script: *test_backend_persist_definition

272
273
274
275
test:backend:persist:hsql:
  <<: *hsql_definition
  script: *test_backend_persist_definition

Piotr Gawron's avatar
Piotr Gawron committed
276
277
278
279
280
281
282
283
test:backend:rest:jdk-8:
  <<: *jdk_8_definition
  script: *test_backend_rest_definition

test:backend:rest:jdk-11:
  <<: *jdk_11_definition
  script: *test_backend_rest_definition

284
285
286
287
test:backend:rest:hsql:
  <<: *hsql_definition
  script: *test_backend_rest_definition

Piotr Gawron's avatar
Piotr Gawron committed
288
289
290
291
292
293
294
295
test:backend:service:jdk-8:
  <<: *jdk_8_definition
  script: *test_backend_service_definition

test:backend:service:jdk-11:
  <<: *jdk_11_definition
  script: *test_backend_service_definition

296
297
298
299
test:backend:service:hsql:
  <<: *hsql_definition
  script: *test_backend_service_definition

Piotr Gawron's avatar
Piotr Gawron committed
300
301
302
303
304
305
306
307
test:backend:web:jdk-8:
  <<: *jdk_8_definition
  script: *test_backend_web_definition

test:backend:web:jdk-11:
  <<: *jdk_11_definition
  script: *test_backend_web_definition

308
309
310
311
test:backend:web:hsql:
  <<: *jdk_11_definition
  script: *test_backend_web_definition

312
build_war:
Piotr Gawron's avatar
Piotr Gawron committed
313
  image: maven:3.6.0-jdk-8
314
  stage: build
315
316
  only:
    - tags
Piotr Gawron's avatar
Piotr Gawron committed
317
318
  tags:
     - privileged
319
  artifacts:
Piotr Gawron's avatar
Piotr Gawron committed
320
    expire_in: 1 day
321
322
323
    paths:
      - minerva.war
  script:
Piotr Gawron's avatar
Piotr Gawron committed
324
325
326
327
    - rm -rf /etc/minerva/
    - mkdir /etc/minerva/
    - cp test-hsql-db-ci.properties /etc/minerva/db.properties

328
    - apt-get update
329
    - DEBIAN_FRONTEND=noninteractive apt-get install -y curl gnupg git ant
330
    - curl -sL https://deb.nodesource.com/setup_9.x | bash -
331
    - DEBIAN_FRONTEND=noninteractive apt-get install -y nodejs
Piotr Gawron's avatar
Piotr Gawron committed
332
    - ant maven-build-with-doc
333
    - cp web/target/*.war minerva.war
334

Piotr Gawron's avatar
Piotr Gawron committed
335
test:dependency_conflict:
Piotr Gawron's avatar
Piotr Gawron committed
336
  image: maven:3.6.0-jdk-8
337
  stage: test
338
339
  script:
    - apt-get update
340
    - DEBIAN_FRONTEND=noninteractive apt-get install -y curl gnupg git ant
341
    - curl -sL https://deb.nodesource.com/setup_9.x | bash -
342
    - DEBIAN_FRONTEND=noninteractive apt-get install -y nodejs
343
344

    - mvn clean install -DskipTests=true
345
346
347
    - set +e
    - mvn dependency:tree -Dverbose | grep conflict | cat > conflicts.txt
    - set -e
348
349
350
351
352
    - conflicts=`cat conflicts.txt| wc -l`
    - echo Found conflicts $conflicts ':'
    - cat conflicts.txt
    - test 0 = $conflicts

Piotr Gawron's avatar
Piotr Gawron committed
353
354
355
356
357
358
359
360
361
362
363
364
test:code_validation:
  image: maven:3.6.0-jdk-8
  stage: test
  script:
    - apt-get update
    - DEBIAN_FRONTEND=noninteractive apt-get install -y curl gnupg git ant
    - curl -sL https://deb.nodesource.com/setup_9.x | bash -
    - DEBIAN_FRONTEND=noninteractive apt-get install -y nodejs

    - mvn clean compile validate


365
366
367
368
test:mvn_changelog_version_check:
  image: debian
  stage: test
  script:
369
    - set +e
370
371
    - mvn_version=`cat pom.xml |grep "<version>" |head -1 |cut -f2 -d'>' | cut -f1 -d'<'`
    - changelog_version=`cat CHANGELOG |grep minerva |head -1 | cut -f2 -d'(' | cut -f1 -d')'`
Piotr Gawron's avatar
Piotr Gawron committed
372
373
    - echo "Maven version:" $mvn_version
    - echo "Changelog version:" $changelog_version
374
    - set -e
375
376
377
    - test $mvn_version = $changelog_version


378
379
build_debian_package:
  image: debian
Piotr Gawron's avatar
Piotr Gawron committed
380
  stage: packaging
381
382
  only:
    - tags
383
384
  tags:
     - privileged
385
386
  dependencies:
    - build_war
387
  artifacts:
388
389
# you cannot enforce never here yet
    expire_in: 1000 yrs
390
391
392
    paths:
      - "debian/*.deb"
  script:
393
    - mkdir web/target/
Piotr Gawron's avatar
Piotr Gawron committed
394
    - mv minerva.war web/target/web-1.0.war
395
    - apt-get update
396
    - DEBIAN_FRONTEND=noninteractive apt-get install -y dh-make build-essential lintian devscripts xsltproc fakeroot xsltproc docbook-xsl
397
398
    - export DEBFULLNAME="Piotr Gawron"
    - export DEBEMAIL="piotr.gawron@uni.lu"
399
    - debian/create-debian-pkg.sh
400

Piotr Gawron's avatar
Piotr Gawron committed
401
test_upgrade_debian_package:
402
  image: debian:stretch
Piotr Gawron's avatar
Piotr Gawron committed
403
404
405
406
407
408
409
410
411
412
413
414
415
  stage: test
  only:
    - tags
# we need to run it in privileged mode due to: https://stackoverflow.com/questions/29683231/tomcat7-fail-to-start-inside-ubuntu-docker-container
  tags:
     - privileged
  services:
     - name: piotrgawron/debian-repo
       alias: debian-repo
  dependencies:
     - build_debian_package
  script:
     - apt-get update
416
417
     - DEBIAN_FRONTEND=noninteractive apt-get install -y ssh software-properties-common dirmngr wget curl apt-transport-https postgresql
     - service postgresql start
Piotr Gawron's avatar
Piotr Gawron committed
418
419
420
421
422
     - debian_file=$(ls debian/*.deb)
     - version=$(echo $debian_file| cut -f2 -d"_")
     - echo "PUT $debian_file /docker/incoming" | sftp -o StrictHostKeyChecking=no user@debian-repo
     - ssh root@debian-repo /usr/local/sbin/reprepro-import
     - apt-add-repository "deb http://repo-r3lab.uni.lu/debian/ stable main"
Piotr Gawron's avatar
Piotr Gawron committed
423
     - apt-key adv --no-tty --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0xcb185f4e31872412
424
425
426
427
428
429
     - echo debconf minerva/internal/skip-preseed boolean true | debconf-set-selections
     - echo debconf minerva/dbconfig-install select true | debconf-set-selections
     - echo debconf minerva/pgsql/app-pass select secret_password | debconf-set-selections
     - echo debconf minerva/remote/host select localhost | debconf-set-selections
     - echo debconf minerva/db/dbname select minerva_db | debconf-set-selections
     - echo debconf minerva/db/app-user select minerva_user@localhost | debconf-set-selections
Piotr Gawron's avatar
Piotr Gawron committed
430
431
432
     - apt-get update
#hacky way of installing minerva on docker - by default rc-invoke is preventing services changes on docker
     - mv /usr/sbin/policy-rc.d /usr/sbin/policy-rc.d.backup
Piotr Gawron's avatar
Piotr Gawron committed
433
     - mv gitlab-ci-policy-rc.d /usr/sbin/policy-rc.d
434
     - chmod 0755 /usr/sbin/policy-rc.d
435
     - DEBIAN_FRONTEND=noninteractive apt-get install -y --allow-unauthenticated minerva
Piotr Gawron's avatar
Piotr Gawron committed
436
437
438

#local repository with new version
     - apt-add-repository "deb http://debian-repo/ unstable main"
439
     - apt-get update --allow-unauthenticated
Piotr Gawron's avatar
Piotr Gawron committed
440
     - apt-get dist-upgrade -y --allow-unauthenticated
Piotr Gawron's avatar
Piotr Gawron committed
441
     - mv /usr/sbin/policy-rc.d.backup /usr/sbin/policy-rc.d
Piotr Gawron's avatar
Piotr Gawron committed
442
443
444
445
446
447
     - service tomcat8 start
#we need to wait a bit for tomcat start
     - sleep 15
     - wget http://localhost:8080/minerva/

#test if we can login and get configuration using new version
448
     - test 200 = $(curl -X POST -d "login=admin&password=admin" --write-out %{http_code} --silent --output /dev/null -c cookie.txt http://localhost:8080/minerva/api/doLogin)
Piotr Gawron's avatar
Piotr Gawron committed
449
450
451
     - test 200 = $(curl --write-out %{http_code} --silent --output configuration.json --cookie cookie.txt http://localhost:8080/minerva/api/configuration/)
     - test 1 = $(cat configuration.json| grep $version | wc -l)

452
test_install_debian_package:
453
  image: debian:stretch
454
  stage: test
455
456
  only:
    - tags
Piotr Gawron's avatar
Piotr Gawron committed
457
# we need to run it in privileged mode due to: https://stackoverflow.com/questions/29683231/tomcat7-fail-to-start-inside-ubuntu-docker-container
458
459
  tags:
     - privileged
460
461
462
  services:
     - name: piotrgawron/debian-repo
       alias: debian-repo
463
464
  dependencies:
     - build_debian_package
465
466
  script:
     - apt-get update
467
468
     - DEBIAN_FRONTEND=noninteractive apt-get install -y ssh software-properties-common dirmngr wget curl postgresql
     - service postgresql start
469
     - debian_file=$(ls debian/*.deb)
Piotr Gawron's avatar
Piotr Gawron committed
470
     - echo "PUT $debian_file /docker/incoming" | sftp -o StrictHostKeyChecking=no user@debian-repo
471
472
     - ssh root@debian-repo /usr/local/sbin/reprepro-import
     - apt-add-repository "deb http://debian-repo/ unstable main"
473
474
475
476
477
478
     - echo debconf minerva/internal/skip-preseed boolean true | debconf-set-selections
     - echo debconf minerva/dbconfig-install select true | debconf-set-selections
     - echo debconf minerva/pgsql/app-pass select secret_password | debconf-set-selections
     - echo debconf minerva/remote/host select localhost | debconf-set-selections
     - echo debconf minerva/db/dbname select minerva_db | debconf-set-selections
     - echo debconf minerva/db/app-user select minerva_user@localhost | debconf-set-selections
479
     - apt-get update --allow-insecure-repositories
Piotr Gawron's avatar
Piotr Gawron committed
480
#hacky way of installing minerva on docker - by default rc-invoke is preventing services changes on docker
481
     - mv /usr/sbin/policy-rc.d /usr/sbin/policy-rc.d.backup
Piotr Gawron's avatar
Piotr Gawron committed
482
     - mv gitlab-ci-policy-rc.d /usr/sbin/policy-rc.d
483
     - chmod 0755 /usr/sbin/policy-rc.d
484
     - DEBIAN_FRONTEND=noninteractive apt-get install -y --allow-unauthenticated minerva
485
486
     - mv /usr/sbin/policy-rc.d.backup /usr/sbin/policy-rc.d 
     - service tomcat8 start
Piotr Gawron's avatar
Piotr Gawron committed
487
#we need to wait a bit for tomcat start
488
489
     - sleep 15
     - wget http://localhost:8080/minerva/
Piotr Gawron's avatar
Piotr Gawron committed
490
#test if we can login and list projects
491
     - test 200 = $(curl -X POST -d "login=admin&password=admin" --write-out %{http_code} --silent --output /dev/null -c cookie.txt http://localhost:8080/minerva/api/doLogin)
492
493
     - test 200 = $(curl --write-out %{http_code} --silent --output /dev/null --cookie cookie.txt http://localhost:8080/minerva/api/projects/)

Piotr Gawron's avatar
Piotr Gawron committed
494
495
build_rpm:
  image: centos:7
Piotr Gawron's avatar
Piotr Gawron committed
496
  stage: packaging
Piotr Gawron's avatar
Piotr Gawron committed
497
498
  dependencies:
    - build_war
499
500
  only:
    - tags
Piotr Gawron's avatar
Piotr Gawron committed
501
502
503
  tags:
     - privileged
  artifacts:
504
505
# you cannot enforce never here yet
    expire_in: 1000 yrs
Piotr Gawron's avatar
Piotr Gawron committed
506
507
508
509
510
    paths:
      - "rpm/rpmbuildtemp/RPMS/noarch/minerva-*.rpm"
  script:
    - yum -y install rpmdevtools unzip
    - rpm/buildrpm.sh minerva.war
511

Piotr Gawron's avatar
Piotr Gawron committed
512
513
514
515
516
517
518
rpmlint:
  image: centos:7
  stage: test
  dependencies:
    - build_rpm
  tags:
     - privileged
519
520
  only:
    - tags
Piotr Gawron's avatar
Piotr Gawron committed
521
522
  script:
    - yum -y install rpmlint
Piotr Gawron's avatar
Piotr Gawron committed
523
    - rpmlint -f rpm/rpmlint.config rpm/rpmbuildtemp/RPMS/noarch/minerva-*.rpm
Piotr Gawron's avatar
Piotr Gawron committed
524

525
test_deploy_with_db_without_superadmin_rights:
526
  image: tomcat:8-jre8
527
528
529
530
531
532
533
534
535
536
537
  stage: test
  services:
    - postgres:9.6
  dependencies:
    - build_war
  tags:
    - privileged
  only:
    - tags
  script:
    - apt-get update
538
    - DEBIAN_FRONTEND=noninteractive apt-get install -y postgresql-client
539
    - mkdir -p /etc/minerva
540
541
542
543
544
    - echo "database.uri=jdbc:postgresql://postgres:5432/test" > /etc/minerva/db.properties
    - echo "database.username=test" >> /etc/minerva/db.properties
    - echo "database.password=test" >> /etc/minerva/db.properties
    - echo "CREATE DATABASE test;CREATE USER test WITH ENCRYPTED PASSWORD 'test';GRANT ALL PRIVILEGES ON DATABASE test TO test;" >tmp.sql
    - PGPASSWORD=$POSTGRES_PASSWORD psql -h postgres -U $POSTGRES_USER $POSTGRES_DB < tmp.sql
545
    - mv minerva.war /usr/local/tomcat/webapps/minerva.war
546
547
    - /usr/local/tomcat/bin/startup.sh
    - sleep 15
548
    - wget http://localhost:8080/minerva/
549
#test if we can login and list projects
550
    - test 200 = $(curl -X POST -d "login=admin&password=admin" --write-out %{http_code} --silent --output /dev/null -c cookie.txt http://localhost:8080/minerva/api/doLogin)
551
552
    - test 200 = $(curl --write-out %{http_code} --silent --output /dev/null --cookie cookie.txt http://localhost:8080/minerva/api/projects/)

553
554

.test_database_template: &test_database_definition
555
556
557
558
559
560
  image: maven:3.6.0-jdk-8
  stage: test
  script:
    - mvn -DskipTests=true clean install -pl persist -am
    - mvn test -pl persist

561
562
563
564
565
test_postgres_9_3_compatibility:
  <<: *test_database_definition
  services:
    - postgres:9.3

566
test_postgres_10_compatibility:
567
  <<: *test_database_definition
568
569
570
571
  services:
    - postgres:10

test_postgres_11_compatibility:
572
  <<: *test_database_definition
573
574
  services:
    - postgres:11