.gitlab-ci.yml 13.1 KB
Newer Older
1 2

before_script:
Mathieu Giraud's avatar
Mathieu Giraud committed
3
  - make demo
4 5
  - make data
  - make germline
6
  - make -C browser sha1
7
  - cp -p doc/analysis-example.vidjil browser/
8 9

stages:
10
  - test_tools
11
  - test_quality
12
  - test_unit
13
  - deploy_review
14
  - test_germlines
15
  - test_functional
16
  - test_shouldvdj
17
  - test_functional_external
18
  - coverage
19
  - prepare_release
20
  - tgz_release
Mathieu Giraud's avatar
Mathieu Giraud committed
21 22
  - valgrind_unit
  - valgrind_functional
23
  - multiple_tests
24
  - benchmark
25
  - publish_release
26
  - deploy_prod
27

28 29
# Anchors

30 31
.coverage_dependency:
  artifacts: &lcov_artifact
32 33
    paths:
      - algo/lcov_test_*.filtered
34
    expire_in: 1 week
35

36 37 38 39 40 41
# Tools

test_tools:
  stage: test_tools
  script: make -C tools/tests

42 43 44 45 46 47 48

# Germlines

test_germlines:
  stage: test_germlines
  script:
    - make -C germline get-all-data
49
    - make -C germline tests
50
  only:
51
    - /^feature-.*g.*\/.*$/
52
    - schedules
53

54 55 56 57
# Doc

include:
  - local: '/doc/.gitlab-ci.yml'
58
  - local: 'algo/.gitlab-ci-compilers.yml' # Stage multiple_tests
59
  - local: 'algo/.gitlab-ci.yml' # Vidjil-algo pipelines
60

Mathieu Giraud's avatar
Mathieu Giraud committed
61
# Algorithm
62 63 64

test_algo_unit:
  stage: test_unit
65
  script: make -C algo unit_coverage
66 67
  artifacts:
    <<: *lcov_artifact
68
  only:
69
    - /^feature-.*a.*\/.*$/
70
    - schedules
71

72 73
test_algo_should:
  stage: test_functional
74
  script: make -C algo should_coverage
75
  artifacts:
76
    <<: *lcov_artifact
77 78
    reports:
      junit: algo/tests/should.xml
79
  only:
80
    - /^feature-.*a.*\/.*$/
81
    - schedules
82 83 84

test_algo_shouldvdj:
  stage: test_shouldvdj
85
  script: make -C algo shouldvdj_coverage
86 87
  artifacts:
    <<: *lcov_artifact
88 89
  only:
    - /^feature-.*a.*\/.*$/
90 91
    - schedules
  
92 93
algo_coverage:
  stage: coverage
94
  coverage: /^\s*lines\.*:\s+([0-9.]+\%)/
95 96 97
  script:
    - make -C algo lcov_reports
    - mv algo/reports/ coverage
98 99
  artifacts:
    paths:
100
      - coverage/
101
    expire_in: 1 week
102
  only:
103
    - /^feature-.*a.*\/.*$/
104
    - schedules
105

Mathieu Giraud's avatar
Mathieu Giraud committed
106 107
algo_valgrind_unit:
  stage: valgrind_unit
108
  script: make -C algo valgrind_unit
Mathieu Giraud's avatar
Mathieu Giraud committed
109
  only:
110
    - /^feature-.*a.*\/.*$/
111
    - schedules
112 113
  tags:
    - valgrind
Mathieu Giraud's avatar
Mathieu Giraud committed
114

115
.snip_valgrind_functional: &valgrind_functional
Mathieu Giraud's avatar
Mathieu Giraud committed
116
  stage: valgrind_functional
117
  script: make -C algo valgrind_should
118 119 120 121 122
  tags:
    - valgrind

algo_valgrind_functional:
  <<: *valgrind_functional
Mathieu Giraud's avatar
Mathieu Giraud committed
123 124
  when: manual
  only:
125
    - /^feature-.*a.*\/.*$/
126
    - schedules
127 128 129

release_valgrind_functional:
  <<: *valgrind_functional
130
  allow_failure: true
131 132
  only:
    - /^feature-.*a.*\/release$/
Mathieu Giraud's avatar
Mathieu Giraud committed
133

