-
Notifications
You must be signed in to change notification settings - Fork 6
488 lines (442 loc) · 17.3 KB
/
centreon-collect.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
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
name: Centreon collect
run-name: |
${{
(github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && github.event.inputs.is_nightly == 'true'))
&& format('collect nightly {0}', github.ref_name)
|| ''
}}
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
on:
workflow_dispatch:
inputs:
is_nightly:
description: 'Set to true for nightly run'
required: true
default: false
type: boolean
legacy_engine:
description: 'Compile Engine with legacy configuration library'
required: true
default: false
type: boolean
packages_in_artifact:
description: 'Save packages in artifacts'
required: true
default: false
type: boolean
unit_tests:
description: 'Execute the unit tests'
required: true
default: true
type: boolean
schedule:
- cron: '30 0 * * 1-5'
pull_request:
paths:
- agent/**
- bbdo/**
- broker/**
- ccc/**
- clib/**
- connectors/**
- custom-triplets/**
- engine/**
- grpc/**
- packaging/**
- cmake.sh
- cmake-vcpkg.sh
- CMakeLists.txt
- CMakeListsLinux.txt
- vcpkg.json
- overlays/**
- selinux/**
- "!.veracode-exclusions"
- "!veracode.json"
- "!**/test/**"
push:
branches:
- develop
- dev-[2-9][0-9].[0-9][0-9].x
- master
- "[2-9][0-9].[0-9][0-9].x"
paths:
- agent/**
- bbdo/**
- broker/**
- ccc/**
- clib/**
- connectors/**
- custom-triplets/**
- engine/**
- grpc/**
- packaging/**
- cmake.sh
- cmake-vcpkg.sh
- CMakeLists.txt
- CMakeListsLinux.txt
- vcpkg.json
- overlays/**
- selinux/**
- "!.veracode-exclusions"
- "!veracode.json"
- "!**/test/**"
jobs:
dispatch-to-maintained-branches:
if: ${{ github.run_attempt == 1 && github.event_name == 'schedule' && github.ref_name == 'develop' }}
runs-on: ubuntu-24.04
steps:
- name: Checkout sources
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Check current day of the week
id: day_check
run: echo "day_of_week=$(date +%u)" >> $GITHUB_OUTPUT
shell: bash
- if: ${{ steps.day_check.outputs.day_of_week == '1' }}
run: |
NIGHTLY_TARGETS=("dev-22.10.x" "dev-23.04.x" "dev-23.10.x" "dev-24.04.x" "dev-24.10.x")
for target in "${NIGHTLY_TARGETS[@]}"; do
echo "[INFO] - Dispatching nightly run to $target branch."
gh workflow run centreon-collect.yml -r "$target" -f is_nightly=true
done
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
get-environment:
uses: ./.github/workflows/get-environment.yml
with:
version_file: CMakeLists.txt
veracode-analysis:
needs: [get-environment]
if: ${{ github.event_name == 'schedule' && github.ref_name == 'develop' }}
uses: ./.github/workflows/veracode-analysis.yml
with:
module_name: centreon-collect
major_version: ${{ needs.get-environment.outputs.major_version }}
minor_version: ${{ needs.get-environment.outputs.minor_version }}
img_version: ${{ needs.get-environment.outputs.img_version }}
secrets:
veracode_api_id: ${{ secrets.VERACODE_API_ID_COLL }}
veracode_api_key: ${{ secrets.VERACODE_API_KEY_COLL }}
veracode_srcclr_token: ${{ secrets.VERACODE_SRCCLR_TOKEN }}
docker_registry_id: ${{ secrets.HARBOR_CENTREON_PULL_USERNAME }}
docker_registry_passwd: ${{ secrets.HARBOR_CENTREON_PULL_TOKEN }}
unit-test:
needs: [get-environment]
if: ${{ github.event.inputs.unit_tests == 'true' && ! contains(fromJson('["stable"]'), needs.get-environment.outputs.stability) }}
strategy:
fail-fast: false
matrix:
distrib: [alma8, alma9, debian-bookworm]
runs-on: [self-hosted, collect]
env:
SCCACHE_PATH: "/usr/bin/sccache"
SCCACHE_BUCKET: "centreon-github-sccache"
SCCACHE_REGION: "eu-west-1"
AWS_ACCESS_KEY_ID: ${{ secrets.COLLECT_S3_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.COLLECT_S3_SECRET_KEY }}
LEGACY_ENGINE: ${{ github.event.inputs.legacy_engine != 'true' && 'OFF' || 'ON' }}
container:
image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/centreon-collect-${{ matrix.distrib }}:${{ needs.get-environment.outputs.img_version }}
credentials:
username: ${{ secrets.HARBOR_CENTREON_PULL_USERNAME }}
password: ${{ secrets.HARBOR_CENTREON_PULL_TOKEN }}
name: unit test ${{ matrix.distrib }}
steps:
- name: Checkout sources
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Install sccache
run: |
if ! command -v wget &> /dev/null; then
if [[ "${{ matrix.distrib }}" == "alma8" || "${{ matrix.distrib }}" == "alma9" ]]; then
dnf install -y wget
else
apt-get update
apt-get install -y wget
fi
fi
wget https://github.com/mozilla/sccache/releases/download/v0.8.1/sccache-v0.8.1-x86_64-unknown-linux-musl.tar.gz
tar xzf sccache-v0.8.1-x86_64-unknown-linux-musl.tar.gz
mv sccache-v0.8.1-x86_64-unknown-linux-musl/sccache /usr/bin/
${SCCACHE_PATH} --start-server
shell: bash
- name: Compile centreon-collect
run: |
CMAKE="cmake"
if [[ "${{ matrix.distrib }}" == "alma8" || "${{ matrix.distrib }}" == "alma9" ]]; then
CMAKE="cmake3"
fi
export VCPKG_ROOT=/vcpkg
export PATH=$VCPKG_ROOT:$PATH
mv /root/.cache /github/home/
CXXFLAGS="-Wall -Wextra" $CMAKE \
-B build \
-DVCPKG_OVERLAY_TRIPLETS=/custom-triplets \
-DVCPKG_TARGET_TRIPLET=x64-linux-release \
-DVCPKG_OVERLAY_PORTS=/overlays \
-GNinja \
-DDEBUG_ROBOT=OFF \
-DCMAKE_EXPORT_COMPILE_COMMANDS=On \
-DCMAKE_BUILD_TYPE=Debug \
-DWITH_PREFIX=/usr \
-DWITH_PREFIX_BIN=/usr/sbin \
-DWITH_USER_BROKER=centreon-broker \
-DWITH_USER_ENGINE=centreon-engine \
-DWITH_GROUP_BROKER=centreon-broker \
-DWITH_GROUP_ENGINE=centreon-engine \
-DWITH_TESTING=On \
-DWITH_PREFIX_MODULES=/usr/share/centreon/lib/centreon-broker \
-DWITH_PREFIX_CONF_BROKER=/etc/centreon-broker \
-DWITH_PREFIX_LIB_BROKER=/usr/lib64/nagios \
-DWITH_PREFIX_CONF_ENGINE=/etc/centreon-engine \
-DWITH_PREFIX_LIB_ENGINE=/usr/lib64/centreon-engine \
-DWITH_PREFIX_LIB_CLIB=/usr/lib64/ \
-DWITH_RW_DIR=/var/lib/centreon-engine/rw \
-DWITH_VAR_DIR=/var/log/centreon-engine \
-DWITH_MODULE_SIMU=On \
-DCMAKE_C_COMPILER_LAUNCHER=${SCCACHE_PATH} \
-DCMAKE_CXX_COMPILER_LAUNCHER=${SCCACHE_PATH} \
-DLEGACY_ENGINE=${LEGACY_ENGINE} \
-S .
ninja -Cbuild
ninja -Cbuild install
shell: bash
- name: Cache statistics
run: ${SCCACHE_PATH} --show-stats
shell: bash
- name: Stop sccache server
run: ${SCCACHE_PATH} --stop-server
shell: bash
- name: Run unit tests
run: |
tests/ut_broker --gtest_output=xml:ut_broker.xml
tests/ut_engine --gtest_output=xml:ut_engine.xml
tests/ut_clib --gtest_output=xml:ut_clib.xml
tests/ut_connector --gtest_output=xml:ut_connector.xml
tests/ut_common --gtest_output=xml:ut_common.xml
tests/ut_agent --gtest_output=xml:ut_agent.xml
working-directory: build
shell: bash
package:
needs: [get-environment]
if: ${{ ! contains(fromJson('["stable"]'), needs.get-environment.outputs.stability) }}
strategy:
fail-fast: false
matrix:
include:
- image: centreon-collect-alma8
distrib: el8
package_extension: rpm
runner: collect
arch: amd64
- image: centreon-collect-alma9
distrib: el9
package_extension: rpm
runner: collect
arch: amd64
- image: centreon-collect-debian-bookworm
distrib: bookworm
package_extension: deb
runner: collect
arch: amd64
- image: centreon-collect-ubuntu-jammy
distrib: jammy
package_extension: deb
runner: collect
arch: amd64
- image: centreon-collect-debian-bookworm-arm64
distrib: bookworm
package_extension: deb
runner: collect-arm64
arch: arm64
uses: ./.github/workflows/package-collect.yml
with:
major_version: ${{ needs.get-environment.outputs.major_version }}
minor_version: ${{ needs.get-environment.outputs.minor_version }}
img_version: ${{ needs.get-environment.outputs.img_version }}
release: ${{ needs.get-environment.outputs.release }}
commit_hash: ${{ github.sha }}
stability: ${{ needs.get-environment.outputs.stability }}
legacy_engine: ${{ github.event.inputs.legacy_engine != 'true' && 'OFF' || 'ON' }}
packages_in_artifact: ${{ github.event.inputs.packages_in_artifact == 'true' }}
image: ${{ matrix.image }}
distrib: ${{ matrix.distrib }}
package_extension: ${{ matrix.package_extension }}
runner: ${{ matrix.runner }}
arch: ${{ matrix.arch }}
secrets: inherit
robot-test:
needs: [get-environment, package]
if: |
(github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && github.event.inputs.is_nightly == 'true')) &&
! cancelled() &&
! contains(needs.*.result, 'failure') &&
! contains(needs.*.result, 'cancelled')
strategy:
fail-fast: false
matrix:
include:
- distrib: el9
image: centreon-collect-alma9-test
package_extension: rpm
arch: amd64
database_type: mariadb
test_group_name: robot_test-mariadb-el9-amd64
tests_params: '{}'
- distrib: el9
image: centreon-collect-mysql-alma9-test
package_extension: rpm
arch: amd64
database_type: mysql
test_group_name: robot_test-mysql-el9-amd64
tests_params: '{}'
- distrib: bookworm
image: centreon-collect-debian-bookworm-arm64-test
package_extension: deb
arch: arm64
database_type: mariadb
test_group_name: robot_test-mariadb-bookworm-arm64
tests_params: '{}'
- distrib: bookworm
image: centreon-collect-debian-bookworm-test
package_extension: deb
arch: amd64
database_type: mariadb
test_group_name: robot_test-mariadb-bookworm-amd64
tests_params: '{}'
- distrib: el9
image: centreon-collect-alma9-test
package_extension: rpm
arch: amd64
database_type: mariadb
test_group_name: robot_test-mariadb-el9-amd64-grpc
tests_params: '{"default_transport":"grpc","default_bbdo_version":"3.1.0"}'
name: ${{ matrix.test_group_name }}
uses: ./.github/workflows/robot-test.yml
with:
distrib: ${{ matrix.distrib }}
arch: ${{ matrix.arch }}
image: ${{ matrix.image }}
image_test: ${{ matrix.image }}:${{ needs.get-environment.outputs.test_img_version }}
image_version: ${{ needs.get-environment.outputs.img_version }}
package_cache_key: ${{ github.run_id }}-${{ github.sha }}-${{ matrix.package_extension }}-centreon-collect-${{ matrix.distrib }}-${{ matrix.arch }}-${{ github.head_ref || github.ref_name }}
package_cache_path: ./*.${{ matrix.package_extension}}
database_type: ${{ matrix.database_type }}
tests_params: ${{matrix.tests_params}}
test_group_name: ${{matrix.test_group_name}}
secrets:
registry_username: ${{ secrets.HARBOR_CENTREON_PULL_USERNAME }}
registry_password: ${{ secrets.HARBOR_CENTREON_PULL_TOKEN }}
collect_s3_access_key: ${{ secrets.COLLECT_S3_ACCESS_KEY }}
collect_s3_secret_key: ${{ secrets.COLLECT_S3_SECRET_KEY }}
xray_client_id: ${{ secrets.XRAY_CLIENT_ID }}
xray_client_secret: ${{ secrets.XRAY_CLIENT_SECRET }}
deliver-sources:
runs-on: [self-hosted, common]
needs: [get-environment, package]
if: |
github.event_name != 'workflow_dispatch' &&
contains(fromJson('["stable"]'), needs.get-environment.outputs.stability) &&
! cancelled() &&
! contains(needs.*.result, 'failure') &&
! contains(needs.*.result, 'cancelled')
steps:
- name: Checkout sources
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
with:
path: centreon-collect
- name: Deliver sources
uses: ./centreon-collect/.github/actions/release-sources
with:
bucket_directory: centreon-collect
module_directory: centreon-collect
module_name: centreon-collect
major_version: ${{ needs.get-environment.outputs.major_version }}
minor_version: ${{ needs.get-environment.outputs.minor_version }}
token_download_centreon_com: ${{ secrets.TOKEN_DOWNLOAD_CENTREON_COM }}
deliver-rpm:
if: |
contains(fromJson('["unstable", "testing"]'), needs.get-environment.outputs.stability) &&
! cancelled() &&
! contains(needs.*.result, 'failure') &&
! contains(needs.*.result, 'cancelled')
needs: [get-environment, robot-test]
runs-on: [self-hosted, common]
strategy:
matrix:
include:
- distrib: el8
arch: amd64
- distrib: el9
arch: amd64
name: deliver ${{ matrix.distrib }}
steps:
- name: Checkout sources
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Publish RPM packages
uses: ./.github/actions/delivery
with:
module_name: collect
distrib: ${{ matrix.distrib }}
major_version: ${{ needs.get-environment.outputs.major_version }}
artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }}
cache_key: ${{ github.run_id }}-${{ github.sha }}-rpm-centreon-collect-${{ matrix.distrib }}-${{ matrix.arch }}-${{ github.head_ref || github.ref_name }}
stability: ${{ needs.get-environment.outputs.stability }}
release_type: ${{ needs.get-environment.outputs.release_type }}
is_cloud: ${{ needs.get-environment.outputs.is_cloud }}
deliver-deb:
if: |
contains(fromJson('["unstable", "testing"]'), needs.get-environment.outputs.stability) &&
! cancelled() &&
! contains(needs.*.result, 'failure') &&
! contains(needs.*.result, 'cancelled')
needs: [get-environment, robot-test]
runs-on: [self-hosted, common]
strategy:
matrix:
include:
- distrib: bookworm
arch: amd64
- distrib: jammy
arch: amd64
name: deliver ${{ matrix.distrib }}
steps:
- name: Checkout sources
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Publish DEB packages
uses: ./.github/actions/delivery
with:
module_name: collect
distrib: ${{ matrix.distrib }}
major_version: ${{ needs.get-environment.outputs.major_version }}
artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }}
cache_key: ${{ github.run_id }}-${{ github.sha }}-deb-centreon-collect-${{ matrix.distrib }}-${{ matrix.arch }}-${{ github.head_ref || github.ref_name }}
stability: ${{ needs.get-environment.outputs.stability }}
release_type: ${{ needs.get-environment.outputs.release_type }}
is_cloud: ${{ needs.get-environment.outputs.is_cloud }}
promote:
needs: [get-environment, deliver-rpm, deliver-deb]
if: |
(contains(fromJson('["stable", "testing"]'), needs.get-environment.outputs.stability) && github.event_name != 'workflow_dispatch') &&
! cancelled() &&
! contains(needs.*.result, 'failure') &&
! contains(needs.*.result, 'cancelled')
runs-on: [self-hosted, common]
strategy:
matrix:
distrib: [el8, el9, bookworm, jammy]
steps:
- name: Checkout sources
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Promote ${{ matrix.distrib }} to stable
uses: ./.github/actions/promote-to-stable
with:
artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }}
module_name: collect
distrib: ${{ matrix.distrib }}
major_version: ${{ needs.get-environment.outputs.major_version }}
stability: ${{ needs.get-environment.outputs.stability }}
github_ref_name: ${{ github.ref_name }}
release_type: ${{ needs.get-environment.outputs.release_type }}
is_cloud: ${{ needs.get-environment.outputs.is_cloud }}