.gitlab-ci.yml 8.62 KB
Newer Older
1
2
default:
  image: python:latest
3

4
5
6
7
8
# avoid running duplicate pipelines for both topic head and MR
# see: https://docs.gitlab.com/ee/ci/yaml/#switch-between-branch-pipelines-and-merge-request-pipelines
workflow:
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
9
    - if: '$CI_COMMIT_REF_NAME =~ /^topic\/.*/  && $CI_OPEN_MERGE_REQUESTS'
10
11
12
      when: never
    - when: always

13
14
15
stages:
  - lint
  - tests
16
  - after-tests
17
  - qa
18
  - deploy
19

20
flake8:
21
  interruptible: true
Laurent Peuch's avatar
Laurent Peuch committed
22
23
24
25
26
  rules:
    - if: '$TRIGGERED_FROM_OTHER_PROJECT'
      when: never
    - changes:
        - "**/*.py"
27
28
  stage: lint
  before_script:
29
    - pip install tox flake8-gl-codeclimate
30
  script:
31
    - tox -e flake8 -- --exit-zero --format gl-codeclimate --output-file gl-code-quality-report.json
32
    - tox -e flake8
33
34
35
36
  artifacts:
    when: always
    reports:
      codequality: gl-code-quality-report.json
37

38
check-manifest:
39
  interruptible: true
Laurent Peuch's avatar
Laurent Peuch committed
40
41
42
  rules:
    - if: '$TRIGGERED_FROM_OTHER_PROJECT'
      when: never
43
    - when: on_success
44
45
46
47
48
49
  stage: lint
  before_script:
    - pip install tox
  script:
    - tox -e check-manifest

50
black:
51
  interruptible: true
52
53
54
55
56
57
58
59
60
61
  rules:
    - if: '$TRIGGERED_FROM_OTHER_PROJECT'
      when: never
    - when: on_success
  stage: lint
  before_script:
    - pip install tox
  script:
    - tox -e black

62
doc8:
63
  interruptible: true
Laurent Peuch's avatar
Laurent Peuch committed
64
65
66
67
68
  rules:
    - if: '$TRIGGERED_FROM_OTHER_PROJECT'
      when: never
    - changes:
        - doc/**/*
69
70
71
72
73
74
  stage: lint
  before_script:
    - pip install tox
  script:
    - tox -e doc8

75
yamllint:
76
  interruptible: true
Laurent Peuch's avatar
Laurent Peuch committed
77
78
79
80
81
82
  rules:
    - if: '$TRIGGERED_FROM_OTHER_PROJECT'
      when: never
    - changes:
        - "**/*.yaml"
        - "**/*.yml"
Laurent Peuch's avatar
Laurent Peuch committed
83
84
85
86
87
88
  stage: lint
  before_script:
    - pip install tox
  script:
    - tox -e yamllint

89
build_doc:
90
  interruptible: true
Laurent Peuch's avatar
Laurent Peuch committed
91
92
93
94
95
96
  rules:
    - if: '$TRIGGERED_FROM_OTHER_PROJECT'
      when: never
    - changes:
        - doc/**/*
        - "**/*.py"
97
98
99
100
101
  stage: lint
  before_script:
    - pip install tox
  script:
    - tox -e doc
102
103
104
  artifacts:
    paths:
      - .tox/doc/tmp/html
105
    expire_in: 2 weeks
Laurent Peuch's avatar
Laurent Peuch committed
106
  allow_failure: true  # XXX fix me
107

108
py3-server:
109
  interruptible: true
Laurent Peuch's avatar
Laurent Peuch committed
110
111
112
113
114
  rules:
    - if: '$TRIGGERED_FROM_OTHER_PROJECT'
      when: never
    - changes:
        - cubicweb/**/*
115
116
117
        - "*.py"  # setup.py
        - requirements/dev.txt
        - requirements/test-server.txt
118
119
120
        - tox.ini
        - .gitlab-ci.yml
        - requirements/*
121
122
  stage: tests
  image: r.intra.logilab.fr/jenkins/jnlp:buster
123
124
  before_script:
    - sudo apt update
125
    - sudo DEBIAN_FRONTEND=noninteractive APT_LISTCHANGES_FRONTEND=none apt-get install -y --assume-yes -qq -o=Dpkg::Use-Pty=0 slapd ldap-utils graphviz
126
127
  script:
    - tox -e py3-server
128
  artifacts:
129
    when: always
130
131
    paths:
      - /builds/cubicweb/cubicweb/server.html
132
      - /builds/cubicweb/cubicweb/py3-server-deprecated-warnings.json
133
      - /builds/cubicweb/cubicweb/reports/coverage-server.xml
134
      - /builds/cubicweb/cubicweb/prof/combined.svg
135
136
    reports:
      junit: /builds/cubicweb/cubicweb/server.xml
137
      cobertura: /builds/cubicweb/cubicweb/reports/coverage-server.xml
138
    expire_in: 2 weeks
139

140
py3-web:
141
  interruptible: true
Laurent Peuch's avatar
Laurent Peuch committed
142
143
144
145
146
  rules:
    - if: '$TRIGGERED_FROM_OTHER_PROJECT'
      when: never
    - changes:
        - cubicweb/**/*