134 135 136 137 138
prepare_release:
  stage: prepare_release
  script: make -C algo release RELEASE_TAG='rc'
  when: manual
  only:
139
    - /^feature-.*a.*\/.*$/
140

141 142
tgz_release:
  stage: tgz_release
143 144
  script: make -C algo release RELEASE_TAG=`cat algo/release`
  only:
145
    - /^feature-.*a.*\/release$/
146
  artifacts:
147
    paths:
148 149
    - algo/releases/vidjil-algo-`cat algo/release`.tar.gz
    - algo/releases/vidjil-algo-`cat algo/release`/vidjil-algo-`cat algo/release`_`uname -m`
150
    expire_in: 10 years
151
  allow_failure: false
152 153
  tags:
    - ubuntu-16.04-amd64
154

155
copy_release:
156
  stage: publish_release
157 158 159 160 161 162 163 164
  script:
    - |
      for repo in $ALGO_REPOSITORIES; do
        echo "Copying release to $repo"
        scp algo/releases/vidjil-algo*.tar.gz algo/releases/vidjil-algo*/vidjil-algo-*_* $repo
      done
      release_name=$(cat algo/release)
      ssh $VIDJIL_WWW "cd /var/www/html/releases; ln -sf vidjil-algo-${release_name}.tar.gz vidjil-latest.tgz; ln -sf vidjil-algo-${release_name}_x86_64 vidjil-latest_x86_64"
Mikaël Salson's avatar
Mikaël Salson committed
165
      ssh $VIDJIL_BONSAI "cd /bio1/www/html/vidjil; scp vidjil-algo-${release_name}* $VIDJIL_BONSAI_PROD:/bio1/www/html/vidjil"
166
  when: manual
167 168 169
  only:
    - /^feature-.*a.*\/release$/

170 171
deploy_release_prod:
  stage: deploy_prod
172
  when: manual
173 174 175 176 177
  only:
    - /^feature-.*a.*\/release$/
  script:
    - |
      release_name=$(cat algo/release)
178
      ssh $DEPLOY_SERVER "cd releases/vidjil;\
179
          tar xvzf vidjil-algo-${release_name}.tar.gz;\
180 181
          make -C vidjil-algo-${release_name};\
          ln -sfT vidjil-algo-${release_name} next"
182

Mathieu Giraud's avatar
Mathieu Giraud committed
183
# Client
184

185
test_browser_unit:
186
  stage: test_unit
Mathieu Giraud's avatar
Mathieu Giraud committed
187
  script: make unit_browser
188 189 190
  artifacts:
    paths:
    - browser/
191
  only:
192 193
    - /^feature-.*c.*\/.*$/
    - /^hotfix-.*c.*\/.*$/
Mathieu Giraud's avatar
Mathieu Giraud committed
194
    - prod-client
195
    - dev
196
    - schedules
197 198
  tags:
    - web
199

200
.browser-functional:
201
  stage: test_functional
202
  retry: 2
203 204 205
  script:
    - make -C browser
    - source /etc/profile.d/rvm.sh
206
    - rvm use 2.6.1
207
    - HEADLESS=1 make -C browser/test functional
208 209 210
  artifacts:
    paths:
    - browser/
211 212
    reports:
      junit: browser/test/test/TEST-*.xml
213
  only:
214 215
    - /^feature-.*c.*\/.*$/
    - /^hotfix-.*c.*\/.*$/
216
    - prod-client
217
    - schedules
218 219
  tags:
    - web
220

221 222 223 224 225
.browser-functional-chrome:
  extends: .browser-functional
  variables:
    WATIR_CHROME: "1"

226
.browser-functional-external:
227
  stage: test_functional_external
228
  retry: 2
229 230 231
  script:
    - make -C browser
    - source /etc/profile.d/rvm.sh
232
    - rvm use 2.6.1
233
    - HEADLESS=1 make -C browser/test external
234 235 236
  artifacts:
    paths:
    - browser/
237 238
    reports:
      junit: browser/test/test/TEST-*.xml
239
  only:
240 241
    - /^feature-.*c.*\/.*$/
    - /^hotfix-.*c.*\/.*$/
Mathieu Giraud's avatar
Mathieu Giraud committed
242
    - prod-client
243
    - schedules
244 245
  tags:
    - web
246

