-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
194 lines (171 loc) · 7.97 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
image: docker.uib.gmbh/opsi/dev/pybuilder:deb9-py3.13
variables:
CI_DEBUG_SERVICES: "false"
stages:
- test
- build
- publish
test:lint-and-test:
stage: test
tags:
- linux-docker-x64-hetzner
image: docker
before_script:
- TXT_HEAD="\e[46m\e[1;37m" && TXT_ERROR="\e[1;31m" && TXT_CLEAR="\e[0m"
# https://gitlab.com/gitlab-org/gitlab-foss/-/issues/41227
- CONTAINER_ID=$(docker ps -q -f "label=com.gitlab.gitlab-runner.job.id=$CI_JOB_ID" -f "label=com.gitlab.gitlab-runner.type=build")
- LOCAL_WORKSPACE_DIR=$(docker inspect $CONTAINER_ID -f "{{ range .Mounts }}{{ if eq .Destination \"/builds\" }}{{ .Source }}{{end}}{{end}}")/uib/opsiconfd/
- DOCKER_COMPOSE="docker compose -f docker/opsiconfd-dev/docker-compose.yml -p opsiconfd-test-$CI_JOB_ID"
- cp docker/opsiconfd-dev/common.env docker/opsiconfd-dev/.env
- echo "OPSILICSRV_TOKEN=${OPSILICSRV_TOKEN}" >> docker/opsiconfd-dev/.env
#- echo "LOCAL_WORKSPACE_DIR=../.." >> docker/opsiconfd-dev/.env
- echo "LOCAL_WORKSPACE_DIR=${LOCAL_WORKSPACE_DIR}" >> docker/opsiconfd-dev/.env
- echo "OPSISERVER_DEV_OPSICONFD_FORWARD_PORT=" >> docker/opsiconfd-dev/.env
- echo "OPSISERVER_CS_OPSICONFD_FORWARD_PORT=" >> docker/opsiconfd-dev/.env
- echo "DEV_USER=" >> docker/opsiconfd-dev/.env
- echo "DEV_UID=" >> docker/opsiconfd-dev/.env
- echo "BENCHER_HOST=${BENCHER_HOST}" >> docker/opsiconfd-dev/.env
- echo "BENCHER_API_TOKEN=${BENCHER_API_TOKEN}" >> docker/opsiconfd-dev/.env
- echo -e "${TXT_HEAD}Build docker images${TXT_CLEAR}"
- $DOCKER_COMPOSE build --pull
- rm -rf .venv
after_script:
- 'echo "CI_JOB_STATUS: $CI_JOB_STATUS"'
- TXT_HEAD="\e[46m\e[1;37m" && TXT_ERROR="\e[1;31m" && TXT_CLEAR="\e[0m"
- DOCKER_COMPOSE="docker compose -f docker/opsiconfd-dev/docker-compose.yml -p opsiconfd-test-$CI_JOB_ID"
- '[ "$CI_DEBUG_SERVICES" = "true" ] && $DOCKER_COMPOSE logs'
- $DOCKER_COMPOSE logs opsiserver43-dev
- $DOCKER_COMPOSE logs opsiserver43-cs
- echo -e "${TXT_HEAD}Stop docker containers${TXT_CLEAR}"
- $DOCKER_COMPOSE down -v
script:
- 'echo "CI_CONCURRENT_ID: $CI_CONCURRENT_ID"'
- echo -e "${TXT_HEAD}Fetch bencher${TXT_CLEAR}"
- wget -q https://github.com/bencherdev/bencher/releases/download/v0.4.2/bencher-v0.4.2-linux-x86-64 -O bencher
- chmod +x bencher
- echo -e "${TXT_HEAD}Prepare docker containers${TXT_CLEAR}"
- $DOCKER_COMPOSE up --detach --wait --wait-timeout 120
- echo -e "${TXT_HEAD}Run linters${TXT_CLEAR}"
- $DOCKER_COMPOSE exec opsiserver43-dev poetry run ruff check opsiconfd tests perftest
- $DOCKER_COMPOSE exec opsiserver43-dev poetry run mypy opsiconfd tests perftest
- echo -e "${TXT_HEAD}Run pytest${TXT_CLEAR}"
- $DOCKER_COMPOSE exec opsiserver43-dev poetry run pytest -x --tb=short -o junit_family=xunit2 --junitxml=testreport.xml --cov-append --cov opsiconfd --cov-report term --cov-report xml -v tests
- echo -e "${TXT_HEAD}Run perftests${TXT_CLEAR}"
- $DOCKER_COMPOSE exec opsiserver43-dev poetry run opsiconfd -c tests/data/default-opsiconfd.conf --workers=1 --log-level-file=5 --log-file=opsiconfd-perftest.log --max-session-per-ip=20000 &
- sleep 10
- echo -e "${TXT_HEAD}Run opsiconfd-perftest${TXT_CLEAR}"
# Average request time has to be faster than 10 ms
- |
$DOCKER_COMPOSE exec opsiserver43-dev poetry run ./perftest/opsiconfd-perftest.py -l perftest/tests/test_session_loading.json --max-errors 0 --max-avg-seconds-per-request 0.01 --bencher-results bencher-results.json || (
echo -e "${TXT_ERROR}opsiconfd-perftest.py failed${TXT_CLEAR}"
cat opsiconfd-perftest.log
exit 1
)
- echo -e "${TXT_HEAD}Run opsiconfd-backend-perftest${TXT_CLEAR}"
- |
$DOCKER_COMPOSE exec opsiserver43-dev poetry run ./perftest/opsiconfd-backend-perftest.py --products 100 --clients 100 --iterations 5 --max-real 30000 || (
echo -e "${TXT_ERROR}opsiconfd-backend-perftest.py failed${TXT_CLEAR}"
cat opsiconfd-perftest.log
exit 1
)
- echo -e "${TXT_HEAD}Run file-download memory test${TXT_CLEAR}"
- |
$DOCKER_COMPOSE exec opsiserver43-dev poetry run python ./perftest/file-download.py --clients=5 --file-size=500 --min-download-time=20 --memory-usage-limit 20 || (
echo -e "${TXT_ERROR}file-download.py failed${TXT_CLEAR}"
cat opsiconfd-perftest.log
exit 1
)
- |
$DOCKER_COMPOSE exec opsiserver43-dev poetry run python ./perftest/file-download.py --clients=10 --file-size=200 --min-download-time=20 --memory-usage-limit 20 --range-requests || (
echo -e "${TXT_ERROR}file-download.py failed (range-requests)${TXT_CLEAR}"
cat opsiconfd-perftest.log
exit 1
)
- echo -e "${TXT_HEAD}Run messagebus websocket load test${TXT_CLEAR}"
- |
$DOCKER_COMPOSE exec opsiserver43-dev poetry run ./perftest/messagebus-clients.py --clients 1000 --event-interval 30 --start-gap 20 || (
echo -e "${TXT_ERROR}messagebus-clients.py failed${TXT_CLEAR}"
cat opsiconfd-perftest.log
exit 1
)
- echo -e "${TXT_HEAD}Run opsiconfd get-config duration test${TXT_CLEAR}"
- |
$DOCKER_COMPOSE exec opsiserver43-dev poetry run ./perftest/bencher-command.py -r bencher-results.json -m opsiconfd-get-config-duration -x 1.0 -i 6 poetry run opsiconfd get-config || (
echo -e "${TXT_ERROR}bencher-command.py failed${TXT_CLEAR}"
exit 1
)
# Bencher server currently not working
# - $DOCKER_COMPOSE exec opsiserver43-dev ./bencher run --project opsiconfd --if-branch "$CI_COMMIT_REF_NAME" --else-if-branch "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" --else-if-branch main --err --adapter json --file bencher-results.json
coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+)%/'
artifacts:
name: 'opsiconfd_test'
paths:
- coverage.xml
expire_in: 3 days
reports:
coverage_report:
coverage_format: cobertura
path: coverage.xml
build:linux-pyinstaller:
stage: build
tags:
- linux-docker-x64-hetzner
script:
- TRANSIFEX_MIN_REVIEW_RATE=0.0
- '[ "$CI_COMMIT_TAG" = "" ] || TRANSIFEX_MIN_REVIEW_RATE=1.0'
- opsi-dev-cli self upgrade
- poetry install
- poetry run opsi-dev-cli -l debug pyinstaller build
- mv opsiconfd opsiconfd.src
- mv dist/opsiconfd ./opsiconfd-amd64
# Check if binary is working
- ./opsiconfd-amd64/opsiconfd -c opsiconfd_data/etc/opsiconfd.conf --version
artifacts:
name: 'opsiconfd-linux-pyinstaller'
paths:
- opsiconfd-amd64
expire_in: 2 day
build:arm64-pyinstaller:
stage: build
tags:
- linux-arm64
script:
- TRANSIFEX_MIN_REVIEW_RATE=0.0
- '[ "$CI_COMMIT_TAG" = "" ] || TRANSIFEX_MIN_REVIEW_RATE=1.0'
- opsi-dev-cli self upgrade
- poetry install
- poetry run opsi-dev-cli -l debug pyinstaller build
- mv opsiconfd opsiconfd.src
- mv dist/opsiconfd ./opsiconfd-arm64
# Check if binary is working
- OPSI_HOSTNAME=test.uib.local ./opsiconfd-arm64/opsiconfd -c opsiconfd_data/etc/opsiconfd.conf --version
artifacts:
name: 'opsiconfd-arm64-pyinstaller'
paths:
- opsiconfd-arm64
expire_in: 2 day
#publish:obs_int:
# stage: publish
# dependencies:
# - build:linux-pyinstaller
# - build:arm64-pyinstaller
# script:
# - *install_tools
# - opsi-dev-tool -l info --obs-update-package https://obs.uib.gmbh home:uibmz:opsi:4.3:development
# only:
# - tags
publish:obs_ext:
stage: publish
tags:
- linux-docker-x64-hetzner
dependencies:
- build:linux-pyinstaller
- build:arm64-pyinstaller
script:
- opsi-dev-cli self upgrade --system
- opsi-dev-cli -l info packaging obs update-package https://build.opensuse.org home:uibmz:opsi:4.3:development
- opsi-dev-cli -l info changelog from-git output
- opsi-dev-cli release-service register-package-version opsiconfd SERVER_PACKAGE --changelog-file output/changelog.md
- opsi-dev-cli release-service push-repository-state opsiconfd SERVER_PACKAGE SERVER_PACKAGE-4.3-development
only:
- tags