147
148
149
        - "*.py"  # setup.py
        - requirements/dev.txt
        - requirements/test-web.txt
150
151
152
        - tox.ini
        - .gitlab-ci.yml
        - requirements/*
153
154
  stage: tests
  image: r.intra.logilab.fr/jenkins/jnlp:buster
155
  before_script:
156
    - sudo apt update && sudo apt install -y firefox-esr graphviz
157
158
  script:
    - tox -e py3-web
159
  artifacts:
160
    when: always
161
162
    paths:
      - /builds/cubicweb/cubicweb/web.html
163
      - /builds/cubicweb/cubicweb/py3-web-deprecated-warnings.json
164
      - /builds/cubicweb/cubicweb/reports/coverage-web.xml
165
      - /builds/cubicweb/cubicweb/prof/combined.svg
166
167
    reports:
      junit: /builds/cubicweb/cubicweb/web.xml
168
      cobertura: /builds/cubicweb/cubicweb/reports/coverage-web.xml
169
    expire_in: 2 weeks
170

171
py3-misc:
172
  interruptible: true
Laurent Peuch's avatar
Laurent Peuch committed
173
174
175
176
177
  rules:
    - if: '$TRIGGERED_FROM_OTHER_PROJECT'
      when: never
    - changes:
        - cubicweb/**/*
178
179
180
        - "*.py"  # setup.py
        - requirements/dev.txt
        - requirements/test-misc.txt
181
182
183
        - tox.ini
        - .gitlab-ci.yml
        - requirements/*
184
185
  stage: tests
  image: r.intra.logilab.fr/jenkins/jnlp:buster
186
  before_script:
187
    - sudo apt update && sudo apt install -y firefox-esr graphviz
188
189
  script:
    - tox -e py3-misc
190
  artifacts:
191
    when: always
192
193
    paths:
      - /builds/cubicweb/cubicweb/misc.html
194
      - /builds/cubicweb/cubicweb/py3-misc-deprecated-warnings.json
195
      - /builds/cubicweb/cubicweb/reports/coverage-misc.xml
196
      - /builds/cubicweb/cubicweb/prof/combined.svg
197
198
    reports:
      junit: /builds/cubicweb/cubicweb/misc.xml
199
      cobertura: /builds/cubicweb/cubicweb/reports/coverage-misc.xml
200
    expire_in: 2 weeks
Laurent Peuch's avatar
Laurent Peuch committed
201

202
test-cube-skeleton:
203
  interruptible: true
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
  rules:
    - if: '$TRIGGERED_FROM_OTHER_PROJECT'
      when: never
    - when: always
  stage: tests
  before_script:
    - pip install -e .
    - pip install tox
  script:
    - cubicweb-ctl newcube testcubeskeleton -s "test cube skeleton"
    - cd cubicweb-testcubeskeleton/
    - hg init
    - hg add .
    - hg commit -m "init"
    - tox
    - '[ "$(hg status | wc -l)" = 0 ]'

221
.py3-from-forge-server:
222
  interruptible: true
Laurent Peuch's avatar
Laurent Peuch committed
223
224
225
  rules:
    - changes:
        - cubicweb/**/*
226
227
228
229
        - "*.py"  # setup.py
        - requirements/from-forge.txt
        - requirements/dev.txt
        - requirements/test-server.txt
Laurent Peuch's avatar
Laurent Peuch committed
230
    - if: '$TRIGGERED_FROM_OTHER_PROJECT'
Laurent Peuch's avatar
Laurent Peuch committed
231
232
  stage: tests
  image: r.intra.logilab.fr/jenkins/jnlp:buster
233
  allow_failure: true
234
235
236
  before_script:
    - sudo apt update
    - sudo DEBIAN_FRONTEND=noninteractive APT_LISTCHANGES_FRONTEND=none apt-get install -y --assume-yes -qq -o=Dpkg::Use-Pty=0 slapd ldap-utils
