.gitlab-ci.yml 7.21 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_functional_external
18
  - test_shouldvdj
19
  - coverage
20
  - prepare_release
21
  - release
22 23
  - valgrind_unit
  - valgrind_functional
24
  - prepare_deploy
25
  - deploy_docker
26
  - deploy_prod
27

28 29 30 31 32 33 34
# Anchors

.coverage_dependency: &lcov_artifact
  artifacts:
    paths:
      - algo/lcov_test_*.filtered
    expire_in: 6hrs
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
Mathieu Giraud's avatar
Mathieu Giraud committed
49
    - make -C germline/tests
50
  only:
51
    - /^feature-.*g.*\/.*$/
52 53


54
# Algorithm
55 56 57

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

test_tools_unit:
  stage: test_unit
  script: make -C tools/tests
  only:
67
    - /^feature-.*a.*\/.*$/
68 69 70

test_algo_should:
  stage: test_functional
71
  script: make -C algo should_coverage
72
  only:
73
    - /^feature-.*a.*\/.*$/
74
  <<: *lcov_artifact
75 76 77

test_algo_shouldvdj:
  stage: test_shouldvdj
78 79
  script: make -C algo shouldvdj_coverage
  <<: *lcov_artifact
80 81 82 83 84
  only:
    - /^feature-.*a.*\/.*$/

algo_coverage:
  stage: coverage
85
  coverage: /^\s*lines\.*:\s+([0-9.]+\%)/
86 87 88
  script:
    - make -C algo lcov_reports
    - mv algo/reports/ coverage
89 90
  artifacts:
    paths:
91
      - coverage/
92
  only:
93
    - /^feature-.*a.*\/.*$/
94

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

algo_valgrind_functional:
  stage: valgrind_functional
105
  script: make -C algo valgrind_should
106 107
  when: manual
  only:
108
    - /^feature-.*a.*\/.*$/
109 110
  tags:
    - valgrind
111

112 113 114 115 116
prepare_release:
  stage: prepare_release
  script: make -C algo release RELEASE_TAG='rc'
  when: manual
  only:
117
    - /^feature-.*a.*\/.*$/
118

119 120 121 122 123
release:
  stage: release
  script: make -C algo release RELEASE_TAG=`cat algo/release`
  when: manual
  only:
124
    - /^feature-.*a.*\/release$/
125
  artifacts:
126
    paths:
127 128
    - algo/releases/vidjil-algo-`cat algo/release`.tar.gz
    - algo/releases/vidjil-algo-`cat algo/release`/vidjil-algo-`cat algo/release`_`uname -m`
129
  allow_failure: false
130 131
  tags:
    - ubuntu-16.04-amd64
132

133 134 135 136 137 138 139 140 141 142 143 144 145 146
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"
      ssh $VIDJIL_BONSAI "cd /bio1/www/html/vidjil; scp vidjil-algo-${release_name}* VIDJIL_BONSAI_PROD:/bio1/www/html/vidjil"
  only:
    - /^feature-.*a.*\/release$/

147 148 149 150 151 152 153 154 155 156 157 158
deploy_release_prod:
  stage: deploy_prod
  only:
    - /^feature-.*a.*\/release$/
  script:
    - |
      release_name=$(cat algo/release)
      ssh $VIDJIL_SERVER "cd releases/vidjil;\
          tar xvzf vidjil-algo-${release_name}.tar.gz;\
          make -C vidjil-algo-${release_name}
          ln -sf vidjil-algo-${release_name} next"

159
# Client
160

161
test_browser_unit:
162
  stage: test_unit
163
  script: make unit_browser
164 165 166
  artifacts:
    paths:
    - browser/
167
  only:
168 169
    - /^feature-.*c.*\/.*$/
    - /^hotfix-.*c.*\/.*$/
170
    - prod-client
171
    - dev
172 173
  tags:
    - web
174

175 176
test_browser-functional:
  stage: test_functional
177 178 179 180
  script:
    - make -C browser
    - source /etc/profile.d/rvm.sh
    - rvm use 2.1.1
181 182 183 184 185
    - HEADLESS=1 make -C browser/test functional
  artifacts:
    paths:
    - browser/
  only:
186 187
    - /^feature-.*c.*\/.*$/
    - /^hotfix-.*c.*\/.*$/
