.gitlab-ci.yml 9.65 KB
Newer Older
1 2 3


before_script:
4
  - make demo
5 6
  - make data
  - make germline
7
  - make -C browser sha1
8
  - cp -p doc/analysis-example.vidjil browser/
9 10

stages:
11
  - test_tools
12
  - test_quality
13
  - test_unit
14
  - deploy_review
15
  - test_germlines
16
  - test_functional
17
  - test_shouldvdj
18
  - test_functional_external
19
  - coverage
20
  - prepare_release
21
  - release
22 23
  - valgrind_unit
  - valgrind_functional
24
  - multiple_tests
25
  - prepare_deploy
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
# Algorithm
56 57 58

test_algo_unit:
  stage: test_unit
59
  script: make -C algo unit_coverage
60 61
  artifacts:
    <<: *lcov_artifact
62
  only:
63
    - /^feature-.*a.*\/.*$/
64
    - schedules
65

66 67
test_algo_should:
  stage: test_functional
68
  script: make -C algo should_coverage
69
  artifacts:
70
    <<: *lcov_artifact
71 72
    reports:
      junit: algo/tests/should.xml
73
  only:
74
    - /^feature-.*a.*\/.*$/
75
    - schedules
76 77 78

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

100 101
algo_valgrind_unit:
  stage: valgrind_unit
102
  script: make -C algo valgrind_unit
103
  only:
104
    - /^feature-.*a.*\/.*$/
105
    - schedules
106 107
  tags:
    - valgrind
108

109
.snip_valgrind_functional: &valgrind_functional
110
  stage: valgrind_functional
111
  script: make -C algo valgrind_should
112 113 114 115 116
  tags:
    - valgrind

algo_valgrind_functional:
  <<: *valgrind_functional
117 118
  when: manual
  only:
119
    - /^feature-.*a.*\/.*$/
120
    - schedules
121 122 123 124 125

release_valgrind_functional:
  <<: *valgrind_functional
  only:
    - /^feature-.*a.*\/release$/
126

127 128 129 130 131
prepare_release:
  stage: prepare_release
  script: make -C algo release RELEASE_TAG='rc'
  when: manual
  only:
132
    - /^feature-.*a.*\/.*$/
133

134 135 136 137 138
release:
  stage: release
  script: make -C algo release RELEASE_TAG=`cat algo/release`
  when: manual
  only:
139
    - /^feature-.*a.*\/release$/
140
  artifacts:
141
    paths:
142 143
    - algo/releases/vidjil-algo-`cat algo/release`.tar.gz
    - algo/releases/vidjil-algo-`cat algo/release`/vidjil-algo-`cat algo/release`_`uname -m`
144
    expire_in: 10 years
145
  allow_failure: false
146 147
  tags:
    - ubuntu-16.04-amd64
148

149 150 151 152 153 154 155 156 157 158
copy_release:
  stage: prepare_deploy
  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"
159
      ssh $VIDJIL_BONSAI "cd /bio1/www/html/vidjil; scp vidjil-algo-${release_name}* $VIDJIL_BONSAI_PROD:/bio1/www/html/vidjil"
160 161 162
  only:
    - /^feature-.*a.*\/release$/

163 164 165 166 167 168 169
deploy_release_prod:
  stage: deploy_prod
  only:
    - /^feature-.*a.*\/release$/
  script:
    - |
      release_name=$(cat algo/release)
170
      ssh $DEPLOY_SERVER "cd releases/vidjil;\
171
          tar xvzf vidjil-algo-${release_name}.tar.gz;\
172 173
          make -C vidjil-algo-${release_name};\
          ln -sfT vidjil-algo-${release_name} next"
174

175 176
.testing-compilers: &test_various_compilers
  stage: multiple_tests
177 178 179 180 181 182 183 184 185 186 187 188
  tags:
    - several-compilers
  script:
    - |
      for CXX in $COMPILERS; do
        echo "**** Using $CXX for compilation ****"
        make -C algo clean
        make -C algo CXX=$CXX unit
        make -C algo CXX=$CXX should
        make -C algo CXX=$CXX valgrind_unit
      done