237
238
239
  artifacts:
    paths:
      - /builds/cubicweb/cubicweb/from-forge-server.html
240
      - /builds/cubicweb/cubicweb/py3-from-forge-server-deprecated-warnings.json
241
242
    reports:
      junit: /builds/cubicweb/cubicweb/from-forge-server.xml
243
    expire_in: 2 weeks
Laurent Peuch's avatar
Laurent Peuch committed
244
245
  script:
    - tox -e py3-from-forge-server
246

247
.py3-from-forge-web:
248
  interruptible: true
Laurent Peuch's avatar
Laurent Peuch committed
249
250
251
  rules:
    - changes:
        - cubicweb/**/*
252
253
254
255
        - "*.py"  # setup.py
        - requirements/from-forge.txt
        - requirements/dev.txt
        - requirements/test-web.txt
Laurent Peuch's avatar
Laurent Peuch committed
256
    - if: '$TRIGGERED_FROM_OTHER_PROJECT'
257
258
259
  stage: tests
  image: r.intra.logilab.fr/jenkins/jnlp:buster
  allow_failure: true
260
261
  before_script:
    - sudo apt update && sudo apt install -y firefox-esr
262
263
  script:
    - tox -e py3-from-forge-web
264
265
266
  artifacts:
    paths:
      - /builds/cubicweb/cubicweb/from-forge-web.html
267
      - /builds/cubicweb/cubicweb/py3-from-forge-web-deprecated-warnings.json
268
269
    reports:
      junit: /builds/cubicweb/cubicweb/from-forge-web.xml
270
    expire_in: 2 weeks
271

272
.py3-from-forge-misc:
273
  interruptible: true
Laurent Peuch's avatar
Laurent Peuch committed
274
275
276
  rules:
    - changes:
        - cubicweb/**/*
277
278
279
280
        - "*.py"  # setup.py
        - requirements/from-forge.txt
        - requirements/dev.txt
        - requirements/test-misc.txt
Laurent Peuch's avatar
Laurent Peuch committed
281
    - if: '$TRIGGERED_FROM_OTHER_PROJECT'
282
283
284
  stage: tests
  image: r.intra.logilab.fr/jenkins/jnlp:buster
  allow_failure: true
285
286
  before_script:
    - sudo apt update && sudo apt install -y firefox-esr
287
288
  script:
    - tox -e py3-from-forge-misc
289
290
291
  artifacts:
    paths:
      - /builds/cubicweb/cubicweb/from-forge-misc.html
292
      - /builds/cubicweb/cubicweb/py3-from-forge-misc-deprecated-warnings.json
293
294
    reports:
      junit: /builds/cubicweb/cubicweb/from-forge-misc.xml
295
    expire_in: 2 weeks
296

Arthur Lutz's avatar
Arthur Lutz committed
297
sonarqube:
298
  interruptible: true
Arthur Lutz's avatar
Arthur Lutz committed
299
300
  stage: qa
  image: sonarsource/sonar-scanner-cli
Laurent Peuch's avatar
Laurent Peuch committed
301
302
303
304
  rules:
    - if: '$TRIGGERED_FROM_OTHER_PROJECT'
      when: never
    - if: '$CI_COMMIT_REF_NAME == "branch/default"'
Arthur Lutz's avatar
Arthur Lutz committed
305
306
307
308
309
310
311
312
313
314
315
  script:
    - apk add python3 mercurial
    - sonar-scanner
      --define sonar.scm.revision=${CI_COMMIT_REF_NAME##*/}
      --define sonar.projectBaseDir=.
      --define sonar.projectVersion=`python3 ./setup.py --version`
      --define sonar.scm.provider=hg
      --define sonar.projectKey=${CI_PROJECT_PATH_SLUG}
      --define sonar.projectName=${CI_PROJECT_TITLE}
      --define sonar.links.homepage=${CI_PROJECT_URL}
      --define sonar.host.url=${SONAR_URL}
316
317
318

pages:
  stage: deploy
Laurent Peuch's avatar
Laurent Peuch committed
319
320
321
322
  rules:
    - if: '$TRIGGERED_FROM_OTHER_PROJECT'
      when: never
    - if: '$CI_COMMIT_REF_NAME == "branch/default"'
323
324
325
  before_script:
    - pip install tox
  script:
326
327
328
329
330
    # remove previous artifacts from build_doc if any (cf. #206). The .tox/doc
    # directory does not « look as a virtualenv », and tox refuses to remove it.
    # Let's do it manually.
    - rm -rf .tox/doc/
    - tox -e doc
331
332
333
334
    - mv .tox/doc/tmp/html public
  artifacts:
    paths:
      - public