.gitlab-ci.yml 7.48 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:
Laurent Peuch's avatar
Laurent Peuch committed
21
22
23
24
25
  rules:
    - if: '$TRIGGERED_FROM_OTHER_PROJECT'
      when: never
    - changes:
        - "**/*.py"
26
27
28
29
30
31
  stage: lint
  before_script:
    - pip install tox
  script:
    - tox -e flake8

32
check-manifest:
Laurent Peuch's avatar
Laurent Peuch committed
33
34
35
  rules:
    - if: '$TRIGGERED_FROM_OTHER_PROJECT'
      when: never
36
    - when: on_success
37
38
39
40
41
42
  stage: lint
  before_script:
    - pip install tox
  script:
    - tox -e check-manifest

43
doc8:
Laurent Peuch's avatar
Laurent Peuch committed
44
45
46
47
48
  rules:
    - if: '$TRIGGERED_FROM_OTHER_PROJECT'
      when: never
    - changes:
        - doc/**/*
49
50
51
52
53
54
  stage: lint
  before_script:
    - pip install tox
  script:
    - tox -e doc8

55
yamllint:
Laurent Peuch's avatar
Laurent Peuch committed
56
57
58
59
60
61
  rules:
    - if: '$TRIGGERED_FROM_OTHER_PROJECT'
      when: never
    - changes:
        - "**/*.yaml"
        - "**/*.yml"
Laurent Peuch's avatar
Laurent Peuch committed
62
63
64
65
66
67
  stage: lint
  before_script:
    - pip install tox
  script:
    - tox -e yamllint

68
build_doc:
Laurent Peuch's avatar
Laurent Peuch committed
69
70
71
72
73
74
  rules:
    - if: '$TRIGGERED_FROM_OTHER_PROJECT'
      when: never
    - changes:
        - doc/**/*
        - "**/*.py"
75
76
77
78
79
  stage: lint
  before_script:
    - pip install tox
  script:
    - tox -e doc
80
81
82
  artifacts:
    paths:
      - .tox/doc/tmp/html
83
    expire_in: 2 weeks
Laurent Peuch's avatar
Laurent Peuch committed
84
  allow_failure: true  # XXX fix me
85

86
py3-server:
Laurent Peuch's avatar
Laurent Peuch committed
87
88
89
90
91
  rules:
    - if: '$TRIGGERED_FROM_OTHER_PROJECT'
      when: never
    - changes:
        - cubicweb/**/*
92
93
94
        - "*.py"  # setup.py
        - requirements/dev.txt
        - requirements/test-server.txt
95
  stage: tests
96
  image: registry.logilab.fr/logilab/infra/dockerfiles/debian-buster-slim-pg11
97
98
99
  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
100
101
  script:
    - tox -e py3-server
102
103
104
  artifacts:
    paths:
      - /builds/cubicweb/cubicweb/server.html
105
      - /builds/cubicweb/cubicweb/py3-server-deprecated-warnings.json
106
      - /reports/coverage-server.xml
107
    expire_in: 2 weeks
108

109
py3-web:
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-web.txt
118
  stage: tests
119
  image: registry.logilab.fr/logilab/infra/dockerfiles/debian-buster-slim-pg11
120
121
  before_script:
    - sudo apt update && sudo apt install -y firefox-esr
122
123
  script:
    - tox -e py3-web
124
125
126
  artifacts:
    paths:
      - /builds/cubicweb/cubicweb/web.html
127
      - /builds/cubicweb/cubicweb/py3-web-deprecated-warnings.json
128
      - /reports/coverage-web.xml
129
    expire_in: 2 weeks
130

131
py3-misc:
Laurent Peuch's avatar
Laurent Peuch committed
132
133
134
135
136
  rules:
    - if: '$TRIGGERED_FROM_OTHER_PROJECT'
      when: never
    - changes:
        - cubicweb/**/*
137
138
139
        - "*.py"  # setup.py
        - requirements/dev.txt
        - requirements/test-misc.txt
140
  stage: tests
141
  image: registry.logilab.fr/logilab/infra/dockerfiles/debian-buster-slim-pg11
142
143
  before_script:
    - sudo apt update && sudo apt install -y firefox-esr
144
145
  script:
    - tox -e py3-misc
146
147
148
  artifacts:
    paths:
      - /builds/cubicweb/cubicweb/misc.html
149
      - /builds/cubicweb/cubicweb/py3-misc-deprecated-warnings.json
150
      - /reports/coverage-misc.xml
151
    expire_in: 2 weeks
Laurent Peuch's avatar
Laurent Peuch committed
152

153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
test-cube-skeleton:
  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 ]'

171
py3-from-forge-server:
Laurent Peuch's avatar
Laurent Peuch committed
172
173
174
  rules:
    - changes:
        - cubicweb/**/*
