.gitlab-ci.yml 9.37 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"
Carine Dengler's avatar
Carine Dengler committed
27
        - "*.py"
28 29
  stage: lint
  before_script:
30
    - pip install tox flake8-gl-codeclimate
31
  script:
32
    - tox -e flake8 -- --exit-zero --format gl-codeclimate --output-file gl-code-quality-report.json
33
    - tox -e flake8
34 35 36 37
  artifacts:
    when: always
    reports:
      codequality: gl-code-quality-report.json
38

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

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

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

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

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

Laurent Peuch's avatar
Laurent Peuch committed
109
can-i-merge:
110
  image: debian:buster
Laurent Peuch's avatar
Laurent Peuch committed
111
  interruptible: true
112
  allow_failure: true
Laurent Peuch's avatar
Laurent Peuch committed
113 114
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
115
  stage: qa
Laurent Peuch's avatar
Laurent Peuch committed
116 117
  before_script:
    - apt-get update
118 119 120
    - apt-get install python-pip python3-pip mercurial -y
    - pip3 install hg+https://forge.extranet.logilab.fr/open-source/can-i-merge/
    - echo -e "[extensions]\nevolve =\ntopic =\nrebase =" >> ~/.hgrc
Laurent Peuch's avatar
Laurent Peuch committed
121 122 123 124 125 126 127 128
    - python2 -m pip install hg-evolve
  script:
    - can-i-merge
  artifacts:
    when: always
    reports:
      junit: /builds/cubicweb/cubicweb/can_i_merge.xml

129
py3-server:
130
  interruptible: true
Laurent Peuch's avatar
Laurent Peuch committed
131 132 133 134 135
  rules:
    - if: '$TRIGGERED_FROM_OTHER_PROJECT'
      when: never
    - changes:
        - cubicweb/**/*
136 137 138
        - "*.py"  # setup.py
        - requirements/dev.txt
        - requirements/test-server.txt
139 140 141
        - tox.ini
        - .gitlab-ci.yml
        - requirements/*
142
  stage: tests
143
  image: registry.logilab.fr/logilab/infra/dockerfiles/debian-buster-slim-pg11
144 145
  before_script:
    - sudo apt update
146
    - sudo DEBIAN_FRONTEND=noninteractive APT_LISTCHANGES_FRONTEND=none apt-get install -y --assume-yes -qq -o=Dpkg::Use-Pty=0 slapd ldap-utils graphviz
147 148
  script:
    - tox -e py3-server
149
  artifacts:
150
    when: always
151 152
    paths:
      - /builds/cubicweb/cubicweb/server.html
153
      - /builds/cubicweb/cubicweb/py3-server-deprecated-warnings.json
154
      - /builds/cubicweb/cubicweb/reports/coverage-server.xml
155
      - /builds/cubicweb/cubicweb/prof/combined.svg
156 157
    reports:
      junit: /builds/cubicweb/cubicweb/server.xml
158
      cobertura: /builds/cubicweb/cubicweb/reports/coverage-server.xml
159
    expire_in: 2 weeks
160

161
py3-web:
162
  interruptible: true
Laurent Peuch's avatar
Laurent Peuch committed
163 164 165 166 167
  rules:
    - if: '$TRIGGERED_FROM_OTHER_PROJECT'
      when: never
    - changes:
        - cubicweb/**/*
168 169 170
        - "*.py"  # setup.py
        - requirements/dev.txt
        - requirements/test-web.txt
171 172 173
        - tox.ini
        - .gitlab-ci.yml
        - requirements/*
174
  stage: tests
175
  image: registry.logilab.fr/logilab/infra/dockerfiles/debian-buster-slim-pg11
176
  before_script:
177
    - sudo apt update && sudo apt install -y firefox-esr graphviz
178 179
  script:
    - tox -e py3-web
180
  artifacts:
181
    when: always
182 183
    paths:
      - /builds/cubicweb/cubicweb/web.html
184
      - /builds/cubicweb/cubicweb/py3-web-deprecated-warnings.json
185
      - /builds/cubicweb/cubicweb/reports/coverage-web.xml
186
      - /builds/cubicweb/cubicweb/prof/combined.svg
187 188
    reports:
      junit: /builds/cubicweb/cubicweb/web.xml
189
      cobertura: /builds/cubicweb/cubicweb/reports/coverage-web.xml
190
    expire_in: 2 weeks
191

192
py3-misc:
193
  interruptible: true
Laurent Peuch's avatar
Laurent Peuch committed
194 195 196 197 198
  rules:
    - if: '$TRIGGERED_FROM_OTHER_PROJECT'
      when: never
    - changes:
        - cubicweb/**/*
