-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
207 lines (197 loc) Β· 4.96 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
stages:
- π lint
- π€ test
- π¦ build
- π deploy
variables:
PYTHON_DOCKER_IMAGE: python:3.12-slim-bookworm
SFCGAL_REGISTRY: registry.gitlab.com/sfcgal/sfcgal
lint:flake8:
stage: π lint
image: ${PYTHON_DOCKER_IMAGE}
only:
refs:
- merge_requests
- master
changes:
- "pysfcgal/*.py"
- "tests/*.py"
- ".gitlab-ci.yml"
before_script:
- python -m pip install --force-reinstall flake8==7.1.1
script:
- flake8 pysfcgal/ tests/ --config=setup.cfg
lint:commit:
stage: π lint
image: ${PYTHON_DOCKER_IMAGE}
before_script:
- apt-get update && apt-get install -y git
- pip install commitizen
script:
- cz check --rev-range $CI_MERGE_REQUEST_DIFF_BASE_SHA..HEAD
only:
refs:
- merge_requests
lint:mypy:
stage: π lint
image: ${PYTHON_DOCKER_IMAGE}
only:
refs:
- merge_requests
- master
changes:
- "pysfcgal/*.py"
- ".gitlab-ci.yml"
before_script:
- python -m pip install -U mypy types-cffi typing-extensions
script:
- mypy pysfcgal/
test:unit:
stage: π€ test
image: ${SFCGAL_REGISTRY}:debian-latest
only:
refs:
- merge_requests
- master
changes:
- "pysfcgal/*.py"
- "tests/*.py"
- ".gitlab-ci.yml"
before_script:
- apt install --no-install-recommends --yes python3 python3-pip python3-dev python3-venv gcc
- python3 -m venv venv
- source venv/bin/activate
- python3 -m pip install -U pytest pytest-cov
- pip install -e .
- python3 -m pip install icontract
script:
- pytest --junitxml=junit/test-results-unit.xml --cov pysfcgal --cov-report=xml:coverage-reports/coverage-unit.xml
artifacts:
when: always
reports:
coverage_report:
coverage_format: cobertura
path: coverage-reports/coverage-unit.xml
junit:
- junit/test-results-unit.xml
build:windows-osgeo4w-wheel:
stage: π¦ build
tags:
- saas-windows-medium-amd64
rules:
# on default branch
- if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
when: always
# on a tag
- if: $CI_COMMIT_TAG
when: always
# on a MR if previous jobs are successful
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
when: manual
allow_failure: true
artifacts:
paths:
- dist_windows
script:
# gitlab ci on widows does not handle the 'image' keyword
# use docker build to be able to pull sfcgal/sfcgal-build-deps image
- $env:dir = $pwd
- docker run
--rm
--mount type=bind,source=$env:dir,target=c:\pysfcgal
--workdir "c:\pysfcgal"
$env:SFCGAL_REGISTRY':'windows-latest
".\ci\build.ps1"
build:linux-wheel-python:
stage: π¦ build
image: docker:27.3
services:
- docker:27.3-dind
rules:
# on default branch
- if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
when: always
# on a tag
- if: $CI_COMMIT_TAG
when: always
# on a MR if previous jobs are successful
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
when: manual
allow_failure: true
variables:
SFCGAL_REGISTRY: registry.gitlab.com/sfcgal/sfcgal
parallel:
matrix:
- PYTHON_VERSION: ['3.9', '3.10', '3.11', '3.12']
script:
- docker build
--tag build_linux_wheel
--build-arg="SFCGAL_REGISTRY=${SFCGAL_REGISTRY}"
--build-arg="PYTHON_WHEEL_VERSION=${PYTHON_VERSION}"
-f "docker/Dockerfile_linux_wheel"
.
- CONTAINER_ID=$(docker run -d -t build_linux_wheel)
- docker cp ${CONTAINER_ID}:/dist_linux_${PYTHON_VERSION}/ ./
- docker stop ${CONTAINER_ID}
artifacts:
paths:
- dist_linux_$PYTHON_VERSION
deploy:pypi:
stage: π deploy
image: ${PYTHON_DOCKER_IMAGE}
rules:
# on a tag
- if: $CI_COMMIT_TAG
needs:
- job: build:windows-osgeo4w-wheel
artifacts: true
- job: build:linux-wheel-python
artifacts: true
before_script:
- pip install twine
script:
- mkdir dist
- cp -r dist_windows/* dist/
- cp -r dist_linux_*/* dist/
- twine upload --password ${PYPI_API_TOKEN} dist/*
build:documentation:
stage: π¦ build
image: ${PYTHON_DOCKER_IMAGE}
rules:
- if: '$CI_COMMIT_BRANCH == "master"'
when: always
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
changes:
- "pysfcgal/*.py"
- ".gitlab-ci.yml"
when: on_success
- when: never
before_script:
- python -m pip install -U pip
- python -m pip install -U -r requirements/documentation.txt
script:
- export PYTHONPATH=$(pwd)
- cd docs && mkdocs build --verbose --strict
artifacts:
name: documentation
expose_as: "built_documentation"
paths:
- docs/site
when: always
# -- DEPLOYMENT JOBS ------------
pages:
stage: π deploy
only:
refs:
- master
needs:
- job: build:documentation
artifacts: true
variables:
GIT_STRATEGY: none
script:
- mkdir -p public
- cp -rf docs/site/* public/
artifacts:
paths:
- public