188
    - prod-client
189 190
  tags:
    - web
191 192 193

test_browser-functional-external:
  stage: test_functional_external
194
  retry: 2
195 196 197 198 199
  script:
    - make -C browser
    - source /etc/profile.d/rvm.sh
    - rvm use 2.1.1
    - HEADLESS=1 make -C browser/test external
200 201 202
  artifacts:
    paths:
    - browser/
203
  only:
204 205
    - /^feature-.*c.*\/.*$/
    - /^hotfix-.*c.*\/.*$/
206
    - prod-client
207 208
  tags:
    - web
209

210 211
code_quality:
  stage: test_quality
212
  script: make -C browser quality
213
  only:
214 215
    - /^feature-.*c.*\/.*$/
    - /^hotfix-.*c.*\/.*$/
216
    - prod-client
217
    - dev
218 219
  tags:
    - web
220

221 222 223 224 225
# Server

test_server_unit:
    stage: test_unit
    script:
226 227
      - virtualenv $CI_BUILD_REF_SLUG
      - source $CI_BUILD_REF_SLUG/bin/activate
228
      - pip install -r requirements.txt
229
      - make -C server install_web2py_standalone
230
      - make -C server launch_fuse_server
231
      - make unit_server || (make -C server kill_fuse_server; deactivate; false)
232
      - make -C server kill_fuse_server
233
      - deactivate
234
    only:
235 236
      - /^feature-.*s.*\/.*$/
      - /^hotfix-.*s.*\/.*$/
237 238 239 240 241
      - prod-server
      - dev
    tags:
      - web

242 243 244
test_server_functional:
  stage: test_functional
  script:
245 246
    - 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
247
    - cd docker && docker-compose up -d && cd ..
248
    - docker exec docker_nginx_1 make -C /usr/share/vidjil browser
249
    - docker exec docker_uwsgi_1 python /usr/share/vidjil/server/web2py/web2py.py -S vidjil -M -R /usr/share/vidjil/server/web2py/applications/vidjil/tests/functional/init_test_db.py
250 251
    - source /etc/profile.d/rvm.sh
    - rvm use 2.1.1
252
    - HEADLESS=1 make functional_server || (cd docker && docker-compose stop; false)
253
    - cd docker && docker-compose stop
254 255 256 257 258 259
  only:
    - /^feature-.*s.*\/.*$/
    - /^hotfix-.*s.*\/.*$/
    - prod-server
    - dev
  tags:
260
    - x86_64
261
    - docker
262

263 264
# Deployment

265 266
deploy_review:
  stage: deploy_review
267
  script:
268
    - make -C browser icons
269
    - echo "$REVIEW_CONFIG_JS" > browser/js/conf.js
270
    - rsync -av --delete browser $DEPLOY_SERVER:$DEPLOY_SERVER_PATH$CI_BUILD_REF_SLUG
271
  environment:
272
    name: review/$CI_BUILD_REF_NAME
273
    url: http://$CI_BUILD_REF_SLUG.ci.vidjil.org/?data=analysis-example.vidjil
Mathieu Giraud's avatar
Mathieu Giraud committed
274
    on_stop: stop_deploy_review
275
  only:
276 277
    - /^feature-.*c.*\/.*$/
    - /^hotfix-.*c.*\/.*$/
278 279
  tags:
    - web
280

281 282 283 284 285 286 287 288 289 290
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
291
    - docker
292

293
deploy_prod:
294
  stage: deploy_prod
295
  script:
296 297 298 299 300 301 302
    - 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/"
303 304
  environment:
    name: production
305
    url: http://$PROD_CLIENT_SERVER/?data=analysis-example.vidjil
306 307
  only:
    - prod-client
308 309
  tags:
    - web
310

311 312
stop_deploy_review:
  stage: deploy_review
313 314 315 316 317 318
  variables:
    GIT_STRATEGY: none
  script:
    - ssh $DEPLOY_SERVER "rm -rf $DEPLOY_SERVER_PATH$CI_BUILD_REF_SLUG"
  when: manual
  environment:
319
    name: review/$CI_BUILD_REF_NAME
320
    action: stop
321
  only:
322 323
    - /^feature-.*c.*\/.*$/
    - /^hotfix-.*c.*\/.*$/
324
  tags:
325
    - web