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

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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219

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

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

220
221
222
223
test:backend:converter_SBGNML:jdk-11-hsql:
  <<: *hsql_definition
  script: *test_backend_converter_SBGNML_definition

Piotr Gawron's avatar
Piotr Gawron committed
224
225
226
227
228
229
230
231
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
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

264
265
266
267
test:backend:persist:hsql:
  <<: *hsql_definition
  script: *test_backend_persist_definition

Piotr Gawron's avatar
Piotr Gawron committed
268
269
270
271
272
273
274
275
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

276
277
278
279
test:backend:rest:hsql:
  <<: *hsql_definition
  script: *test_backend_rest_definition

Piotr Gawron's avatar
Piotr Gawron committed
280
281
282
283
284
285
286
287
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

288
289
290
291
test:backend:service:hsql:
  <<: *hsql_definition
  script: *test_backend_service_definition

Piotr Gawron's avatar
Piotr Gawron committed
292
293
294
295
296
297
298
299
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

300
301
302
303
test:backend:web:hsql:
  <<: *jdk_11_definition
  script: *test_backend_web_definition

304
build_war:
Piotr Gawron's avatar
Piotr Gawron committed
305
  image: maven:3.6.0-jdk-8
306
  stage: build
307
308
  only:
    - tags
Piotr Gawron's avatar
Piotr Gawron committed
309
310
  tags:
     - privileged
311
  artifacts:
Piotr Gawron's avatar
Piotr Gawron committed
312
    expire_in: 1 day
313
314
315
    paths:
      - minerva.war
  script:
Piotr Gawron's avatar
Piotr Gawron committed
316
317
318
319
    - rm -rf /etc/minerva/
    - mkdir /etc/minerva/
    - cp test-hsql-db-ci.properties /etc/minerva/db.properties

320
    - apt-get update
321
    - DEBIAN_FRONTEND=noninteractive apt-get install -y curl gnupg git ant
322
    - curl -sL https://deb.nodesource.com/setup_9.x | bash -
323
    - DEBIAN_FRONTEND=noninteractive apt-get install -y nodejs
Piotr Gawron's avatar
Piotr Gawron committed
324
    - ant maven-build-with-doc
