-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
211 lines (201 loc) · 7.85 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
image: docker.uib.gmbh/opsi/dev/pybuilder:deb9-py3.11
stages:
- test
- build
- viruscheck
viruscheck:virustotal:
stage: viruscheck
tags:
- win10-py311-x86
script:
- Invoke-WebRequest -UseBasicParsing -Uri "$OPSIDEVTOOLS_URL_WINDOWS_X86" -OutFile opsi-dev-tools.zip
- Expand-Archive opsi-dev-tools.zip -DestinationPath .
- Copy-Item opsi-dev-tool.exe opsi-dev-cli.exe
- .\opsi-dev-cli.exe -l info --output-format summary virustotal check opsiclientd_windows_x86\opsiclientd.exe --allow-detections=5 > viruscheck.txt
artifacts:
name: "opsiclientd_viruscheck"
paths:
- viruscheck.txt
expire_in: 14 days
only:
- tags
except:
variables:
- $SKIP_TESTS
.run_opsiclientd: &run_opsiclientd |
mkdir -p /var/log/opsi-client-agent
mkdir -p /etc/opsi-client-agent
# cp opsiclientd_data/linux/opsiclientd.conf /etc/opsi-client-agent/opsiclientd.conf
# sed -i s'/url =.*/url = /' /etc/opsi-client-agent/opsiclientd.conf
# sed -i s'/host_id =.*/host_id = testclient.opsi.org/' /etc/opsi-client-agent/opsiclientd.conf
# sed -i s'/opsi_host_key =.*/opsi_host_key = opsiopsiopsiopsiopsiopsiopsiopsi/' /etc/opsi-client-agent/opsiclientd.conf
# sed -i s'#static_dir =.*#static_dir = opsiclientd_data/common/static_html#' /etc/opsi-client-agent/opsiclientd.conf
# openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes -keyout /etc/opsi-client-agent/opsiclientd.pem -out /etc/opsi-client-agent/opsiclientd.pem -subj "/CN=testclient.opsi.org"
mkdir -p /usr/share/opsi-client-agent/opsiclientd
cp -a opsiclientd_data/common/static_html /usr/share/opsi-client-agent/opsiclientd/static_html
poetry run opsiclientd --config-file=tests/data/opsiclientd.conf -l 1 &
test:pytest-darwin:
#when: manual
stage: test
tags:
- catalina-py311-x64
script:
- poetry --version
- poetry lock --no-update --no-cache
- poetry install
- poetry run pytest --tb=short -x -o junit_family=xunit2 --junitxml=testreport.xml --cov-config .coveragerc --cov opsiclientd --cov-report term --cov-report xml -v tests
- mv .coverage coverage_darwin
artifacts:
name: "opsiclientd_test_darwin"
paths:
- coverage.xml
- testreport.xml
- coverage_darwin
expire_in: 3 days
except:
variables:
- $SKIP_TESTS
test:pytest-windows:
#when: manual
stage: test
tags:
- win10-py311-x86
script:
- poetry lock --no-update --no-cache
- poetry install
- poetry run pytest --tb=short -x -o junit_family=xunit2 --junitxml=testreport.xml --cov-config .coveragerc --cov opsiclientd --cov-report term --cov-report xml -v tests
- Rename-Item -Path .coverage -NewName coverage_windows
artifacts:
name: "opsiclientd_test_windows"
paths:
- coverage.xml
- testreport.xml
- coverage_windows
expire_in: 3 days
except:
variables:
- $SKIP_TESTS
test:pytest-linux:
#when: manual
stage: test
script:
- poetry lock --no-update --no-cache
- poetry install
- *run_opsiclientd
- sleep 8
- poetry run pytest --tb=short -x -o junit_family=xunit2 --junitxml=testreport.xml --cov-config .coveragerc --cov opsiclientd --cov-report term --cov-report xml -v tests
- mv .coverage coverage_linux
artifacts:
name: "opsiclientd_test_linux"
paths:
- coverage.xml
- testreport.xml
- coverage_linux
expire_in: 3 days
except:
variables:
- $SKIP_TESTS
lint-pytest:
#when: manual
stage: test
needs:
# We want to combine test coverage from all test jobs
- job: test:pytest-windows
artifacts: true
- job: test:pytest-darwin
artifacts: true
- job: test:pytest-linux
artifacts: true
script:
- apt-get update
- apt-get --yes --allow-downgrades install libsqlite3-0=3.16.2-5+deb9u1
- apt-get --yes install sqlite3
- poetry lock --no-update --no-cache
- poetry install
- poetry run ruff check opsiclientd tests
- poetry run mypy opsiclientd tests
- for db in coverage_*; do sqlite3 $db 'update file set path=replace(substr(path,instr(path,"opsiclientd")+12),"\","/");'; done
- echo -e '[run]\nrelative_files = True\n' > .coveragerc
- poetry run coverage combine coverage_*
- poetry run coverage xml
- poetry run coverage report
coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+)%/'
artifacts:
name: "opsiclientd_test"
paths:
- coverage.xml
expire_in: 3 days
except:
variables:
- $SKIP_TESTS
build:pyinstaller-linux-x64:
stage: build
script:
- TRANSIFEX_MIN_REVIEW_RATE=0.0
- '[ "$CI_COMMIT_TAG" = "" ] || TRANSIFEX_MIN_REVIEW_RATE=1.0'
- curl -o opsi-dev-tools.tar.gz "$OPSIDEVTOOLS_URL_LINUX_X64"
- tar -xvf opsi-dev-tools.tar.gz
- mv opsi-dev-tool opsi-dev-cli
- poetry lock --no-update --no-cache
- poetry install
- poetry run ./opsi-dev-cli -l info pyinstaller build
- mv dist/opsiclientd opsiclientd_linux_x64
# Check if binary is working
- ./opsiclientd_linux_x64/opsiclientd --version
# Push to binaryindex
- '[ "$CI_COMMIT_TAG" = "" ] && ./opsi-dev-cli -l info binary push opsiclientd_linux_x64 --prerelease="$CI_JOB_ID"'
- '[ "$CI_COMMIT_TAG" = "" ] || ./opsi-dev-cli -l info binary push opsiclientd_linux_x64'
build:pyinstaller-darwin-x64:
stage: build
tags:
- catalina-py311-x64
script:
#- sed -ie s'/^python-opsi = .*/python-opsi = "^4.2"/' pyproject.toml
#- poetry update python-opsi
- TRANSIFEX_MIN_REVIEW_RATE=0.0
- '[ "$CI_COMMIT_TAG" = "" ] || TRANSIFEX_MIN_REVIEW_RATE=1.0'
- curl -o opsi-dev-tools.tar.gz "$OPSIDEVTOOLS_URL_DARWIN_X64"
- tar -xvf opsi-dev-tools.tar.gz
- mv opsi-dev-tool opsi-dev-cli
- poetry lock --no-update --no-cache
- poetry install
- poetry run ./opsi-dev-cli -l info pyinstaller build
- mv dist/opsiclientd opsiclientd_darwin_x64
# Check if binary is working
- ./opsiclientd_darwin_x64/opsiclientd --version
# Push to biaryindex
- '[ "$CI_COMMIT_TAG" = "" ] && ./opsi-dev-cli -l info binary push opsiclientd_darwin_x64 --prerelease="$CI_JOB_ID"'
- '[ "$CI_COMMIT_TAG" = "" ] || ./opsi-dev-cli -l info binary push opsiclientd_darwin_x64'
build:pyinstaller-windows-x86:
stage: build
tags:
- win10-py311-x86
script:
#- $env:path
#- where.exe poetry
#- (Invoke-WebRequest -Uri https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py -UseBasicParsing).Content | python -
#- Get-Content pyproject.toml | %{ $_ -Replace '"^python-opsi = .*"', 'python-opsi = "^4.2"' } | Out-File -Encoding ASCII "pyproject.tmp"
#- Move-Item -Path "pyproject.tmp" -Destination "pyproject.toml" -Force
#- Get-Content pyproject.toml
#- poetry update python-opsi
- $Env:TRANSIFEX_MIN_REVIEW_RATE="0.0"
- if ($CI_COMMIT_TAG) { $Env:TRANSIFEX_MIN_REVIEW_RATE="1.0" }
- Invoke-WebRequest -UseBasicParsing -Uri "$OPSIDEVTOOLS_URL_WINDOWS_X86" -OutFile opsi-dev-tools.zip
- Expand-Archive opsi-dev-tools.zip -DestinationPath .
- Copy-Item opsi-dev-tool.exe opsi-dev-cli.exe
- poetry lock --no-update --no-cache
- poetry install
- poetry run .\opsi-dev-cli.exe -l debug pyinstaller build
- .\opsi-dev-cli.exe -l info -l info signserver sign dist\opsiclientd\opsiclientd.exe
- .\opsi-dev-cli.exe -l info -l info signserver sign dist\opsiclientd\opsiclientd_rpc.exe
- .\opsi-dev-cli.exe -l info -l info signserver sign dist\opsiclientd\action_processor_starter.exe
- Move-Item -Path dist\opsiclientd -Destination opsiclientd_windows_x86
# Check if binary is working
- opsiclientd_windows_x86\opsiclientd.exe --version
# Push to biaryindex
- if (! $CI_COMMIT_TAG) {.\opsi-dev-cli.exe -l info binary push opsiclientd_windows_x86 --prerelease="$CI_JOB_ID"}
- if ($CI_COMMIT_TAG) {.\opsi-dev-cli.exe -l info binary push opsiclientd_windows_x86}
artifacts:
name: "opsiclientd_windows_x86"
paths:
- opsiclientd_windows_x86\opsiclientd.exe