forked from waldur/waldur-mastermind
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
316 lines (298 loc) · 11.2 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
310
311
312
313
314
315
316
include:
- project: "waldur/waldur-pipelines"
file: "/templates/stages.yml"
- project: "waldur/waldur-pipelines"
file: "/templates/test/check-merge-compatibility.yml"
- project: "waldur/waldur-pipelines"
file: "/templates/release/publish.yml"
- project: "waldur/waldur-pipelines"
file: "/templates/validate/docker-compose-trigger.yml"
- project: "waldur/waldur-pipelines"
file: "/templates/test/lint-docker-image.yaml"
- project: "waldur/waldur-pipelines"
file: "/templates/test/lint-dockerfile.yaml"
- project: "waldur/waldur-pipelines"
file: "/templates/test/lint-md-files.yml"
- project: "waldur/waldur-pipelines"
file: "/templates/deploy/dev-env-update.yml"
- project: "waldur/waldur-pipelines"
file: "/templates/sbom/generate-python-codebase-sbom.yml"
- project: "waldur/waldur-pipelines"
file: "/templates/sbom/upload-sboms-to-docs.yml"
- project: "waldur/waldur-pipelines"
file: "/templates/sbom/generate-image-sbom.yml"
before_script:
- export
Run linters:
image: registry.hpc.ut.ee/mirror/library/python:3.11-bullseye
stage: test
interruptible: true
rules:
# Skip tests if said so
- if: '$SKIP_TESTS == "true" || $SKIP_TESTS == "yes"'
when: never
- if: '$CI_COMMIT_BRANCH == "develop"'
# If tagged release
- if: '$CI_COMMIT_TAG =~ /^\d+\.\d+\.\d+$/'
# If event is related to a created merge request
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
script:
- pip install pre-commit
- pre-commit run --all
.Unit test runner:
image: registry.hpc.ut.ee/mirror/$WALDUR_MASTERMIND_TEST_IMAGE
stage: test
interruptible: true
rules:
# Skip tests if said so
- if: '$SKIP_TESTS == "true" || $SKIP_TESTS == "yes"'
when: never
- if: '$CI_COMMIT_BRANCH == "develop"'
# If tagged release
- if: '$CI_COMMIT_TAG =~ /^\d+\.\d+\.\d+$/'
# If event is related to a created merge request
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
changes:
- src/**/*
- pyproject.toml
- poetry.lock
- gitlab-ci-test/**/*
services:
- name: "registry.hpc.ut.ee/mirror/library/postgres:15-alpine"
alias: postgres
command:
[
"postgres",
"-cfsync=off",
"-cfull_page_writes=off",
"-cmax_connections=1000",
"-cshared_buffers=1GB",
"-ceffective_cache_size=4GB",
"-cwork_mem=32MB",
"-cmaintenance_work_mem=32MB",
"-ctemp_buffers=16MB",
"-cwal_buffers=48MB",
]
variables:
POSTGRES_DB: test_waldur
POSTGRES_USER: runner
POSTGRES_PASSWORD: waldur
Run unit tests:
extends: .Unit test runner
script:
- |
# Check merge compatibility only it is not a tagged release
if [ "$CI_PIPELINE_SOURCE" == "merge_request_event" ]; then
echo "[+] Add dummy user $GIT_USER_NAME ($GIT_USER_EMAIL)"
git config user.name $GIT_USER_NAME
git config user.email $GIT_USER_EMAIL
echo "[+] Merging branches $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME and origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME"
git merge --no-ff origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
fi
- gitlab-ci-test/waldur-test
- coverage xml
- coverage report
coverage: "/TOTAL.+ ([0-9]{1,3}%)/"
artifacts:
when: always
reports:
junit: report.xml
coverage_report:
coverage_format: cobertura
path: coverage.xml
parallel: 10
Run migration test:
extends: .Unit test runner
script:
- gitlab-ci-test/waldur-test MIGRATIONS
Try building docker image:
image:
name: "gcr.io/kaniko-project/executor:debug"
entrypoint: [""]
stage: test
interruptible: true
rules:
# Skip tests if said so
- if: '$SKIP_TESTS == "true" || $SKIP_TESTS == "yes"'
when: never
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
changes:
- Dockerfile
- docker/**/*
# TODO: drop after testing
- .gitlab-ci.yml
variables:
DOCKER_REGISTRY: registry.hpc.ut.ee/mirror/
script:
- /kaniko/executor
--context "${CI_PROJECT_DIR}"
--dockerfile "${CI_PROJECT_DIR}/Dockerfile"
--build-arg DOCKER_REGISTRY=$DOCKER_REGISTRY
--destination "waldur-mastermind:$CI_COMMIT_REF_SLUG"
--no-push
Generate Image SBOM:
extends: .Generate Image SBOM template
variables:
PROJECT_NAME: "waldur-mastermind"
Generate Codebase SBOM:
extends: .Generate Codebase SBOM template
variables:
PROJECT_NAME: "waldur-mastermind"
before_script:
- apt-get update
- apt-get install -y gcc libldap2-dev libsasl2-dev libssl-dev libdb-dev
Build docker image for tests:
stage: build
interruptible: true
image:
name: "gcr.io/kaniko-project/executor:debug"
entrypoint: [ "" ]
rules:
# If scheduled pipeline for 'develop' branch is set up
- if: '$CI_COMMIT_BRANCH == "develop" && $CI_PIPELINE_SOURCE == "schedule"'
variables:
DOCKER_REGISTRY: registry.hpc.ut.ee/mirror/
script:
- echo $CI_COMMIT_SHA > docker/rootfs/COMMIT
- cat docker/rootfs/COMMIT
- AUTH=$(echo -n "${WALDUR_DOCKER_HUB_USER}:${WALDUR_DOCKER_HUB_PASSWORD}" | base64)
- |
cat << EOF > /kaniko/.docker/config.json
{
"auths": {
"https://index.docker.io/v1/": {
"auth": "${AUTH}"
}
}
}
EOF
- /kaniko/executor
--context "${CI_PROJECT_DIR}"
--dockerfile "${CI_PROJECT_DIR}/gitlab-ci-test/Dockerfile"
--build-arg DOCKER_REGISTRY=$DOCKER_REGISTRY
--destination "$WALDUR_MASTERMIND_TEST_IMAGE"
Publish latest docker image:
before_script:
- echo '[+] Build and publish latest docker image'
- echo $CI_COMMIT_SHA > docker/rootfs/COMMIT_SHA
Publish docker image with specific version:
before_script:
- echo "[+] Build and publish $CI_COMMIT_TAG docker image"
- echo $CI_COMMIT_TAG > docker/rootfs/COMMIT_TAG
- sed -i "s/version = \"0.0.0\"/version = \"$CI_COMMIT_TAG\"/" pyproject.toml
Lint docker image:
extends: .Lint docker image template
variables:
IMAGE: opennode/waldur-mastermind:latest
Lint dockerfile:
extends: .Lint dockerfile template
variables:
DOCKERFILE: Dockerfile
HADOLINT_CONFIG: |
ignored:
- DL3003 # "WORKDIR" warning
- DL3008 # "versions for `apt install`" warning
- DL3015 # "--no-install-recommends" info
- SC2094 # "read and write the same file in the same pipeline" info
Upload Image SBOM:
extends: .Upload SBOM template
needs:
- Generate Image SBOM
variables:
PROJECT_NAME: "waldur-mastermind"
SBOM_TYPE: "image"
SBOM_DIR: "images"
Upload Source SBOM:
extends: .Upload SBOM template
needs:
- Generate Codebase SBOM
variables:
PROJECT_NAME: "waldur-mastermind"
SBOM_TYPE: "source"
SBOM_DIR: "source"
Upload configuration guide:
stage: deploy
interruptible: true
rules:
- if: '$CI_COMMIT_BRANCH == "develop" && $CI_PIPELINE_SOURCE == "schedule"'
image: registry.hpc.ut.ee/mirror/$WALDUR_MASTERMIND_TEST_IMAGE
variables:
CONF_GUIDE_PATH: docs/admin-guide/mastermind-configuration/configuration-guide.md
CLI_GUIDE_PATH: docs/admin-guide/mastermind-configuration/cli-guide.md
FEATURES_GUIDE_PATH: docs/admin-guide/mastermind-configuration/features.md
NOTIFICATIONS_GUIDE_PATH: docs/admin-guide/mastermind-configuration/notifications.md
TEMPLATES_LIST_PATH: docs/admin-guide/mastermind-configuration/templates.md
DEVELOPER_DOCS_PATH: docs/developer-guide
DJANGO_SETTINGS_MODULE: waldur_core.server.doc_settings
script:
- poetry install
- cd /tmp/
- git clone "https://gitlab-ci-token:$GITLAB_TOKEN@$CI_SERVER_HOST/waldur/waldur-docs.git"
- git config --global user.name "$GITLAB_USER_NAME"
- git config --global user.email "$GITLAB_USER_EMAIL"
- cd waldur-docs
- waldur print_settings > $CONF_GUIDE_PATH
- waldur print_features_docs > $FEATURES_GUIDE_PATH
- waldur print_notifications > $NOTIFICATIONS_GUIDE_PATH
- waldur print_commands > $CLI_GUIDE_PATH
- waldur print_events > $CI_PROJECT_DIR/docs/events.md
- waldur print_templates > $TEMPLATES_LIST_PATH
- waldur graph_models structure -I Customer,Project,OrganizationGroup,OrganizationGroupType,ProjectType,User -o $DEVELOPER_DOCS_PATH/core_structure.png
- waldur graph_models permissions -I User,Role,UserRole,RolePermission -o $DEVELOPER_DOCS_PATH/core_permissions.png
- waldur graph_models marketplace -I CategoryGroup,Category,CategoryColumn,Section,Attribute,AttributeOption,CategoryComponent,CategoryComponentUsage,Offering,OfferingComponent,Plan,PlanComponent,Resource,Order -o $DEVELOPER_DOCS_PATH/marketplace.png
- cp -rv $CI_PROJECT_DIR/docs/* $DEVELOPER_DOCS_PATH
- git add $CONF_GUIDE_PATH $FEATURES_GUIDE_PATH $CLI_GUIDE_PATH $DEVELOPER_DOCS_PATH $TEMPLATES_LIST_PATH $NOTIFICATIONS_GUIDE_PATH
- git commit -m "Update configuration, CLI and developer guide" || exit 0
- git branch new-configuration-guide
- git push --set-upstream origin new-configuration-guide:master
before_script: []
Upload HomePort enums:
stage: deploy
interruptible: true
rules:
- if: '$CI_COMMIT_BRANCH == "develop" && $CI_PIPELINE_SOURCE == "schedule"'
image: registry.hpc.ut.ee/mirror/$WALDUR_MASTERMIND_TEST_IMAGE
variables:
PERMISSIONS_ENUM_PATH: src/permissions/enums.ts
EVENTS_ENUM_PATH: src/EventsEnums.ts
FEATURES_ENUM_PATH: src/FeaturesEnums.ts
FEATURES_DESCRIPTION_PATH: src/features/FeaturesDescription.ts
PERMISSION_OPTIONS_PATH: src/administration/roles/PermissionOptions.tsx
SETTINGS_DESCRIPTION_PATH: src/SettingsDescription.ts
DJANGO_SETTINGS_MODULE: waldur_core.server.doc_settings
script:
- poetry install
- cd src/waldur_core/permissions
- python print_permission_enums.py > /tmp/permission_enums.ts
- waldur print_events_enums > /tmp/events_enums.ts
- waldur print_features_enums > /tmp/features_enums.ts
- waldur print_features_description > /tmp/features_description.ts
- waldur print_settings_description > /tmp/settings_description.ts
- waldur print_permissions_description > /tmp/permission_options.ts
- cd /tmp/
- git clone "https://homeport-updates:$HOMEPORT_ACCESS_TOKEN@$CI_SERVER_HOST/waldur/waldur-homeport.git"
- git config --global user.name "$GITLAB_USER_NAME"
- git config --global user.email "$GITLAB_USER_EMAIL"
- cd waldur-homeport
- git checkout develop
- mv /tmp/permission_enums.ts $PERMISSIONS_ENUM_PATH
- mv /tmp/events_enums.ts $EVENTS_ENUM_PATH
- mv /tmp/features_enums.ts $FEATURES_ENUM_PATH
- mv /tmp/features_description.ts $FEATURES_DESCRIPTION_PATH
- mv /tmp/settings_description.ts $SETTINGS_DESCRIPTION_PATH
- mv /tmp/permission_options.ts $PERMISSION_OPTIONS_PATH
- git add $PERMISSIONS_ENUM_PATH
- git add $EVENTS_ENUM_PATH
- git add $FEATURES_ENUM_PATH
- git add $FEATURES_DESCRIPTION_PATH
- git add $SETTINGS_DESCRIPTION_PATH
- git add $PERMISSION_OPTIONS_PATH
- git commit -m "Update enums" || exit 0
- git branch new-enums
- git push --set-upstream origin new-enums:develop
before_script: []
Lint MD links:
before_script:
- touch docs/core_structure.png
- touch docs/core_permissions.png
- touch docs/marketplace.png