.gitlab-ci.yml 7.66 KB
Newer Older
1
image: gitlab.kwant-project.org:5005/kwant/kwant
2
3

stages:
4
  - build-env
5
6
7
  - build
  - test
  - deploy
8
  - release
9

10
11
12
variables:
  # rsync is used to send documentation to our web servers: we never send any
  # secret information, and using 'ssh-keyscan' causes the CI server's IP to be blacklisted
Christoph Groth's avatar
Christoph Groth committed
13
  SSH_COMMAND: "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
14

15
16
17
18
19
## Building Docker environments
## Only runs when docker specifications change

.build-env: &build-env
  stage: build-env
20
  when: manual
21
  image:
Viacheslav Ostroukh's avatar
Viacheslav Ostroukh committed
22
    name: gcr.io/kaniko-project/executor:debug
23
24
    entrypoint: [""]
  before_script:
25
26
    - mkdir -p /kaniko/.docker
    - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61

build-env:ubuntu:
  <<: *build-env
  script:
    - /kaniko/executor
      --context $CI_PROJECT_DIR/docker
      --dockerfile $CI_PROJECT_DIR/docker/Dockerfile.ubuntu
      --destination $CI_REGISTRY_IMAGE/ubuntu

build-env:debian:
  <<: *build-env
  script:
    - /kaniko/executor
      --context $CI_PROJECT_DIR/docker
      --dockerfile $CI_PROJECT_DIR/docker/Dockerfile.debian
      --destination $CI_REGISTRY_IMAGE/debian

build-env:conda:
  <<: *build-env
  script:
    - /kaniko/executor
      --context $CI_PROJECT_DIR/docker
      --dockerfile $CI_PROJECT_DIR/docker/Dockerfile.conda
      --destination $CI_REGISTRY_IMAGE/conda

build-env:default:
  <<: *build-env
  script:
    - /kaniko/executor
      --context $CI_PROJECT_DIR/docker
      --dockerfile $CI_PROJECT_DIR/docker/Dockerfile.conda
      --destination $CI_REGISTRY_IMAGE


## Build environment specifications
62

63
.build: &build
64
65
  stage: build
  script:
66
67
68
    - echo -e "[DEFAULT]\ndefine_macros = CYTHON_TRACE=1" >build.conf
    - ./setup.py build
    - ./setup.py build_ext -i
69
70
  artifacts:
    untracked: true
Joseph Weston's avatar
Joseph Weston committed
71
    expire_in: 2 hour
72

73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96

.stable-env: &stable_env
  before_script:
    - source deactivate
    - source activate kwant-stable

.no-extras-env: &no_extras_env
  before_script:
    - source deactivate
    - source activate kwant-stable-no-extras

# Note that this is 'latest' as of when the image was last built
.latest-env: &latest_env
  before_script:
    - source deactivate
    - source activate kwant-latest

.bleeding-edge-env: &bleeding_edge_env
  before_script:
    - source deactivate
    - conda env update -f /kwant-latest.yml
    - source activate kwant-latest

.ubuntu-env: &ubuntu_env
97
  image: gitlab.kwant-project.org:5005/kwant/kwant/ubuntu
98
99

.debian-env: &debian_env
100
  image: gitlab.kwant-project.org:5005/kwant/kwant/debian
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128

## Build Jobs

build:ubuntu:
  <<: *build
  <<: *ubuntu_env

build:debian:
  <<: *build
  <<: *debian_env

build:stable:
  <<: *build
  <<: *stable_env

build:no-extras:
  <<: *build
  <<: *no_extras_env

build:latest:
  <<: *build
  <<: *latest_env

build:bleeding-edge:
  <<: *build
  <<: *bleeding_edge_env
  only:
    - schedules
129
  allow_failure: true
130
131
132

## Test Jobs

133
check whitespace style:
134
  stage: test
135
  script: ./check_whitespace
136
137
138
139
140
141
142
143
  allow_failure: true

check for dependencies installed:
  stage: test
  script:
    - if [ -d .eggs ]; then echo "$(ls -d .eggs/*/) downloaded by build, update build environment" >&2; fi
  allow_failure: true

144

145
146
147
.test: &test
  stage: test
  script:
148
    - py.test -r w --flakes kwant --junitxml=tests.xml --durations=10
149
  artifacts:
Joseph Weston's avatar
Joseph Weston committed
150
151
    reports:
      junit: tests.xml
152

153
154
155
156
157
158
159
160
161
162
.coverage: &coverage
  stage: test
  script:
    - py.test -r w --cov=kwant --cov-report term --cov-report html --flakes kwant --junitxml=tests.xml --durations=10
  artifacts:
    paths:
      - htmlcov
    reports:
      junit: tests.xml

163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200

test:stable:
  <<: *test
  <<: *stable_env
  dependencies:
    - build:stable

test:no-extras:
  <<: *test
  <<: *no_extras_env
  dependencies:
    - build:no-extras

test:ubuntu:
  <<: *test
  <<: *ubuntu_env
  dependencies:
    - build:ubuntu

test:debian:
  <<: *test
  <<: *debian_env
  dependencies:
    - build:debian

test:latest:
  <<: *test
  <<: *latest_env
  dependencies:
    - build:latest

test:bleeding-edge:
  <<: *test
  <<: *bleeding_edge_env
  dependencies:
    - build:bleeding-edge
  only:
    - schedules
201
  allow_failure: true
202

Joseph Weston's avatar
Joseph Weston committed
203
204
205
coverage:latest:
  <<: *coverage
  <<: *latest_env
206
207
208
209
210
  dependencies:
    - build:latest
  only:
    - schedules

