-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
269 lines (249 loc) · 8.03 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
variables:
VER_PYTHON: "3.10"
VER_CUDA: "11.8.0"
VER_TORCH: "2.3.0"
IMAGE_NAME: $DOCKER_REGISTRY/users/$USER/${CI_PROJECT_NAME}-py${VER_PYTHON}
IMAGE_TAG: $CI_COMMIT_SHORT_SHA
OLDER_THAN: "1d" # Cleanup docker images older 1 day
FF_USE_FASTZIP: "true"
CACHE_COMPRESSION_LEVEL: "fastest"
ARTIFACT_COMPRESSION_LEVEL: "fastest"
DOCKER_BUILDKIT: 1
BUILDKIT_PROGRESS: plain
stages:
- docker
- build
- test
- docs
- release
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
when: never
- if: $CI_COMMIT_BRANCH || $CI_COMMIT_TAG
before_script:
- command -v git && git config --local url.$CI_SERVER_URL/thirdparty.insteadOf https://github.com/ || true
.cache:
variables:
CONDA_PKGS_DIRS: $CI_PROJECT_DIR/.cache/pkgs
PIP_CACHE_DIR: $CI_PROJECT_DIR/.cache/pip
CCACHE_BASEDIR: $CI_BUILDS_DIR
CCACHE_DIR: $CI_PROJECT_DIR/.ccache
before_script:
- ccache --zero-stats || true
after_script:
- ccache --show-stats || true
cache:
key: ${VER_CUDA}
paths:
- $CI_PROJECT_DIR/.cache/
- $CCACHE_DIR
.matrix:
variables:
parallel: &matrix
matrix:
- VER_PYTHON: &ver_python
- "3.10"
- "3.11"
VER_CUDA: &ver_cuda
- "11.8.0"
VER_TORCH: &ver_torch
- "2.3.0"
.verify: # All inheretance jobs must have a name which verify could use as an argument
stage: test
tags:
- docker
extends:
- .cache
rules:
- if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH && $VER_PYTHON == "3.11"
when: never
- when: always
image:
name: ${IMAGE_NAME}:${IMAGE_TAG}
entrypoint: [""]
needs: ["docker"]
variables:
ARGS: ""
before_script:
- $CONDA_PREFIX/bin/conda run --name $CONDA_DEFAULT_ENV --live-stream python3 -m pip install -e ".[dev]"
script:
- $CONDA_PREFIX/bin/conda run --name $CONDA_DEFAULT_ENV --live-stream ./scripts/verify --$CI_JOB_NAME -- $ARGS
docker:
stage: docker
tags:
- shell
script:
- make build
- make push
wheels:
extends:
- .cache
stage: build
tags:
- docker
image:
name: ${IMAGE_NAME}:${IMAGE_TAG}
entrypoint: [""]
artifacts:
expire_in: "1d"
when: always
paths:
- "dist/fastforward-*.whl"
script:
- ${CONDA_PREFIX}/bin/conda run --name ${CONDA_DEFAULT_ENV} --live-stream python3 -m build --verbose --no-isolation --wheel --outdir=dist/ ${CI_PROJECT_DIR}
pytest:
extends:
- .cache
stage: test
tags:
- docker
parallel:
matrix:
- VER_PYTHON: *ver_python
VER_CUDA: *ver_cuda
VER_TORCH: *ver_torch
image: python:${VER_PYTHON}
rules:
- if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH && $VER_PYTHON == "3.11"
when: never
- when: always
artifacts:
expire_in: "1h"
when: always
reports:
junit: reports/py${VER_PYTHON}-cu${VER_CUDA}-pt${VER_TORCH}.xml
before_script:
# Cuda version consists of 3 numbers although we need only the first two: "11.7.1" -> "11.7"
- export VER_CUDA_SHORT="$(echo $VER_CUDA | awk -F'.' '{print $1$2}')"
- python3 -m pip install torch==${VER_TORCH}+cu${VER_CUDA_SHORT} nvidia-cuda-runtime-cu${VER_CUDA%%.*}~=${VER_CUDA} nvidia-cudnn --extra-index-url="https://pypi.ngc.nvidia.com" --extra-index-url="https://download.pytorch.org/whl/cu${VER_CUDA_SHORT}"
script:
- python3 -m pip install "$(find dist -name 'fastforward-*.whl')[test]"
- python3 -m torch.utils.collect_env
- python3 -m pytest $PYTEST_EXTRA_ARGS ./tests --junitxml=reports/py${VER_PYTHON}-cu${VER_CUDA}-pt${VER_TORCH}.xml
mypy:
extends:
- .verify
variables:
ARGS: "--junit-xml reports-mypy.xml"
shell-check:
extends:
- .verify
format:
extends:
- .verify
variables:
ARGS: "--check"
lint:
extends:
- .verify
markers-check:
extends:
- .verify
.docs:
stage: docs
tags:
- docker
cache: {}
dependencies: []
environment:
name: docs/$CI_COMMIT_REF_SLUG
url: $CI_PAGES_URL/$CI_COMMIT_REF_SLUG
image:
name: ${IMAGE_NAME}:${IMAGE_TAG}
entrypoint: [""]
artifacts:
paths:
- $PAGES_PREFIX
variables:
PAGES_BRANCH: "pages"
PAGES_REMOTE: "https://gitlab-ci-token:${GL_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git"
PAGES_PREFIX: public
DOCS_VERSION: "$CI_COMMIT_REF_NAME"
# Use a resource group to prevent running multiple jobs simultaneously because job do pull&push
resource_group: docs
before_script:
# The `$PAGES_BRANCH` branch keeps doocumentation for different version. An inherited job might
# add a new version or delete obsolete one. When a job deleting an old docs version, there is no
# git branch any more. Thus, such job has to set `GIT_STRATEGY` to `none`. In that case all
# manupulation with git should be done manually. Thus before job the following steps are done:
# - init git repo
# - config user (mkdocs would generate new commits)
# - fetch the latest changes from `$PAGES_BRANCH` branch.
# And after each job:
# - checkout from the `$PAGES_BRANCH` branch the `$PAGES_PREFIX` folder which would be
# uploaded to gitlab
- git init --quiet
- git config --local user.name bot
- git config --local user.email bot
- git fetch --prune --prune-tags --force $PAGES_REMOTE $PAGES_BRANCH:refs/remotes/fetch/$PAGES_BRANCH
- git branch --force $PAGES_BRANCH fetch/$PAGES_BRANCH
- rm -rf $PAGES_PREFIX
after_script:
- git log -n 5 $PAGES_BRANCH
- git checkout $PAGES_BRANCH -- $PAGES_PREFIX
- git branch -D $PAGES_BRANCH
- ls -la $PAGES_PREFIX
pages:
extends: [.docs]
dependencies: [wheels]
environment:
on_stop: delete_revieved_docs
# must be in sync with delete_revieved_docs
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- if: $CI_COMMIT_BRANCH =~ /^docs/
- if: $CI_COMMIT_TAG
script:
- >
${CONDA_PREFIX}/bin/conda run --name ${CONDA_DEFAULT_ENV} --live-stream bash -c "
set -ex ;
python3 -m pip install $(find dist -name 'fastforward-*.whl')[docs] ;
mike deploy --config-file mkdocs.yml --update-aliases --deploy-prefix $PAGES_PREFIX --branch $PAGES_BRANCH --remote $PAGES_REMOTE --push $CI_COMMIT_REF_NAME $([ \"$CI_COMMIT_TAG\" != \"\" ] && echo "latest");
mike set-default --deploy-prefix $PAGES_PREFIX --branch $PAGES_BRANCH --remote $PAGES_REMOTE --push latest ;
git show --stat $PAGES_BRANCH ;
"
delete_revieved_docs:
extends: [.docs]
variables:
GIT_STRATEGY: none
environment:
action: stop
# must be in sync with pages
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
when: manual
- if: $CI_COMMIT_BRANCH =~ /^docs/
when: manual
- if: $CI_COMMIT_TAG
when: manual
script:
- >
${CONDA_PREFIX}/bin/conda run --name ${CONDA_DEFAULT_ENV} --live-stream bash -c "
set -ex ;
if [[ \"$CI_COMMIT_BRANCH\" != \"$CI_DEFAULT_BRANCH\" ]] ;
then
mike delete --deploy-prefix $PAGES_PREFIX --branch $PAGES_BRANCH --remote $PAGES_REMOTE --push $CI_COMMIT_REF_NAME ;
fi ;
"
# - git checkout --force $PAGES_BRANCH
# - git pull --unshallow docs
# # `2 i exec git commit --quiet --amend --message \"...\"` -> insert a command to chage a commit massage to \"...\"
# # `2,$ s/pick/fixup/` -> squash all commits execpt the first one to the first commit ignoring commit message
# - GIT_SEQUENCE_EDITOR='sed -i -e "2 i exec git commit --quiet --amend --message \"Update docs\"" -e "2,$ s/pick/fixup/"' git rebase -i --root --autostash
# - git push --force-with-lease docs $PAGES_BRANCH
release:
stage: release
tags:
- shell
rules:
- if: $CI_COMMIT_TAG
script:
- find dist -name "fastforward-*.whl" | xargs -i twine upload --non-interactive --disable-progress-bar {}
include:
# A cleanup script to delete Docker images older than 2 weeks.
# For more information: https://morpheus-gitlab.qualcomm.com/emironov/cleanup-artifactory
# e.g., if you want to customize the behaviour or update the Docker tags format.
- project: emironov/cleanup-artifactory
file: /cleanup.yml