.gitlab-ci.yml 9.68 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
  - tgz_release
22 23
  - valgrind_unit
  - valgrind_functional
24
  - multiple_tests
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
# 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
tgz_release:
  stage: tgz_release
136 137
  script: make -C algo release RELEASE_TAG=`cat algo/release`
  only:
138
    - /^feature-.*a.*\/release$/
139
  artifacts:
140
    paths:
141 142
    - algo/releases/vidjil-algo-`cat algo/release`.tar.gz
    - algo/releases/vidjil-algo-`cat algo/release`/vidjil-algo-`cat algo/release`_`uname -m`
143
    expire_in: 10 years
144
  allow_failure: false
145 146
  tags:
    - ubuntu-16.04-amd64
147

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

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

176 177
.testing-compilers: &test_various_compilers
  stage: multiple_tests
178 179 180 181 182 183 184 185 186 187 188 189
  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

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

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

202

203
# Client
204

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

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

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

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

270 271 272 273 274
# Server

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

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

326 327
# Deployment

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

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

365
deploy_prod:
366
  stage: deploy_prod
367
  script:
368 369 370 371 372 373 374
    - 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/"
375 376
  environment:
    name: production
377
    url: http://$PROD_CLIENT_SERVER/?data=analysis-example.vidjil
378 379
  only:
    - prod-client
380 381
  tags:
    - web
382

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