-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
309 lines (271 loc) · 8.19 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
include:
project: TankerHQ/gitlab-ci-files
file: /common.yml
ref: 2023-08-09-267
variables:
SDK_NATIVE_CONAN_REFERENCE: tanker/latest-stable@
############
# Workflow #
############
workflow:
rules:
# web pipelines for releases only
- if: $CI_PIPELINE_SOURCE == "web" && $SDK_PYTHON_RELEASE_VERSION !~ /\A\d+\.\d+\.\d+(-(alpha|beta)\d+)?\z/
when: never
- if: !reference [.if-invalid-native-conan-reference, if]
when: never
- if: '$CI_MERGE_REQUEST_TITLE =~ /.*\[preview].*/'
variables:
CONAN_REMOTE: "artifactory-preview"
- when: always
variables:
CONAN_REMOTE: "artifactory"
###########
# Default #
###########
default:
before_script:
- poetry -V
- poetry run python -m pip install --upgrade pip
- poetry install --no-root
- poetry run python --version
image: registry.gitlab.com/tankerhq/docker/sdk-python:latest
##########
# Stages #
##########
stages:
- check
- build-wheel
- deploy
#################
# Extend blocks #
#################
.coverage:
artifacts:
paths:
- coverage
expire_in: 7 days
.rules/deployed-native:
rules:
- !reference [.rules/web/auto, rules]
- !reference [.rules/mr/manual, rules]
#############################
# Default settings override #
#############################
.before-script/download-artifacts:
before_script:
- poetry run python -m pip install --upgrade pip
- poetry install --no-root
- poetry run python run-ci.py download-artifacts --project-id=$UPSTREAM_PROJECT_ID --pipeline-id=$UPSTREAM_PIPELINE_ID --job-name=$UPSTREAM_JOB_NAME
###############
# check stage #
###############
lint:
stage: check
rules:
- !reference [.rules/mr/auto, rules]
- !reference [.rules/web/auto, rules]
- !reference [.rules/push-master-or-feat, rules]
script:
- ./lint.sh
tags: !reference [.tags/linux, tags]
## deployed native
check/deployed-native/linux:
stage: check
extends:
- .coverage
- .rules/deployed-native
script:
- poetry run python run-ci.py --isolate-conan-user-home prepare --use-tanker=deployed --profile linux-x86_64 --remote $CONAN_REMOTE --tanker-ref=$SDK_NATIVE_CONAN_REFERENCE
- poetry run python run-ci.py build --test
parallel:
matrix:
- PYENV_VERSION: [ '3.9', '3.10', '3.11', '3.12' ]
tags: !reference [.tags/linux, tags]
check/deployed-native/macos/x86_64:
stage: check
extends:
- .coverage
- .rules/deployed-native
script:
- poetry run python run-ci.py --isolate-conan-user-home prepare --use-tanker=deployed --profile macos-x86_64 --remote $CONAN_REMOTE --tanker-ref=$SDK_NATIVE_CONAN_REFERENCE
- poetry run python run-ci.py build --test
parallel:
matrix:
- PYENV_VERSION: [ '3.9', '3.10', '3.11', '3.12' ]
tags: !reference [.tags/macos/x86_64, tags]
check/deployed-native/macos/arm:
stage: check
extends:
- .coverage
- .rules/deployed-native
script:
- poetry run python run-ci.py --isolate-conan-user-home prepare --use-tanker=deployed --profile macos-armv8 --remote $CONAN_REMOTE --tanker-ref=$SDK_NATIVE_CONAN_REFERENCE
- poetry run python run-ci.py build --test
parallel:
matrix:
- PYENV_VERSION: [ '3.9', '3.10', '3.11', '3.12' ]
tags: !reference [.tags/macos/arm, tags]
## native from sources
check/native-from-sources/linux:
stage: check
extends:
- .coverage
- .rules/native-from-sources
script:
- poetry run python run-ci.py --isolate-conan-user-home prepare --remote $CONAN_REMOTE --use-tanker=same-as-branch --profile linux-x86_64
- poetry run python run-ci.py build --test
parallel:
matrix:
- PYENV_VERSION: [ '3.9', '3.10', '3.11', '3.12' ]
tags: !reference [.tags/compilation-linux, tags]
check/native-from-sources/macos/x86_64:
stage: check
extends:
- .coverage
- .rules/native-from-sources
script:
- poetry run python run-ci.py --isolate-conan-user-home prepare --remote $CONAN_REMOTE --use-tanker=same-as-branch --profile macos-x86_64
- poetry run python run-ci.py build --test
parallel:
matrix:
- PYENV_VERSION: [ '3.9', '3.10', '3.11', '3.12' ]
tags: !reference [.tags/macos/x86_64, tags]
check/native-from-sources/macos/arm:
stage: check
extends:
- .coverage
- .rules/native-from-sources
script:
- poetry run python run-ci.py --isolate-conan-user-home prepare --remote $CONAN_REMOTE --use-tanker=same-as-branch --profile macos-armv8
- poetry run python run-ci.py build --test
parallel:
matrix:
- PYENV_VERSION: [ '3.9', '3.10', '3.11', '3.12' ]
tags: !reference [.tags/macos/arm, tags]
## downstream
check/downstream/linux:
stage: check
extends:
- .before-script/download-artifacts
- .rules/check/downstream/linux
script:
- poetry run python run-ci.py --isolate-conan-user-home prepare --remote $CONAN_REMOTE --use-tanker=upstream --profile linux-x86_64
- poetry run python run-ci.py build --test
parallel:
matrix:
- PYENV_VERSION: [ '3.9', '3.10', '3.11', '3.12' ]
tags: !reference [.tags/linux, tags]
check/downstream/macos/x86_64:
stage: check
extends:
- .before-script/download-artifacts
- .rules/check/downstream/macos/x86_64
dependencies: []
script:
- poetry run python run-ci.py --isolate-conan-user-home prepare --remote $CONAN_REMOTE --use-tanker=upstream --profile macos-x86_64
- poetry run python run-ci.py build --test
parallel:
matrix:
- PYENV_VERSION: [ '3.9', '3.10', '3.11', '3.12' ]
tags: !reference [.tags/macos/x86_64, tags]
check/downstream/macos/arm:
stage: check
extends:
- .before-script/download-artifacts
- .rules/check/downstream/macos/arm
dependencies: []
script:
- poetry run python run-ci.py --isolate-conan-user-home prepare --remote $CONAN_REMOTE --use-tanker=upstream --profile macos-armv8
- poetry run python run-ci.py build --test
parallel:
matrix:
- PYENV_VERSION: [ '3.9', '3.10', '3.11', '3.12' ]
tags: !reference [.tags/macos/arm, tags]
.safety:
stage: check
before_script:
- poetry -V
# poetry does not remove deps that aren't necessary anymore, that leads to
# false positive on safety's side
- poetry env remove $(poetry run which python3 | sed -e 's/^.*tanker\(.*\)\/bin.*$/tanker\1/') || true
- poetry run python -m pip install --upgrade pip
- poetry install --no-root
- poetry run python --version
script:
- poetry run safety check --full-report
tags: !reference [.tags/linux, tags]
safety:
extends:
- .rules/nightly
- .safety
safety/manual:
extends:
- .rules/mr/manual
- .safety
#####################
# build-wheel stage #
#####################
.rules/build-wheel:
rules:
- !reference [.rules/valid-python-release-version, rules]
- !reference [.rules/web/auto, rules]
- !reference [.rules/deploy-pipeline, rules]
.job/build-wheel:
stage: build-wheel
extends:
- .rules/build-wheel
script:
- poetry run python run-ci.py --isolate-conan-user-home prepare --remote $CONAN_REMOTE --use-tanker=deployed --tanker-ref $SDK_NATIVE_CONAN_REFERENCE --profile $CONAN_PROFILE
- poetry run python run-ci.py build --release $SDK_PYTHON_RELEASE_VERSION
artifacts:
paths:
- dist
build-wheel/linux:
extends:
- .job/build-wheel
variables:
CONAN_PROFILE: linux-x86_64
tags: !reference [.tags/linux, tags]
build-wheel/macos/x86_64:
extends:
- .job/build-wheel
variables:
CONAN_PROFILE: macos-x86_64
tags: !reference [.tags/macos/x86_64, tags]
build-wheel/macos/arm:
extends:
- .job/build-wheel
variables:
CONAN_PROFILE: macos-armv8
tags: !reference [.tags/macos/arm, tags]
################
# deploy stage #
################
deploy:
stage: deploy
extends:
- .rules/deploy/python
script:
- poetry run python run-ci.py deploy
needs:
- build-wheel/linux
- build-wheel/macos/x86_64
- build-wheel/macos/arm
release:
description: sdk-python v$SDK_PYTHON_RELEASE_VERSION
tag_name: v$SDK_PYTHON_RELEASE_VERSION
tags: !reference [.tags/linux, tags]
pages:
stage: deploy
extends:
- .rules/push-master-or-feat
needs:
- check/native-from-sources/linux
script:
- mv coverage/ public/
artifacts:
paths:
- public
expire_in: 7 days
tags: !reference [.tags/linux, tags]