247 248 249 250 251
.browser-functional-external-chrome:
  extends: .browser-functional-external
  variables:
    WATIR_CHROME: "1"
    
252
ff32-browser-functional:
253 254
  extends: .browser-functional
  variables:
255
    FIREFOX_VERSION: 32
256

257
ff45-browser-functional:
258 259
  extends: .browser-functional
  variables:
260 261
    FIREFOX_VERSION: 45

262
chrome-browser-functional:
263 264
  extends: .browser-functional-chrome
        
265
old-chrome-browser-functional:
266
  extends: .browser-functional-chrome
267 268 269
  tags:
    - legacy

270
ff32-browser-functional-external:
271 272
  extends: .browser-functional-external
  variables:
273
    FIREFOX_VERSION: 32
274

275
ff45-browser-functional-external:
276 277
  extends: .browser-functional-external
  variables:
278
    FIREFOX_VERSION: 45
279

280
chrome-browser-functional-external:
281 282
  extends: .browser-functional-external-chrome
    
283
old-chrome-browser-functional-external-chrome:
284 285 286
  extends: .browser-functional-external-chrome
  tags:
    - legacy
287

288 289
code_quality:
  stage: test_quality
290
  script: make -C browser quality
291
  only:
292 293
    - /^feature-.*c.*\/.*$/
    - /^hotfix-.*c.*\/.*$/
294
    - prod-client
295
    - dev
296
    - schedules
297 298
  tags:
    - web
299

Ryan Herbert's avatar
Ryan Herbert committed
300 301 302 303 304
# Server

test_server_unit:
    stage: test_unit
    script:
305 306
      - virtualenv $CI_COMMIT_SHORT_SHA
      - source $CI_COMMIT_SHORT_SHA/bin/activate
307
      - pip install -r requirements.txt
Ryan Herbert's avatar
Ryan Herbert committed
308
      - make -C server install_web2py_standalone
309
      - make -C server launch_fuse_server
310
      - make unit_server || (make -C server kill_fuse_server; deactivate; false)
Ryan Herbert's avatar
Ryan Herbert committed
311
      - make -C server kill_fuse_server
312
      - deactivate
313 314 315
    artifacts:
      reports:
        junit: server/web2py/test-reports/TEST*xml
Ryan Herbert's avatar
Ryan Herbert committed
316
    only:
317 318
      - /^feature-.*s.*\/.*$/
      - /^hotfix-.*s.*\/.*$/
Ryan Herbert's avatar
Ryan Herbert committed
319 320
      - prod-server
      - dev
321
      - schedules
Ryan Herbert's avatar
Ryan Herbert committed
322 323 324
    tags:
      - web

325
.test_server_functional:
326 327
  stage: test_functional
  script:
328 329
    - docker build --no-cache --build-arg git_branch=$CI_COMMIT_REF_NAME --build-arg build_env=TEST -t "vidjil/server:test" docker/vidjil-server
    - docker build --no-cache --build-arg git_branch=$CI_COMMIT_REF_NAME --build-arg build_env=TEST -t "vidjil/client:test" docker/vidjil-client
330
    - sed -i '/\:\/etc\/nginx\/ssl/d' ./docker/docker-compose.yml
331 332 333
    - sed -i '/\/var\/lib\/mysql/d' ./docker/docker-compose.yml
    - sed -i 's/\/opt\/vidjil\/databases/databases/' ./docker/docker-compose.yml
    - echo -e "volumes:\n    databases:" >> ./docker/docker-compose.yml
334
    - sed -i 's/\:latest/\:test/g' ./docker/docker-compose.yml
335
    - cd docker/vidjil-server/conf/ && mv defs.py defs_https.py && mv defs_http.py defs.py && cd ../../..
336
    - make germline && cp browser/js/germline.js docker/vidjil-client/conf
337
    - mkdir -p docker/postfix/ssl
338
    - cd docker && docker-compose up -d && cd ..
339
    - sed -i "s/^python\ \.\.\/\.\.\/\.\./docker\ exec\ docker_uwsgi_1\ python\ \/usr\/share\/vidjil\/server\/web2py/" server/web2py/applications/vidjil/tests/init_tests.sh
340
    - docker exec docker_uwsgi_1 sed -i "s/^\(FILE_SOURCE .*\)/FILE_SOURCE = '\/usr\/share\/vidjil\/demo'/" /usr/share/vidjil/server/web2py/applications/vidjil/modules/defs.py
