.gitlab-ci.yml 8.26 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_shouldvdj
17 18
  - test_functional
  - test_functional_external
19
  - coverage
20
  - prepare_release
21
  - release
22 23
  - valgrind_unit
  - valgrind_functional
24
  - multiple_tests
25
  - prepare_deploy
26
  - deploy_docker
27
  - deploy_prod
28

29 30 31 32 33 34 35
# Anchors

.coverage_dependency: &lcov_artifact
  artifacts:
    paths:
      - algo/lcov_test_*.filtered
    expire_in: 6hrs
36

37 38 39 40 41 42
# Tools

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

43 44 45 46 47 48 49

# Germlines

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


56
# Algorithm
57 58 59

test_algo_unit:
  stage: test_unit
60 61
  script: make -C algo unit_coverage
  <<: *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
  only:
70
    - /^feature-.*a.*\/.*$/
71
    - schedules
72
  <<: *lcov_artifact
73 74 75

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

95 96
algo_valgrind_unit:
  stage: valgrind_unit
97
  script: make -C algo valgrind_unit
98
  only:
99
    - /^feature-.*a.*\/.*$/
100
    - schedules
101 102
  tags:
    - valgrind
103

104
.snip_valgrind_functional: &valgrind_functional
105
  stage: valgrind_functional
106
  script: make -C algo valgrind_should
107 108 109 110 111
  tags:
    - valgrind

algo_valgrind_functional:
  <<: *valgrind_functional
112 113
  when: manual
  only:
114
    - /^feature-.*a.*\/.*$/
115
    - schedules
116 117 118 119 120

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

122 123 124 125 126
prepare_release:
  stage: prepare_release
  script: make -C algo release RELEASE_TAG='rc'
  when: manual
  only:
127
    - /^feature-.*a.*\/.*$/
128

129 130 131 132 133
release:
  stage: release
  script: make -C algo release RELEASE_TAG=`cat algo/release`
  when: manual
  only:
134
    - /^feature-.*a.*\/release$/
135
  artifacts:
136
    paths:
137 138
    - algo/releases/vidjil-algo-`cat algo/release`.tar.gz
    - algo/releases/vidjil-algo-`cat algo/release`/vidjil-algo-`cat algo/release`_`uname -m`
139
  allow_failure: false
140 141
  tags:
    - ubuntu-16.04-amd64
142

143 144 145 146 147 148 149 150 151 152
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"
153
      ssh $VIDJIL_BONSAI "cd /bio1/www/html/vidjil; scp vidjil-algo-${release_name}* $VIDJIL_BONSAI_PROD:/bio1/www/html/vidjil"
154 155 156
  only:
    - /^feature-.*a.*\/release$/

157 158 159 160 161 162 163
deploy_release_prod:
  stage: deploy_prod
  only:
    - /^feature-.*a.*\/release$/
  script:
    - |
      release_name=$(cat algo/release)
164
      ssh $DEPLOY_SERVER "cd releases/vidjil;\
165
          tar xvzf vidjil-algo-${release_name}.tar.gz;\
166 167
          make -C vidjil-algo-${release_name};\
          ln -sfT vidjil-algo-${release_name} next"
168

169 170
.testing-compilers: &test_various_compilers
  stage: multiple_tests
171 172 173 174 175 176 177 178 179 180 181 182
  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

183 184 185 186 187
test_various_compilers_manual:
  <<: *test_various_compilers
  when: manual
  only:
    - /^feature-.*a.*\/.*$/
188
    - schedules
189 190 191 192 193 194

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

195

196
# Client
197

198
test_browser_unit:
199
  stage: test_unit
200
  script: make unit_browser
201 202 203
  artifacts:
    paths:
    - browser/
204
  only:
205 206
    - /^feature-.*c.*\/.*$/
    - /^hotfix-.*c.*\/.*$/
207
    - prod-client
208
    - dev