325
    - cp web/target/*.war minerva.war
326

Piotr Gawron's avatar
Piotr Gawron committed
327
test:dependency_conflict:
Piotr Gawron's avatar
Piotr Gawron committed
328
  image: maven:3.6.0-jdk-8
329
  stage: test
330
331
  script:
    - apt-get update
332
    - DEBIAN_FRONTEND=noninteractive apt-get install -y curl gnupg git ant
333
    - curl -sL https://deb.nodesource.com/setup_9.x | bash -
334
    - DEBIAN_FRONTEND=noninteractive apt-get install -y nodejs
335
336

    - mvn clean install -DskipTests=true
337
338
339
    - set +e
    - mvn dependency:tree -Dverbose | grep conflict | cat > conflicts.txt
    - set -e
340
341
342
343
344
    - conflicts=`cat conflicts.txt| wc -l`
    - echo Found conflicts $conflicts ':'
    - cat conflicts.txt
    - test 0 = $conflicts

345
346
347
348
test:mvn_changelog_version_check:
  image: debian
  stage: test
  script:
349
    - set +e
350
351
    - 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
352
353
    - echo "Maven version:" $mvn_version
    - echo "Changelog version:" $changelog_version
354
    - set -e
355
356
357
    - test $mvn_version = $changelog_version


358
359
build_debian_package:
  image: debian
Piotr Gawron's avatar
Piotr Gawron committed
360
  stage: packaging
361
362
  only:
    - tags
363
364
  tags:
     - privileged
365
366
  dependencies:
    - build_war
367
  artifacts:
368
369
# you cannot enforce never here yet
    expire_in: 1000 yrs
370
371
372
    paths:
      - "debian/*.deb"
  script:
373
    - mkdir web/target/
Piotr Gawron's avatar
Piotr Gawron committed
374
    - mv minerva.war web/target/web-1.0.war
375
    - apt-get update
376
    - DEBIAN_FRONTEND=noninteractive apt-get install -y dh-make build-essential lintian devscripts xsltproc fakeroot xsltproc docbook-xsl
377
378
    - export DEBFULLNAME="Piotr Gawron"
    - export DEBEMAIL="piotr.gawron@uni.lu"
379
    - debian/create-debian-pkg.sh
380

Piotr Gawron's avatar
Piotr Gawron committed
381
test_upgrade_debian_package:
382
  image: debian:stretch
Piotr Gawron's avatar
Piotr Gawron committed
383
384
385
386
387
388
389
390
391
392
393
394
395
  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
396
397
     - 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
398
399
400
401
402
     - 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
403
     - apt-key adv --no-tty --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0xcb185f4e31872412
404
405
406
407
408
409
     - 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
410
411
412
     - 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
413
     - mv gitlab-ci-policy-rc.d /usr/sbin/policy-rc.d
414
     - chmod 0755 /usr/sbin/policy-rc.d
415
     - DEBIAN_FRONTEND=noninteractive apt-get install -y --allow-unauthenticated minerva
Piotr Gawron's avatar
Piotr Gawron committed
416
417
418

#local repository with new version
     - apt-add-repository "deb http://debian-repo/ unstable main"
419
     - apt-get update --allow-unauthenticated
Piotr Gawron's avatar
Piotr Gawron committed
420
     - apt-get dist-upgrade -y --allow-unauthenticated
Piotr Gawron's avatar
Piotr Gawron committed
421
     - mv /usr/sbin/policy-rc.d.backup /usr/sbin/policy-rc.d
Piotr Gawron's avatar
Piotr Gawron committed
422
423
424
425
426
427
     - 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
428
     - 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
429
430
431
     - 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)

432
test_install_debian_package:
433
  image: debian:stretch
434
  stage: test
435
436
  only:
    - tags
Piotr Gawron's avatar
Piotr Gawron committed
437
# we need to run it in privileged mode due to: https://stackoverflow.com/questions/29683231/tomcat7-fail-to-start-inside-ubuntu-docker-container
438
439
  tags:
     - privileged
440
441
442
  services:
     - name: piotrgawron/debian-repo
       alias: debian-repo
443
444
  dependencies:
     - build_debian_package
445
446
  script:
     - apt-get update
447
448
     - DEBIAN_FRONTEND=noninteractive apt-get install -y ssh software-properties-common dirmngr wget curl postgresql
     - service postgresql start
449
     - debian_file=$(ls debian/*.deb)
Piotr Gawron's avatar
Piotr Gawron committed
450
     - echo "PUT $debian_file /docker/incoming" | sftp -o StrictHostKeyChecking=no user@debian-repo
451
452
     - ssh root@debian-repo /usr/local/sbin/reprepro-import
     - apt-add-repository "deb http://debian-repo/ unstable main"
453
454
455
456
457
458
     - 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
459
     - apt-get update --allow-insecure-repositories
Piotr Gawron's avatar
Piotr Gawron committed
460
#hacky way of installing minerva on docker - by default rc-invoke is preventing services changes on docker
461
     - mv /usr/sbin/policy-rc.d /usr/sbin/policy-rc.d.backup
Piotr Gawron's avatar
Piotr Gawron committed
462
     - mv gitlab-ci-policy-rc.d /usr/sbin/policy-rc.d
463
     - chmod 0755 /usr/sbin/policy-rc.d
464
     - DEBIAN_FRONTEND=noninteractive apt-get install -y --allow-unauthenticated minerva
465
466
     - mv /usr/sbin/policy-rc.d.backup /usr/sbin/policy-rc.d 
     - service tomcat8 start
Piotr Gawron's avatar
Piotr Gawron committed
467
#we need to wait a bit for tomcat start
468
469
     - sleep 15
     - wget http://localhost:8080/minerva/
Piotr Gawron's avatar
Piotr Gawron committed
470
#test if we can login and list projects
471
     - 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)
472
473
     - 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
474
475
build_rpm:
  image: centos:7
Piotr Gawron's avatar
Piotr Gawron committed
476
  stage: packaging
Piotr Gawron's avatar
Piotr Gawron committed
477
478
  dependencies:
    - build_war
479
480
  only:
    - tags
Piotr Gawron's avatar
Piotr Gawron committed
481
482
483
  tags:
     - privileged
  artifacts:
484
485
# you cannot enforce never here yet
    expire_in: 1000 yrs
Piotr Gawron's avatar
Piotr Gawron committed
486
487
488
489
490
    paths:
      - "rpm/rpmbuildtemp/RPMS/noarch/minerva-*.rpm"
  script:
    - yum -y install rpmdevtools unzip
    - rpm/buildrpm.sh minerva.war
491

Piotr Gawron's avatar
Piotr Gawron committed
492
493
494
495
496
497
498
rpmlint:
  image: centos:7
  stage: test
  dependencies:
    - build_rpm
  tags:
     - privileged
499
500
  only:
    - tags
Piotr Gawron's avatar
Piotr Gawron committed
501
502
  script:
    - yum -y install rpmlint
Piotr Gawron's avatar
Piotr Gawron committed
503
    - rpmlint -f rpm/rpmlint.config rpm/rpmbuildtemp/RPMS/noarch/minerva-*.rpm
Piotr Gawron's avatar
Piotr Gawron committed
504

505
test_deploy_with_db_without_superadmin_rights:
506
  image: tomcat:8-jre8
507
508
509
510
511
512
513
514
515
516
517
  stage: test
  services:
    - postgres:9.6
  dependencies:
    - build_war
  tags:
    - privileged
  only:
    - tags
  script:
    - apt-get update
518
    - DEBIAN_FRONTEND=noninteractive apt-get install -y postgresql-client
519
520
521
522
523
524
    - mkdir /etc/minerva
    - 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
525
    - mv minerva.war /usr/local/tomcat/webapps/minerva.war
526
527
    - /usr/local/tomcat/bin/startup.sh
    - sleep 15
528
    - wget http://localhost:8080/minerva/
529
#test if we can login and list projects
530
    - 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)
531
532
    - test 200 = $(curl --write-out %{http_code} --silent --output /dev/null --cookie cookie.txt http://localhost:8080/minerva/api/projects/)

533
534

.test_database_template: &test_database_definition
535
536
537
538
539
540
  image: maven:3.6.0-jdk-8
  stage: test
  script:
    - mvn -DskipTests=true clean install -pl persist -am
    - mvn test -pl persist

541
542
543
544
545
test_postgres_9_3_compatibility:
  <<: *test_database_definition
  services:
    - postgres:9.3

546
test_postgres_10_compatibility:
547
  <<: *test_database_definition
548
549
550
551
  services:
    - postgres:10

test_postgres_11_compatibility:
552
  <<: *test_database_definition
553
554
  services:
    - postgres:11