.gitlab-ci.yml 6.74 KB
Newer Older
1
2
image: python:latest

3
4
5
6
7
# 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"'
8
    - if: '$CI_COMMIT_REF_NAME =~ /^topic\/.*/  && $CI_OPEN_MERGE_REQUESTS'
9
10
11
      when: never
    - when: always

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

lint_py:
Laurent Peuch's avatar
Laurent Peuch committed
20
21
22
23
24
  rules:
    - if: '$TRIGGERED_FROM_OTHER_PROJECT'
      when: never
    - changes:
        - "**/*.py"
25
26
27
28
29
30
31
  stage: lint
  before_script:
    - pip install tox
  script:
    - tox -e flake8

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

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

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

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

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

py3_web:
Laurent Peuch's avatar
Laurent Peuch committed
107
108
109
110
111
  rules:
    - if: '$TRIGGERED_FROM_OTHER_PROJECT'
      when: never
    - changes:
        - cubicweb/**/*
112
113
114
        - "*.py"  # setup.py
        - requirements/dev.txt
        - requirements/test-web.txt
115
116
  stage: tests
  image: r.intra.logilab.fr/jenkins/jnlp:buster
117
118
  before_script:
    - sudo apt update && sudo apt install -y firefox-esr
119
120
  script:
    - tox -e py3-web
121
122
123
  artifacts:
    paths:
      - /builds/cubicweb/cubicweb/web.html
124
      - /builds/cubicweb/cubicweb/py3-web-deprecated-warnings.json
125
      - /reports/coverage-web.xml
126
127

py3_misc:
Laurent Peuch's avatar
Laurent Peuch committed
128
129
130
131
132
  rules:
    - if: '$TRIGGERED_FROM_OTHER_PROJECT'
      when: never
    - changes:
        - cubicweb/**/*
133
134
135
        - "*.py"  # setup.py
        - requirements/dev.txt
        - requirements/test-misc.txt
136
137
  stage: tests
  image: r.intra.logilab.fr/jenkins/jnlp:buster
138
139
  before_script:
    - sudo apt update && sudo apt install -y firefox-esr
140
141
  script:
    - tox -e py3-misc
142
143
144
  artifacts:
    paths:
      - /builds/cubicweb/cubicweb/misc.html
145
      - /builds/cubicweb/cubicweb/py3-misc-deprecated-warnings.json
146
      - /reports/coverage-misc.xml
Laurent Peuch's avatar
Laurent Peuch committed
147

148
py3-from-forge-server:
Laurent Peuch's avatar
Laurent Peuch committed
149
150
151
  rules:
    - changes:
        - cubicweb/**/*
152
153
154
155
        - "*.py"  # setup.py
        - requirements/from-forge.txt
        - requirements/dev.txt
        - requirements/test-server.txt
Laurent Peuch's avatar
Laurent Peuch committed
156
    - if: '$TRIGGERED_FROM_OTHER_PROJECT'
Laurent Peuch's avatar
Laurent Peuch committed
157
158
  stage: tests
  image: r.intra.logilab.fr/jenkins/jnlp:buster
159
  allow_failure: true
160
161
162
  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
163
164
165
  artifacts:
    paths:
      - /builds/cubicweb/cubicweb/from-forge-server.html
166
      - /builds/cubicweb/cubicweb/py3-from-forge-server-deprecated-warnings.json
Laurent Peuch's avatar
Laurent Peuch committed
167
168
  script:
    - tox -e py3-from-forge-server
169
170

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

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

trigger-readthedocs:
Laurent Peuch's avatar
Laurent Peuch committed
213
214
215
216
217
218
219
  rules:
    - if: '$TRIGGERED_FROM_OTHER_PROJECT'
      when: never
    - if: '$CI_COMMIT_REF_NAME == "branch/default"'
      changes:
        - cubicweb/**/*
        - doc/**/*
220
221
  stage: after-tests
  script:
Laurent Peuch's avatar
Laurent Peuch committed
222
223
    # 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
224
225
226
227

sonarqube:
  stage: qa
  image: sonarsource/sonar-scanner-cli
Laurent Peuch's avatar
Laurent Peuch committed
228
229
230
231
  rules:
    - if: '$TRIGGERED_FROM_OTHER_PROJECT'
      when: never
    - if: '$CI_COMMIT_REF_NAME == "branch/default"'
Arthur Lutz's avatar
Arthur Lutz committed
232
233
234
235
236
237
238
239
240
241
242
  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}
243
244
245

pages:
  stage: deploy
Laurent Peuch's avatar
Laurent Peuch committed
246
247
248
249
  rules:
    - if: '$TRIGGERED_FROM_OTHER_PROJECT'
      when: never
    - if: '$CI_COMMIT_REF_NAME == "branch/default"'
250
251
252
  before_script:
    - pip install tox
  script:
253
254
255
256
257
    # 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
258
259
260
261
    - mv .tox/doc/tmp/html public
  artifacts:
    paths:
      - public