-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
229 lines (205 loc) · 5.83 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
stages:
- test
- prepare
- deploy
variables:
POETRY_CACHE_DIR: "$CI_PROJECT_DIR/.cache"
DOCKER_IMAGE: registry.opengeosys.org/ogs/tools/ogstools/devcontainer-3.10
DOCKER_USER_IMAGE: registry.opengeosys.org/ogs/tools/ogstools/main-3.10
ARTIFACTS_PAGES_URL: https://$CI_PROJECT_ROOT_NAMESPACE.$CI_PAGES_DOMAIN/-/$SUBGROUP_SLUG$CI_PROJECT_NAME/-/jobs/$CI_JOB_ID/artifacts
workflow:
rules:
- if: $CI_MERGE_REQUEST_IID
changes:
- .devcontainer/*
variables:
DOCKER_IMAGE: $CI_REGISTRY_IMAGE/devcontainer-3.10:$CI_COMMIT_REF_SLUG
- if: $CI_MERGE_REQUEST_IID
- if: $CI_COMMIT_TAG
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PROJECT_PATH == "ogs/tools/ogstools"'
image: $DOCKER_IMAGE
cache:
paths:
- .cache
.setup-headless: &setup-headless
- make setup
- make setup_headless
- source .venv/bin/activate
pre-commit:
tags: [shell, envinf]
rules:
- if: $CI_MERGE_REQUEST_IID
needs: []
script:
- git fetch origin ${CI_MERGE_REQUEST_DIFF_BASE_SHA}
- pre-commit run --from-ref ${CI_MERGE_REQUEST_DIFF_BASE_SHA} --to-ref HEAD
build:
script:
- pip install build
- pyproject-build
tests (arch):
tags: [shell, envinf]
needs: []
script:
- *setup-headless
- make test
tests (arch - ogs custom latest):
tags: [shell, envinf]
when: manual
needs: []
script:
- make setup_with_ogs_custom_latest
- *setup-headless
- make test
tests:
script:
- make setup_devcontainer
- source .venv-devcontainer/bin/activate
- make coverage
coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
artifacts:
when: always
paths:
- htmlcov
reports:
coverage_report:
coverage_format: cobertura
path: coverage.xml
environment:
name: code coverage $CI_MERGE_REQUEST_IID
url: ${ARTIFACTS_PAGES_URL}/htmlcov/index.html
tests win:
tags: [windows]
when: manual
needs: []
before_script:
- python -m venv .venv
- .venv\Scripts\Activate.ps1
- pip install -e ".[dev,test,docs]"
script:
- pytest
# Remove -j 1 when this is resolved:
# https://github.com/pydata/pydata-sphinx-theme/issues/1643
.docs-script: &docs-script
- make setup_devcontainer
- source .venv-devcontainer/bin/activate
- make docs SPHINXOPTS="-W --keep-going -n -j 4"
- mv docs/_build/html public
docs preview:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
script:
- *docs-script
artifacts:
paths:
- public
environment:
name: docs preview $CI_MERGE_REQUEST_IID $CI_PROJECT_ROOT_NAMESPACE
url: "${ARTIFACTS_PAGES_URL}/public/index.html"
pages:
stage: deploy
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
image: registry.opengeosys.org/ogs/tools/feflow-python-docker:8.0.1
script:
- *docs-script
artifacts:
paths:
- public
environment: production
pages-tag:
stage: prepare
rules:
- if: $CI_COMMIT_TAG
image: registry.opengeosys.org/ogs/tools/feflow-python-docker:8.0.1
script:
- *docs-script
artifacts:
paths:
- public
deploy-pages-tag:
stage: deploy
rules:
- if: $CI_COMMIT_TAG
needs: [pages-tag]
variables:
GIT_STRATEGY: none
script:
- rm -rf ogstools-docs
- git config --global user.name "GitLab CI"
- git config --global user.email "[email protected]"
- git clone https://${CI_SERVER_HOST}/ogs/tools/ogstools-docs.git
- cd ogstools-docs
- mv ../public $CI_COMMIT_TAG
- git add $CI_COMMIT_TAG
- >
jq 'map(if has("preferred") then del(.preferred) else . end) + [{"version": env.PARENT_PIPELINE_TAG,"url": "https://ogstools.opengeosys.org/\($ENV.PARENT_PIPELINE_TAG)/","preferred": true}]' _static/versions.json > versions.tmp
- mv versions.tmp _static/versions.json
- git add _static/versions.json
- rm stable && ln -s $CI_COMMIT_TAG stable && git add stable
- git commit -m "Release $CI_COMMIT_TAG"
- git push "https://${CI_COMMITTER_USER_AND_TOKEN}@${CI_SERVER_HOST}/ogs/tools/ogstools-docs.git" HEAD:main
publish:
rules:
- if: $CI_COMMIT_TAG
when: manual
variables:
TWINE_REPOSITORY: pypi
PYTHON_KEYRING_BACKEND: keyring.backends.null.Keyring
script:
- pip install build twine
- pyproject-build
- twine upload dist/*
devcontainer image:
stage: .pre
tags:
- envinf
- shell
rules:
- changes:
- .devcontainer/*
# - when: manual # uncomment if required, otherwise jobs are skipped
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- devcontainer build --workspace-folder . --push true --image-name ${DOCKER_IMAGE}
user container image:
stage: .pre
needs: []
tags:
- envinf
- shell
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- if: $CI_COMMIT_TAG
variables:
DOCKER_USER_IMAGE: registry.opengeosys.org/ogs/tools/ogstools/main-3.10:$CI_COMMIT_TAG
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build -t $DOCKER_USER_IMAGE .
- docker push $DOCKER_USER_IMAGE
code_quality_ruff:
image: python:3.10-slim
needs: []
script:
# Use same ruff as in .pre-commit-config.yaml
- pip install ruff==0.0.277
- ruff . --format gitlab > ruff-code-quality-report.json || true
artifacts:
reports:
codequality: ruff-code-quality-report.json
code_quality_mypy:
image: python:3.10-slim
needs: []
script:
# Use same mypy as in .pre-commit-config.yaml
- pip install mypy==1.4.1 mypy-to-codeclimate
- mypy ogstools > mypy-output.txt || true
- mypy-to-codeclimate mypy-output.txt mypy-code-quality-report.json || true
artifacts:
reports:
codequality: mypy-code-quality-report.json
ogs/tools/feflow-converter-tests:
stage: test
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
trigger: ogs/tools/feflow-converter-tests