189 190 191 192 193
test_various_compilers_manual:
  <<: *test_various_compilers
  when: manual
  only:
    - /^feature-.*a.*\/.*$/
194
    - schedules
195 196 197 198 199 200

test_various_compilers_release:
  <<: *test_various_compilers
  only:
    - /^feature-.*a.*\/release$/

201

202
# Client
203

204
test_browser_unit:
205
  stage: test_unit
206
  script: make unit_browser
207 208 209
  artifacts:
    paths:
    - browser/
210
  only:
211 212
    - /^feature-.*c.*\/.*$/
    - /^hotfix-.*c.*\/.*$/
213
    - prod-client
214
    - dev
215
    - schedules
216 217
  tags:
    - web
218

219 220
test_browser-functional:
  stage: test_functional
221
  retry: 2
222 223 224 225
  script:
    - make -C browser
    - source /etc/profile.d/rvm.sh
    - rvm use 2.1.1
226 227 228 229 230
    - HEADLESS=1 make -C browser/test functional
  artifacts:
    paths:
    - browser/
  only:
231 232
    - /^feature-.*c.*\/.*$/
    - /^hotfix-.*c.*\/.*$/
233
    - prod-client
234
    - schedules
235 236
  tags:
    - web
237 238 239

test_browser-functional-external:
  stage: test_functional_external
240
  retry: 2
241 242 243 244 245
  script:
    - make -C browser
    - source /etc/profile.d/rvm.sh
    - rvm use 2.1.1
    - HEADLESS=1 make -C browser/test external
246 247 248
  artifacts:
    paths:
    - browser/
249
  only:
250 251
    - /^feature-.*c.*\/.*$/
    - /^hotfix-.*c.*\/.*$/
252
    - prod-client
253
    - schedules
254 255
  tags:
    - web
256

257 258
code_quality:
  stage: test_quality
259
  script: make -C browser quality
260
  only:
261 262
    - /^feature-.*c.*\/.*$/
    - /^hotfix-.*c.*\/.*$/
263
    - prod-client
264
    - dev
265
    - schedules
266 267
  tags:
    - web
268

269 270 271 272 273
# Server

test_server_unit:
    stage: test_unit
    script:
274 275
      - virtualenv $CI_BUILD_REF_SLUG
      - source $CI_BUILD_REF_SLUG/bin/activate
276
      - pip install -r requirements.txt
277
      - make -C server install_web2py_standalone
278
      - make -C server launch_fuse_server
279
      - make unit_server || (make -C server kill_fuse_server; deactivate; false)
280
      - make -C server kill_fuse_server
281
      - deactivate
282 283 284
    artifacts:
      reports:
        junit: server/web2py/test-reports/TEST*xml
285
    only:
286 287
      - /^feature-.*s.*\/.*$/
      - /^hotfix-.*s.*\/.*$/
288 289
      - prod-server
      - dev
290
      - schedules
291 292 293
    tags:
      - web

294 295 296
test_server_functional:
  stage: test_functional
  script:
297 298
    - 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
299
    - sed -i '/\/etc\/nginx\/ssl\:\/etc\/nginx\/ssl/d' ./docker/docker-compose.yml
300
    - sed -i 's/\:latest/\:test/g' ./docker/docker-compose.yml
301 302
    - cd docker/vidjil-server/conf/ && mv defs.py defs_https.py && mv defs_http.py defs.py && cd ../../..
    - cd docker/vidjil-client/conf/ && mv conf.js conf_https.js && mv conf_http.js conf.js && cd ../../..
303
    - make germline && cp browser/js/germline.js docker/vidjil-client/conf
304
    - cd docker && docker-compose up -d && cd ..
305
    - sed -i "s/^python\ \.\.\/\.\.\/\.\./docker\ exec\ docker_uwsgi_1\ python\ \/usr\/share\/vidjil\/server\/web2py/" server/web2py/applications/vidjil/tests/init_func_test_db.sh
