-
Notifications
You must be signed in to change notification settings - Fork 151
/
.gitlab-ci.yml
278 lines (252 loc) · 6.44 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
variables:
PANDOC_BUILDER_IMAGE: glregistry.blockstream.io/satellite/satellite/blocksat-pandoc-builder
stages:
- test
- deploy
- docker
- pandoc
.pandoc_setup:
stage: pandoc
image: google/cloud-sdk
needs: []
tags:
- k8s
only:
refs:
- master
- web
- tags
.venv-install:
script:
- python3 -m venv .venv
- source .venv/bin/activate
- pip3 install setuptools
- make && make install
.docker_setup:
stage: docker
tags:
- k8s-docker
image: docker:20.10.12
services:
- docker:20.10.12-dind
variables:
DOCKER_DRIVER: overlay2
DOCKER_HOST: tcp://localhost:2375
DOCKER_TLS_CERTDIR: ""
BUILDX_URL: https://github.com/docker/buildx/releases/download/v0.11.2/buildx-v0.11.2.linux-amd64
DOCKER_PLUGINS_DIR: /usr/local/lib/docker/cli-plugins
needs: []
before_script:
- mkdir -p $DOCKER_PLUGINS_DIR
- wget -O $DOCKER_PLUGINS_DIR/docker-buildx $BUILDX_URL
- chmod +x $DOCKER_PLUGINS_DIR/docker-buildx
- apk add make python3 py3-setuptools py3-pip help2man gcc musl-dev python3-dev
- !reference [.venv-install, script]
- pip3 install shtab
- docker buildx create --use
.test:
stage: test
script:
- !reference [.venv-install, script]
- python -m unittest discover -b
# Exercise all imports triggered when launching the CLI
- blocksat-cli --version
unit-tests-py38:
extends: .test
image: python:3.8
unit-tests-py39:
extends: .test
image: python:3.9
unit-tests-py310:
extends: .test
image: python:3.10
unit-tests-py311:
extends: .test
image: python:3.11
unit-tests-py312:
extends: .test
image: python:3.12
bash-completion:
extends: .test
image: python:3.11
script:
- !reference [.venv-install, script]
- pip3 install shtab
- make completion
- git diff --exit-code blocksat-cli.bash-completion
manpage:
extends: .test
image: python:3.11
before_script:
- apt update && apt install -y help2man
script:
- !reference [.venv-install, script]
- make manpage
flake8-lint:
image: python:3.9
before_script:
- pip3 install flake8
script:
- flake8 .
yapf-format:
image: python:3.9
before_script:
- pip3 install yapf
script:
- yapf --diff --recursive --verbose .
test-make-install-apt:
image: $IMAGE
stage: test
only:
- tags
- web
before_script:
- |
apt update -y && apt install -y make \
python3 python3-setuptools python3-pip python3-venv
script:
- !reference [.venv-install, script]
parallel:
matrix:
- IMAGE:
["ubuntu:jammy", "ubuntu:noble", "debian:bullseye", "debian:bookworm"]
# TODO Remove the gcc/python3-devel installation when zfec ships py3.11 wheels
test-make-install-fedora:
image: $IMAGE
stage: test
only:
- tags
- web
before_script:
- dnf update -y && dnf install -y make python3 python3-setuptools python3-pip
- dnf install -y gcc python3-devel
script:
- !reference [.venv-install, script]
parallel:
matrix:
- IMAGE: ["fedora:39", "fedora:40"]
.test-dependencies:
stage: test
script:
- !reference [.venv-install, script]
- python3 -m unittest blocksatcli/verify_deps_instal.py
test-deb-dependencies:
image: $IMAGE
extends: .test-dependencies
only:
- tags
- web
before_script:
- |
apt update -y && apt install -y make \
python3 python3-setuptools python3-pip python3-venv
parallel:
matrix:
- IMAGE:
["ubuntu:jammy", "ubuntu:noble", "debian:bullseye", "debian:bookworm"]
test-fedora-dependencies:
image: $IMAGE
extends: .test-dependencies
only:
- tags
- web
before_script:
- dnf update -y && dnf install -y make python3 python3-setuptools python3-pip
- dnf install -y gcc python3-devel
parallel:
matrix:
- IMAGE: ["fedora:39", "fedora:40"]
pypi-upload:
image: python
stage: deploy
only:
refs:
- tags
when: manual
script:
- pip3 install twine
- make pypi
docker-build:
extends: .docker_setup
rules:
- if: $DOCKER_BUILD
script:
- make docker-buildx
docker-upload:
extends: .docker_setup
rules:
- if: $CI_COMMIT_TAG
- if: $DOCKER_UPLOAD
when: manual
script:
- echo $DOCKERHUB_PW | docker login -u $DOCKERHUB_USER --password-stdin
- make docker-buildx
- make docker-buildx-push
pandoc-docker-builder:
extends: .pandoc_setup
tags:
- k8s-docker
image: docker:20.10.12
services:
- docker:20.10.12-dind
variables:
DOCKER_DRIVER: overlay2
DOCKER_HOST: tcp://localhost:2375
DOCKER_TLS_CERTDIR: ""
needs: []
when: manual
script:
- cd doc/
- docker pull $PANDOC_BUILDER_IMAGE:latest || true
- >
docker build
-f pandoc_builder.docker
--network=host
--cache-from $PANDOC_BUILDER_IMAGE:latest
--build-arg BUILDKIT_INLINE_CACHE=1
-t $PANDOC_BUILDER_IMAGE:latest
.
- docker push $PANDOC_BUILDER_IMAGE:latest
pandoc:
extends: .pandoc_setup
image:
name: $PANDOC_BUILDER_IMAGE:latest
entrypoint: [""]
script:
- cd doc/ && python3 pandoc.py
artifacts:
paths:
- doc/blocksat_manual_*.pdf
pandoc-upload:
extends: .pandoc_setup
when: manual
needs: ["pandoc"]
variables:
POOL_ID: gitlab-2f4bb583
PROVIDER_ID: gitlab
SERVICE_ACCOUNT_EMAIL: [email protected]
id_tokens:
GITLAB_OIDC_TOKEN:
aud: https://gl.blockstream.io
script:
- echo ${GITLAB_OIDC_TOKEN} > .ci_job_jwt_file
- gcloud iam workload-identity-pools create-cred-config "projects/697214616889/locations/global/workloadIdentityPools/${POOL_ID}/providers/${PROVIDER_ID}"
--service-account="${SERVICE_ACCOUNT_EMAIL}"
--output-file=.gcp_temp_cred.json
--credential-source-file=.ci_job_jwt_file
- gcloud auth login --cred-file=.gcp_temp_cred.json --update-adc
- CLOUDSDK_AUTH_ACCESS_TOKEN=$(gcloud auth application-default print-access-token)
- echo "GOOGLE_OAUTH_ACCESS_TOKEN=$CLOUDSDK_AUTH_ACCESS_TOKEN" > vars.env
- cp doc/blocksat_manual_*.pdf doc/blocksat_manual.pdf
- gsutil cp doc/blocksat_manual*.pdf gs://blocksat-docs
check-markdown-links:
image:
name: ghcr.io/tcort/markdown-link-check:stable
entrypoint: [""]
only:
changes:
- "**/*.md"
script:
- >
echo '{"ignorePatterns": [{"pattern": "^https://help.blockstream.com"}, {"pattern": "^http://localhost:8000"}]}' > config.json
- find . -name \*.md | xargs -n1 /src/markdown-link-check -c config.json