341
    - docker exec docker_nginx_1 make -C /usr/share/vidjil browser
342
    - source /etc/profile.d/rvm.sh
343
    - rvm use 2.6.1
344 345
    - HEADLESS=1 make functional_server
  after_script:
346
    - cd docker && docker-compose down -v
347
    - docker rmi "vidjil/server:test" "vidjil/client:test" reporter:test
348 349 350
  artifacts:
    reports:
      junit: server/web2py/applications/vidjil/tests/test/TEST-*.xml
351 352 353 354 355
  only:
    - /^feature-.*s.*\/.*$/
    - /^hotfix-.*s.*\/.*$/
    - prod-server
    - dev
356
    - schedules
357
  tags:
358
    - x86_64
359
    - docker
360

361
ff32-server-functional:
362 363 364 365
  extends: .test_server_functional
  variables:
    FIREFOX_VERSION: 32

366
ff45-server-functional:
367 368 369 370 371
  extends: .test_server_functional
  variables:
    FIREFOX_VERSION: 45


372 373 374 375

# Benchmark

benchmark_algo:
376
  image:  gcc:6.3
377
  extends: .install-algo-dependencies
378 379
  stage: benchmark
  script:
380
    - cd algo/tests ; python3 benchmark-releases.py -r 3 -bIc
381 382 383
  artifacts:
    paths:
      - algo/tests/benchmark.log
384 385 386 387
  when: manual
  only:
    - /^feature-.*a.*\/.*$/
  tags:
388
    - cidocker
389 390


Ryan Herbert's avatar
Ryan Herbert committed
391 392
# Deployment

393 394
deploy_review:
  stage: deploy_review
395
  script:
396
    - make -C browser icons
397
    - echo "$REVIEW_CONFIG_JS" > browser/js/conf.js
398
    - rsync -av --delete browser $REVIEW_SERVER:$REVIEW_SERVER_PATH$CI_BUILD_REF_SLUG
399
  environment:
400
    name: review/$CI_BUILD_REF_NAME
Mikaël Salson's avatar
Mikaël Salson committed
401
    url: http://$CI_BUILD_REF_SLUG.ci.vidjil.org/?data=analysis-example.vidjil
Mathieu Giraud's avatar
Mathieu Giraud committed
402
    on_stop: stop_deploy_review
403
  only:
404 405
    - /^feature-.*c.*\/.*$/
    - /^hotfix-.*c.*\/.*$/
406 407
  tags:
    - web
408

409 410 411
deploy_review_server:
  stage: deploy_review
  script:
412 413
    - make -C browser icons
    - cp ./docker/vidjil-client/conf/conf.js ./browser/js/conf.js
414
    - sed -i -r "s/localhost/${CI_BUILD_REF_SLUG}.server.ci.vidjil.org/g" ./browser/js/conf.js
415
    - sed -r 's/^.*FILE_SOURCE.*$/FILE_SOURCE="\/usr\/share\/vidjil\/demo"/' ./docker/vidjil-server/conf/defs.py > ./server/web2py/applications/vidjil/modules/defs.py
416
    - sed -i -e "/EMAIL_SUBJECT_START/c EMAIL_SUBJECT_START='[Vidjil/CI][$CI_COMMIT_REF_NAME]'" -e '/FROM_EMAIL/c FROM_EMAIL="server.ci@vidjil.org"' ./server/web2py/applications/vidjil/modules/defs.py
417 418
    - mv docker docker_${CI_BUILD_REF_SLUG}
    - cd docker_${CI_BUILD_REF_SLUG}
419 420
    - TMP_DOCKER=$(tempfile)
    - cp docker-compose.yml $TMP_DOCKER
421 422
    - awk -f ci/for-review.awk $TMP_DOCKER > docker-compose.yml
    - rm -f $TMP_DOCKER
423
    - sed -i -r "s/WEB2PY_ADMIN_PASSWORD=/WEB2PY_ADMIN_PASSWORD=$REVIEW_SERVER_ADMIN_PASSWORD/" docker-compose.yml
424
    - cd ..
425
    - rsync -av --exclude .git . $REVIEW_SERVER:$REVIEW_SERVER_PATH_SERVER$CI_BUILD_REF_SLUG || $(case "$?" in 0|23) exit 0 ;; *) exit $?; esac)
