.gitlab-ci.yml 6.91 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

lint_py:
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
32
  stage: lint
  before_script:
    - pip install tox
  script:
    - tox -e flake8

lint_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
43
  stage: lint
  before_script:
    - pip install tox
  script:
    - tox -e check-manifest

lint_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

Laurent Peuch's avatar
Laurent Peuch committed
55
lint_yaml:
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
96
  stage: tests
  image: r.intra.logilab.fr/jenkins/jnlp:buster
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
119
  stage: tests
  image: r.intra.logilab.fr/jenkins/jnlp:buster
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
141
  stage: tests
  image: r.intra.logilab.fr/jenkins/jnlp:buster
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
py3-from-forge-server:
Laurent Peuch's avatar
Laurent Peuch committed
154
155
156
  rules:
    - changes:
        - cubicweb/**/*
157
158
159
160
        - "*.py"  # setup.py
        - requirements/from-forge.txt
        - requirements/dev.txt
        - requirements/test-server.txt
Laurent Peuch's avatar
Laurent Peuch committed
161
    - if: '$TRIGGERED_FROM_OTHER_PROJECT'
Laurent Peuch's avatar
Laurent Peuch committed
162
163
  stage: tests
  image: r.intra.logilab.fr/jenkins/jnlp:buster
164
  allow_failure: true
165
166
167
  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
168
169
170
  artifacts:
    paths:
      - /builds/cubicweb/cubicweb/from-forge-server.html
171
      - /builds/cubicweb/cubicweb/py3-from-forge-server-deprecated-warnings.json
172
    expire_in: 2 weeks
Laurent Peuch's avatar
Laurent Peuch committed
173
174
  script:
    - tox -e py3-from-forge-server
175
176

py3-from-forge-web:
Laurent Peuch's avatar
Laurent Peuch committed
177
178
179
  rules:
    - changes:
        - cubicweb/**/*
180
181
182
183
        - "*.py"  # setup.py
        - requirements/from-forge.txt
        - requirements/dev.txt
        - requirements/test-web.txt
Laurent Peuch's avatar
Laurent Peuch committed
184
    - if: '$TRIGGERED_FROM_OTHER_PROJECT'
185
186
187
  stage: tests
  image: r.intra.logilab.fr/jenkins/jnlp:buster
  allow_failure: true
188
189
  before_script:
    - sudo apt update && sudo apt install -y firefox-esr
190
191
  script:
    - tox -e py3-from-forge-web
192
193
194
  artifacts:
    paths:
      - /builds/cubicweb/cubicweb/from-forge-web.html
195
      - /builds/cubicweb/cubicweb/py3-from-forge-web-deprecated-warnings.json
196
    expire_in: 2 weeks
197
198

py3-from-forge-misc:
Laurent Peuch's avatar
Laurent Peuch committed
199
200
201
  rules:
    - changes:
        - cubicweb/**/*
202
203
204
205
        - "*.py"  # setup.py
        - requirements/from-forge.txt
        - requirements/dev.txt
        - requirements/test-misc.txt
Laurent Peuch's avatar
Laurent Peuch committed
206
    - if: '$TRIGGERED_FROM_OTHER_PROJECT'
207
208
209
  stage: tests
  image: r.intra.logilab.fr/jenkins/jnlp:buster
  allow_failure: true
210
211
  before_script:
    - sudo apt update && sudo apt install -y firefox-esr
212
213
  script:
    - tox -e py3-from-forge-misc
214
215
216
  artifacts:
    paths:
      - /builds/cubicweb/cubicweb/from-forge-misc.html
217
      - /builds/cubicweb/cubicweb/py3-from-forge-misc-deprecated-warnings.json
218
    expire_in: 2 weeks
219
220

trigger-readthedocs:
Laurent Peuch's avatar
Laurent Peuch committed
221
222
223
224
225
226
227
  rules:
    - if: '$TRIGGERED_FROM_OTHER_PROJECT'
      when: never
    - if: '$CI_COMMIT_REF_NAME == "branch/default"'
      changes:
        - cubicweb/**/*
        - doc/**/*
228
229
  stage: after-tests
  script:
Laurent Peuch's avatar
Laurent Peuch committed
230
231
    # 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
232
233
234
235

sonarqube:
  stage: qa
  image: sonarsource/sonar-scanner-cli
Laurent Peuch's avatar
Laurent Peuch committed
236
237
238
239
  rules:
    - if: '$TRIGGERED_FROM_OTHER_PROJECT'
      when: never
    - if: '$CI_COMMIT_REF_NAME == "branch/default"'
Arthur Lutz's avatar
Arthur Lutz committed
240
241
242
243
244
245
246
247
248
249
250
  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}
251
252
253

pages:
  stage: deploy
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"'
258
259
260
  before_script:
    - pip install tox
  script:
261
262
263
264
265
    # 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
266
267
268
269
    - mv .tox/doc/tmp/html public
  artifacts:
    paths:
      - public