209
    - schedules
210 211
  tags:
    - web
212

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

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

251 252
code_quality:
  stage: test_quality
253
  script: make -C browser quality
254
  only:
255 256
    - /^feature-.*c.*\/.*$/
    - /^hotfix-.*c.*\/.*$/
257
    - prod-client
258
    - dev
259
    - schedules
260 261
  tags:
    - web
262

263 264 265 266 267
# Server

test_server_unit:
    stage: test_unit
    script:
268 269
      - virtualenv $CI_BUILD_REF_SLUG
      - source $CI_BUILD_REF_SLUG/bin/activate
270
      - pip install -r requirements.txt
271
      - make -C server install_web2py_standalone
272
      - make -C server launch_fuse_server
273
      - make unit_server || (make -C server kill_fuse_server; deactivate; false)
274
      - make -C server kill_fuse_server
275
      - deactivate
276
    only:
277 278
      - /^feature-.*s.*\/.*$/
      - /^hotfix-.*s.*\/.*$/
279 280
      - prod-server
      - dev
281
      - schedules
282 283 284
    tags:
      - web

285 286 287
test_server_functional:
  stage: test_functional
  script:
288 289
    - 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
290
    - cd docker && docker-compose up -d && cd ..
291
    - 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
292
    - 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
293
    - docker exec docker_nginx_1 make -C /usr/share/vidjil browser
294 295
    - source /etc/profile.d/rvm.sh
    - rvm use 2.1.1
296
    - HEADLESS=1 make functional_server || (cd docker && docker-compose stop; false)
297
    - cd docker && docker-compose stop
298 299 300 301 302
  only:
    - /^feature-.*s.*\/.*$/
    - /^hotfix-.*s.*\/.*$/
    - prod-server
    - dev
303
    - schedules
304
  tags:
305
    - x86_64
306
    - docker
307

308 309
# Deployment

310 311
deploy_review:
  stage: deploy_review
312
  script:
313
    - make -C browser icons
314
    - echo "$REVIEW_CONFIG_JS" > browser/js/conf.js
315
    - rsync -av --delete browser $DEPLOY_SERVER:$DEPLOY_SERVER_PATH$CI_BUILD_REF_SLUG
316
  environment:
317
    name: review/$CI_BUILD_REF_NAME
318
    url: http://$CI_BUILD_REF_SLUG.ci.vidjil.org/?data=analysis-example.vidjil
Mathieu Giraud's avatar
Mathieu Giraud committed
319
    on_stop: stop_deploy_review
320
  only:
321 322
    - /^feature-.*c.*\/.*$/
    - /^hotfix-.*c.*\/.*$/
323 324
  tags:
    - web
325

326 327 328 329 330 331 332 333 334 335
deploy_docker:
  stage: deploy_docker
  script:
    - docker tag $CI_BUILD_REF_SLUG vidjil/vidjil:latest
    - docker push vidjil/vidjil:latest
  when: manual
  only:
    - prod-server
  tags:
    - web
336
    - docker
337

338
deploy_prod:
339
  stage: deploy_prod
340
  script:
341 342 343 344 345 346 347
    - 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/"
348 349
  environment:
    name: production
350
    url: http://$PROD_CLIENT_SERVER/?data=analysis-example.vidjil
351 352
  only:
    - prod-client
353 354
  tags:
    - web
355

356 357
stop_deploy_review:
  stage: deploy_review
358 359 360 361 362 363
  variables:
    GIT_STRATEGY: none
  script:
    - ssh $DEPLOY_SERVER "rm -rf $DEPLOY_SERVER_PATH$CI_BUILD_REF_SLUG"
  when: manual
  environment:
364
    name: review/$CI_BUILD_REF_NAME
365
    action: stop
366
  only:
367 368
    - /^feature-.*c.*\/.*$/
    - /^hotfix-.*c.*\/.*$/
369
  tags:
370
    - web