306
    - 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
307
    - docker exec docker_nginx_1 make -C /usr/share/vidjil browser
308 309
    - source /etc/profile.d/rvm.sh
    - rvm use 2.1.1
310
    - HEADLESS=1 make functional_server || (cd docker && docker-compose stop; docker stop $(docker ps -aq); docker rm $(docker ps -aq); docker rmi "vidjil/server:test" "vidjil/client:test"; false)
311
    - cd docker && docker-compose stop
312 313
    - docker stop $(docker ps -aq)
    - docker rm $(docker ps -aq)
314
    - docker rmi "vidjil/server:test" "vidjil/client:test" reporter:test
315 316 317 318 319
  only:
    - /^feature-.*s.*\/.*$/
    - /^hotfix-.*s.*\/.*$/
    - prod-server
    - dev
320
    - schedules
321
  tags:
322
    - x86_64
323
    - docker
324

325 326
# Deployment

327 328
deploy_review:
  stage: deploy_review
329
  script:
330
    - make -C browser icons
331
    - echo "$REVIEW_CONFIG_JS" > browser/js/conf.js
332
    - rsync -av --delete browser $DEPLOY_SERVER:$DEPLOY_SERVER_PATH$CI_BUILD_REF_SLUG
333
  environment:
334
    name: review/$CI_BUILD_REF_NAME
335
    url: http://$CI_BUILD_REF_SLUG.ci.vidjil.org/?data=analysis-example.vidjil
Mathieu Giraud's avatar
Mathieu Giraud committed
336
    on_stop: stop_deploy_review
337
  only:
338 339
    - /^feature-.*c.*\/.*$/
    - /^hotfix-.*c.*\/.*$/
340 341
  tags:
    - web
342

343
deploy_docker:
344
  stage: deploy_prod
345
  script:
346
    - export CUR_DATE=`date +%Y-%m-%d`
347
    - export TYPE=`echo $CI_COMMIT_REF_NAME | awk '{ gsub(/prod-/, "") }{ print $1 }'`
348 349
    - export SHA=`echo $CI_COMMIT_SHA | awk '{ print substr($0, 0, 8) }'`
    - export TAG="vidjil/$TYPE:$CUR_DATE-$SHA"
350
    - docker build --no-cache --build-arg git_branch=$CI_COMMIT_REF_NAME --build-arg build_env=PRODUCTION -t $TAG docker/vidjil-$TYPE
351 352 353 354 355
    - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
    - docker push $TAG
    - docker tag $TAG "vidjil/$TYPE:latest"
    - docker push "vidjil/$TYPE:latest"
    - docker rmi $TAG "vidjil/$TYPE:latest"
356 357 358
  when: manual
  only:
    - prod-server
359
    - prod-client
360 361
  tags:
    - web
362
    - docker
363

364
deploy_prod:
365
  stage: deploy_prod
366
  script:
367 368 369 370 371 372 373
    - ssh $PROD_CLIENT_SERVER "
         cd $PROD_CLIENT_PATH;
         git fetch
         && git reset --hard origin/prod-client
         && make -C browser
         && make -C browser sha1
         && cp doc/analysis-example.vidjil browser/"
374 375
  environment:
    name: production
376
    url: http://$PROD_CLIENT_SERVER/?data=analysis-example.vidjil
377 378
  only:
    - prod-client
379 380
  tags:
    - web
381

382 383
stop_deploy_review:
  stage: deploy_review
384 385 386 387 388 389
  variables:
    GIT_STRATEGY: none
  script:
    - ssh $DEPLOY_SERVER "rm -rf $DEPLOY_SERVER_PATH$CI_BUILD_REF_SLUG"
  when: manual
  environment:
390
    name: review/$CI_BUILD_REF_NAME
391
    action: stop
392
  only:
393 394
    - /^feature-.*c.*\/.*$/
    - /^hotfix-.*c.*\/.*$/
395
  tags:
396
    - web