199 200 201
        - "*.py"  # setup.py
        - requirements/dev.txt
        - requirements/test-misc.txt
202 203 204
        - tox.ini
        - .gitlab-ci.yml
        - requirements/*
205
  stage: tests
206
  image: registry.logilab.fr/logilab/infra/dockerfiles/debian-buster-slim-pg11
207
  before_script:
208
    - sudo apt update && sudo apt install -y firefox-esr graphviz
209 210
  script:
    - tox -e py3-misc
211
  artifacts:
212
    when: always
213 214
    paths:
      - /builds/cubicweb/cubicweb/misc.html
215
      - /builds/cubicweb/cubicweb/py3-misc-deprecated-warnings.json
216
      - /builds/cubicweb/cubicweb/reports/coverage-misc.xml
217
      - /builds/cubicweb/cubicweb/prof/combined.svg
218 219
    reports:
      junit: /builds/cubicweb/cubicweb/misc.xml
220
      cobertura: /builds/cubicweb/cubicweb/reports/coverage-misc.xml
221
    expire_in: 2 weeks
Laurent Peuch's avatar
Laurent Peuch committed
222

223
test-cube-skeleton:
224
  interruptible: true
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241
  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 ]'

242
.py3-from-forge-server:
243
  interruptible: true
Laurent Peuch's avatar
Laurent Peuch committed
244 245 246
  rules:
    - changes:
        - cubicweb/**/*
247 248 249 250
        - "*.py"  # setup.py
        - requirements/from-forge.txt
        - requirements/dev.txt
        - requirements/test-server.txt
Laurent Peuch's avatar
Laurent Peuch committed
251
    - if: '$TRIGGERED_FROM_OTHER_PROJECT'
Laurent Peuch's avatar
Laurent Peuch committed
252
  stage: tests
253
  image: registry.logilab.fr/logilab/infra/dockerfiles/debian-buster-slim-pg11
254
  allow_failure: true
255 256 257
  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
258 259 260
  artifacts:
    paths:
      - /builds/cubicweb/cubicweb/from-forge-server.html
261
      - /builds/cubicweb/cubicweb/py3-from-forge-server-deprecated-warnings.json
262 263
    reports:
      junit: /builds/cubicweb/cubicweb/from-forge-server.xml
264
    expire_in: 2 weeks
Laurent Peuch's avatar
Laurent Peuch committed
265 266
  script:
    - tox -e py3-from-forge-server
267

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

293
.py3-from-forge-misc:
294
  interruptible: true
Laurent Peuch's avatar
Laurent Peuch committed
295 296 297
  rules:
    - changes:
        - cubicweb/**/*
298 299 300 301
        - "*.py"  # setup.py
        - requirements/from-forge.txt
        - requirements/dev.txt
        - requirements/test-misc.txt
Laurent Peuch's avatar
Laurent Peuch committed
302
    - if: '$TRIGGERED_FROM_OTHER_PROJECT'
303
  stage: tests
304
  image: registry.logilab.fr/logilab/infra/dockerfiles/debian-buster-slim-pg11
305
  allow_failure: true
306 307
  before_script:
    - sudo apt update && sudo apt install -y firefox-esr
308 309
  script:
    - tox -e py3-from-forge-misc
310 311 312
  artifacts:
    paths:
      - /builds/cubicweb/cubicweb/from-forge-misc.html
313
      - /builds/cubicweb/cubicweb/py3-from-forge-misc-deprecated-warnings.json
314 315
    reports:
      junit: /builds/cubicweb/cubicweb/from-forge-misc.xml
316
    expire_in: 2 weeks
317

Arthur Lutz's avatar
Arthur Lutz committed
318
sonarqube:
319
  interruptible: true
Arthur Lutz's avatar
Arthur Lutz committed
320 321
  stage: qa
  image: sonarsource/sonar-scanner-cli
Laurent Peuch's avatar
Laurent Peuch committed
322 323 324 325
  rules:
    - if: '$TRIGGERED_FROM_OTHER_PROJECT'
      when: never
    - if: '$CI_COMMIT_REF_NAME == "branch/default"'
Arthur Lutz's avatar
Arthur Lutz committed
326 327 328 329 330 331 332 333 334 335 336
  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}
337 338 339

pages:
  stage: deploy
Laurent Peuch's avatar
Laurent Peuch committed
340 341 342 343
  rules:
    - if: '$TRIGGERED_FROM_OTHER_PROJECT'
      when: never
    - if: '$CI_COMMIT_REF_NAME == "branch/default"'
344 345 346
  before_script:
    - pip install tox
  script:
347 348 349 350 351
    # 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
352 353 354 355
    - mv .tox/doc/tmp/html public
  artifacts:
    paths:
      - public