175
176
177
178
        - "*.py"  # setup.py
        - requirements/from-forge.txt
        - requirements/dev.txt
        - requirements/test-server.txt
Laurent Peuch's avatar
Laurent Peuch committed
179
    - if: '$TRIGGERED_FROM_OTHER_PROJECT'
Laurent Peuch's avatar
Laurent Peuch committed
180
  stage: tests
181
  image: registry.logilab.fr/logilab/infra/dockerfiles/debian-buster-slim-pg11
182
  allow_failure: true
183
184
185
  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
186
187
188
  artifacts:
    paths:
      - /builds/cubicweb/cubicweb/from-forge-server.html
189
      - /builds/cubicweb/cubicweb/py3-from-forge-server-deprecated-warnings.json
190
    expire_in: 2 weeks
Laurent Peuch's avatar
Laurent Peuch committed
191
192
  script:
    - tox -e py3-from-forge-server
193
194

py3-from-forge-web:
Laurent Peuch's avatar
Laurent Peuch committed
195
196
197
  rules:
    - changes:
        - cubicweb/**/*
198
199
200
201
        - "*.py"  # setup.py
        - requirements/from-forge.txt
        - requirements/dev.txt
        - requirements/test-web.txt
Laurent Peuch's avatar
Laurent Peuch committed
202
    - if: '$TRIGGERED_FROM_OTHER_PROJECT'
203
  stage: tests
204
  image: registry.logilab.fr/logilab/infra/dockerfiles/debian-buster-slim-pg11
205
  allow_failure: true
206
207
  before_script:
    - sudo apt update && sudo apt install -y firefox-esr
208
209
  script:
    - tox -e py3-from-forge-web
210
211
212
  artifacts:
    paths:
      - /builds/cubicweb/cubicweb/from-forge-web.html
213
      - /builds/cubicweb/cubicweb/py3-from-forge-web-deprecated-warnings.json
214
    expire_in: 2 weeks
215
216

py3-from-forge-misc:
Laurent Peuch's avatar
Laurent Peuch committed
217
218
219
  rules:
    - changes:
        - cubicweb/**/*
220
221
222
223
        - "*.py"  # setup.py
        - requirements/from-forge.txt
        - requirements/dev.txt
        - requirements/test-misc.txt
Laurent Peuch's avatar
Laurent Peuch committed
224
    - if: '$TRIGGERED_FROM_OTHER_PROJECT'
225
  stage: tests
226
  image: registry.logilab.fr/logilab/infra/dockerfiles/debian-buster-slim-pg11
227
  allow_failure: true
228
229
  before_script:
    - sudo apt update && sudo apt install -y firefox-esr
230
231
  script:
    - tox -e py3-from-forge-misc
232
233
234
  artifacts:
    paths:
      - /builds/cubicweb/cubicweb/from-forge-misc.html
235
      - /builds/cubicweb/cubicweb/py3-from-forge-misc-deprecated-warnings.json
236
    expire_in: 2 weeks
237
238

trigger-readthedocs:
Laurent Peuch's avatar
Laurent Peuch committed
239
240
241
242
243
244
245
  rules:
    - if: '$TRIGGERED_FROM_OTHER_PROJECT'
      when: never
    - if: '$CI_COMMIT_REF_NAME == "branch/default"'
      changes:
        - cubicweb/**/*
        - doc/**/*
246
247
  stage: after-tests
  script:
Laurent Peuch's avatar
Laurent Peuch committed
248
249
    # regarding the " everywhere when there is a '%': yaml is extremly weird when % are involved
    - curl -X POST -d "token=${READTHEDOCS_TOKEN}" https://readthedocs.org/api/v2/webhook/cubicweb/33537/ -w "\nhttp code:"\ "%{http_code}\n" -f
Arthur Lutz's avatar
Arthur Lutz committed
250
251
252
253

sonarqube:
  stage: qa
  image: sonarsource/sonar-scanner-cli
Laurent Peuch's avatar
Laurent Peuch committed
254
255
256
257
  rules:
    - if: '$TRIGGERED_FROM_OTHER_PROJECT'
      when: never
    - if: '$CI_COMMIT_REF_NAME == "branch/default"'
Arthur Lutz's avatar
Arthur Lutz committed
258
259
260
261
262
263
264
265
266
267
268
  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}
269
270
271

pages:
  stage: deploy
Laurent Peuch's avatar
Laurent Peuch committed
272
273
274
275
  rules:
    - if: '$TRIGGERED_FROM_OTHER_PROJECT'
      when: never
    - if: '$CI_COMMIT_REF_NAME == "branch/default"'
276
277
278
  before_script:
    - pip install tox
  script:
279
280
281
282
283
    # 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
284
285
286
287
    - mv .tox/doc/tmp/html public
  artifacts:
    paths:
      - public