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

3
4
5
6
7
8
9
10
11
12
# avoid running duplicate pipelines for both topic head and MR
# with gitlab 13.8, $CI_OPEN_MERGE_REQUESTS will become available and improve this
# 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"'
    - if: '$CI_COMMIT_REF_NAME =~ /^topic\/.*/'
      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
Laurent Peuch's avatar
Laurent Peuch committed
83
  allow_failure: true  # XXX fix me
84
85

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

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

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

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

py3-from-forge-web:
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-web.txt
Laurent Peuch's avatar
Laurent Peuch committed
179
    - if: '$TRIGGERED_FROM_OTHER_PROJECT'
180
181
182
  stage: tests
  image: r.intra.logilab.fr/jenkins/jnlp:buster
  allow_failure: true
183
184
  before_script:
    - sudo apt update && sudo apt install -y firefox-esr
185
186
  script:
    - tox -e py3-from-forge-web
187
188
189
  artifacts:
    paths:
      - /builds/cubicweb/cubicweb/from-forge-web.html
190
      - /builds/cubicweb/cubicweb/py3-from-forge-web-deprecated-warnings.json
191
192

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

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

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

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