211
212
## Documentation building

213
build documentation:
214
215
216
  <<: *latest_env
  dependencies:
    - build:latest
217
218
  stage: test
  script:
219
    - python -c 'from matplotlib import pyplot'  # Pre-generate font cache
220
    - make -C doc clean; make -C doc html SPHINXOPTS='-A website_deploy=True -n -D jupyter_execute_default_kernel=kwant-latest' SOURCE_LINK_TEMPLATE="$CI_PROJECT_URL"/blob/\$\$r/\$\$f
221
222
223
224
225
  artifacts:
    paths:
      - doc/build/html/
    expire_in: 1 month

226
build PDF documentation:
227
228
229
  <<: *latest_env
  dependencies:
    - build:latest
230
231
  stage: test
  script:
232
    - python -c 'from matplotlib import pyplot'  # Pre-generate font cache
233
    - make -C doc latex SPHINXOPTS='-n -D jupyter_execute_default_kernel=kwant-latest'
234
235
236
237
238
239
    - cd doc/build/latex
    - make all-pdf
  artifacts:
    paths:
      - doc/build/latex/kwant.pdf
    expire_in: 1 month
240

241
check for broken links in doc:
242
243
244
  <<: *latest_env
  dependencies:
    - build:latest
245
246
247
248
249
  stage: test
  script:
    - make -C doc linkcheck
  allow_failure: true

250

251
252
253
254
255
256
257
258
259
260
261
262
## Upload coverage reports and dev documentation

upload coverage:
  stage: deploy
  only:
    - schedules
  dependencies:
    - coverage:latest
  environment:
    name: coverage/$CI_BUILD_REF_NAME
    url: https://kwant-project.org/coverage/$CI_BUILD_REF_SLUG
    on_stop: remove_coverage
263
  script:
264
265
    - eval $(ssh-agent -s)
    - echo $MASTER_WEBSITE_KEY | base64 -d | ssh-add -
266
    - mv htmlcov $CI_BUILD_REF_SLUG
Christoph Groth's avatar
Christoph Groth committed
267
    - rsync -rlv -e "$SSH_COMMAND" --delete --relative $CI_BUILD_REF_SLUG kwant@kwant-project.org:coverage/
268
269
270
271
272
273
274
275
276
277


remove_coverage:
  stage: deploy
  only:
    - branches@kwant/kwant
  when: manual
  environment:
    name: coverage/$CI_BUILD_REF_NAME
    action: stop
278
  script:
279
280
    - eval $(ssh-agent -s)
    - echo $MASTER_WEBSITE_KEY | base64 -d | ssh-add -
281
    - mkdir empty/
Christoph Groth's avatar
Christoph Groth committed
282
    - rsync -rlv -e "$SSH_COMMAND" --delete empty/ kwant@kwant-project.org:coverage/$CI_BUILD_REF_SLUG
Anton Akhmerov's avatar
Anton Akhmerov committed
283
284


285
286
upload documentation to the test server:
  stage: deploy
287
288
289
290
  environment:
    name: docs review/$CI_BUILD_REF_NAME
    url: https://test.kwant-project.org/doc/$CI_BUILD_REF_SLUG
    on_stop: remove_docs
291
292
  only:
    - branches@kwant/kwant
293
  script:
294
295
    - eval $(ssh-agent -s)
    - echo $TEST_WEBSITE_KEY | base64 -d | ssh-add -
Christoph Groth's avatar
Christoph Groth committed
296
    - rsync -rlv -e "$SSH_COMMAND" --delete doc/build/html/* kwant2@test.kwant-project.org:doc/$CI_BUILD_REF_SLUG
297
298
299
300
301


remove_docs:
  stage: deploy
  when: manual
Anton Akhmerov's avatar
Anton Akhmerov committed
302
303
  only:
    - branches@kwant/kwant
304
305
306
  environment:
    name: docs review/$CI_BUILD_REF_NAME
    action: stop
307
  script:
308
309
    - eval $(ssh-agent -s)
    - echo $TEST_WEBSITE_KEY | base64 -d | ssh-add -
310
    - mkdir empty
Christoph Groth's avatar
Christoph Groth committed
311
    - rsync -arv -e "$SSH_COMMAND" --delete empty/ kwant2@test.kwant-project.org:doc/$CI_BUILD_REF_SLUG/
312

313

314
315
upload dev version docs:
  stage: deploy
316
317
318
  environment:
    name: production
    url: https://kwant-project.org/doc/dev
319
320
  only:
    - master@kwant/kwant
321
  script:
322
323
    - eval $(ssh-agent -s)
    - echo $MASTER_WEBSITE_KEY | base64 -d | ssh-add -
Christoph Groth's avatar
Christoph Groth committed
324
    - rsync -rlv -e "$SSH_COMMAND" --delete doc/build/html/* kwant@kwant-project.org:doc/dev
325

326
327

## Build documentation for tagged releases
328

329
330
331
332
333
334
335
.tagged-version: &tagged_version
    only:
       - /^v[0-9]+\.[0-9]+.[0-9]+$/@kwant/kwant

gather release artifacts:
  <<: *tagged_version
  stage: release
336
  script:
337
338
339
340
341
342
343
344
345
    - ./setup.py sdist
    - mkdir docs
    - mv doc/build/latex/kwant.pdf docs/kwant-doc-${CI_COMMIT_TAG//v}.pdf
    - mv doc/build/html docs/html
    - zip -r docs/kwant-doc-${CI_COMMIT_TAG//v}.zip docs/html
  artifacts:
    paths:
      - docs
      - dist