426
    - ssh $REVIEW_SERVER "cd $REVIEW_SERVER_PATH_SERVER; ./install_certs.sh ${CI_BUILD_REF_SLUG}; cd ${CI_BUILD_REF_SLUG}/docker_${CI_BUILD_REF_SLUG}; mkdir -p postfix/ssl; docker-compose up -d mysql fuse uwsgi nginx workers"
427 428
  environment:
    name: review_server/$CI_BUILD_REF_NAME
429
    url: http://$CI_BUILD_REF_SLUG.server.ci.vidjil.org/browser/
430
    on_stop: stop_deploy_review_server
431
    auto_stop_in: 2 months
432 433 434 435
  only:
    - /^feature-.*s.*\/.*$/
    - /^hotfix-.*s.*\/.*$/

436
deploy_docker:
437
  stage: deploy_prod
438
  script:
439
    - export CUR_DATE=`date +%Y-%m-%d`
440
    - export TYPE=`echo $CI_COMMIT_REF_NAME | awk '{ gsub(/prod-/, "") }{ print $1 }'`
441 442
    - export SHA=`echo $CI_COMMIT_SHA | awk '{ print substr($0, 0, 8) }'`
    - export TAG="vidjil/$TYPE:$CUR_DATE-$SHA"
443
    - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
444
    - docker build --no-cache --build-arg git_branch=$CI_COMMIT_REF_NAME --build-arg build_env=PRODUCTION -t $TAG docker/vidjil-$TYPE
445 446 447 448
    - docker push $TAG
    - docker tag $TAG "vidjil/$TYPE:latest"
    - docker push "vidjil/$TYPE:latest"
    - docker rmi $TAG "vidjil/$TYPE:latest"
449 450 451
  when: manual
  only:
    - prod-server
452
    - prod-client
453 454
  tags:
    - web
455
    - docker
456

457
deploy_prod:
458
  stage: deploy_prod
459
  script:
460
    - ssh $PROD_CLIENT_SERVER "
461
         cd $PROD_CLIENT_PATH;"
462 463
  environment:
    name: production
464
    url: http://$PROD_CLIENT_SERVER/?data=analysis-example.vidjil
465 466
  only:
    - prod-client
467 468
  tags:
    - web
469

470 471 472 473 474
deploy_germlines:
  stage: deploy_prod
  script:
    - make -C germline get-all-data
    - make -C germline js
475
    - date=$(date +%Y-%m-%d)
476 477 478 479 480 481 482 483
    - tar cvzf germline-$date.tar.gz germline/*/*.fa germline/IMGT_RELEASE browser/js/germline.js
    - scp germline-$date.tar.gz $VIDJIL_WWW:$REMOTE_GERMLINE_DIR
  only:
    - manual
    - /^feature-.*g.*\/.*$/
    


484 485
stop_deploy_review:
  stage: deploy_review
486 487 488
  variables:
    GIT_STRATEGY: none
  script:
489
    - ssh $REVIEW_SERVER "rm -rf $REVIEW_SERVER_PATH$CI_BUILD_REF_SLUG"
490 491
  when: manual
  environment:
492
    name: review/$CI_BUILD_REF_NAME
493
    action: stop
494
  only:
495 496
    - /^feature-.*c.*\/.*$/
    - /^hotfix-.*c.*\/.*$/
497
  tags:
498
    - web
499 500 501 502

stop_deploy_review_server:
  stage: deploy_review
  script:
503
    - ssh $REVIEW_SERVER "set -o xtrace; docker-compose -f $REVIEW_SERVER_PATH_SERVER$CI_BUILD_REF_SLUG/docker_$CI_BUILD_REF_SLUG/docker-compose.yml down -v ; rm -rf $REVIEW_SERVER_PATH_SERVER$CI_BUILD_REF_SLUG; $REVIEW_SERVER_PATH_SERVER/uninstall_certs.sh $CI_BUILD_REF_SLUG"
504 505 506 507 508 509 510
  when: manual
  environment:
    name: review_server/$CI_BUILD_REF_NAME
    action: stop
  only:
    - /^feature-.*s.*\/.*$/
    - /^hotfix-.*s.*\/.*$/