-
Notifications
You must be signed in to change notification settings - Fork 302
569 lines (514 loc) · 21.5 KB
/
plugins.yml
File metadata and controls
569 lines (514 loc) · 21.5 KB
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
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
name: plugins
run-name: ${{ (github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && github.event.inputs.nightly_manual_trigger == 'true')) && format('plugins nightly {0}', github.ref_name) || '' }}
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
on:
workflow_dispatch:
inputs:
nightly_manual_trigger:
description: 'Set to true to trigger a nightly run'
required: true
default: false
type: boolean
schedule:
- cron: "30 1 * * 1"
pull_request:
paths:
- '.github/workflows/plugins.yml'
- '.github/workflows/plugins-robot-tests.yml'
- '.github/scripts/list-plugins-to-build-and-test.py'
- '.github/scripts/prepare-package-plugins.sh'
- '.github/scripts/fatpack-plugins.pl'
- '.github/scripts/test-plugins.py'
- '.github/packaging/centreon-plugin.yaml.template'
- 'src/**'
- 'packaging/**'
- 'tests/**'
push:
branches:
- develop
- master
paths:
- '.github/workflows/plugins.yml'
- '.github/workflows/plugins-robot-tests.yml'
- '.github/scripts/list-plugins-to-build-and-test.py'
- '.github/scripts/prepare-package-plugins.sh'
- '.github/scripts/fatpack-plugins.pl'
- '.github/scripts/test-plugins.py'
- '.github/packaging/centreon-plugin.yaml.template'
- 'src/**'
- 'packaging/**'
- 'tests/**'
env:
max_testing_jobs: 25
jobs:
dependency-scan:
uses: centreon/security-tools/.github/workflows/dependency-analysis.yml@main
get-environment:
needs: [dependency-scan]
uses: ./.github/workflows/get-environment.yml
with:
nightly_manual_trigger: ${{ inputs.nightly_manual_trigger || false }}
changes:
needs: [get-environment]
runs-on: ubuntu-24.04
outputs:
changes_common: ${{ steps.filter.outputs.common || 'true' }}
changes_packages: ${{ steps.filter.outputs.packages || 'false' }}
changes_plugins: ${{ steps.filter.outputs.plugins || 'false' }}
changes_tests: ${{ steps.filter.outputs.tests || 'false' }}
packages_files: ${{ steps.filter.outputs.packages_files }}
plugins_files: ${{ steps.filter.outputs.plugins_files }}
tests_files: ${{ steps.filter.outputs.tests_files }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
id: filter
if: |
github.event_name == 'pull_request' &&
contains(fromJson('["testing", "unstable", "canary"]'), needs.get-environment.outputs.stability)
with:
base: ${{ github.head_ref || github.ref_name }}
list-files: shell
filters: |
common:
- added|deleted|modified: src/centreon/**
- modified: .github/packaging/centreon-plugin.yaml.template
packages:
- added|modified: packaging/**
plugins:
- added|modified: src/**
tests:
- added|modified: tests/**
get-plugins:
runs-on: ubuntu-24.04
needs: [get-environment, changes]
outputs:
package_plugins: ${{ steps.get_plugins.outputs.package_plugins || 'false' }}
test_plugins: ${{ steps.get_plugins.outputs.test_plugins || 'false' }}
index_matrix: ${{ steps.get_plugins.outputs.index_matrix }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: '3.13'
- name: Get new or updated directories
env:
PACKAGES_FILES: ${{ needs.changes.outputs.packages_files }}
PLUGINS_FILES: ${{ needs.changes.outputs.plugins_files }}
TESTS_FILES: ${{ needs.changes.outputs.tests_files }}
run: |
packages_folders=()
for package_file in $PACKAGES_FILES; do
echo "Adding $(dirname $package_file) to packages_folders"
packages_folders+=($(dirname $package_file))
done
unique_packages_folders=($(printf "%s\n" "${packages_folders[@]}" | sort -u | tr '\n' ' '))
jq --compact-output --null-input '$ARGS.positional' --args -- ${unique_packages_folders[@]} > packages_directories.json
plugins_folders=()
for plugin_file in $PLUGINS_FILES; do
echo "Adding $plugin_file to plugins_folders"
plugin_folder=$(dirname $plugin_file)
while [[ $plugin_folder =~ /(components|conf|custom|lib|mode|templates)$ ]]; do
plugin_folder=$(dirname $plugin_folder)
done
plugins_folders+=($plugin_folder)
done
unique_plugins_folders=($(printf "%s\n" "${plugins_folders[@]}" | sort -u | tr '\n' ' '))
jq --compact-output --null-input '$ARGS.positional' --args -- ${unique_plugins_folders[@]} > plugins_directories.json
tests_folders=()
for test_file in $TESTS_FILES; do
echo "Adding $test_file to tests_folders"
tests_folders+=($(dirname $test_file))
done
unique_tests_folders=($(printf "%s\n" "${tests_folders[@]}" | sort -u | tr '\n' ' '))
jq --compact-output --null-input '$ARGS.positional' --args -- ${unique_tests_folders[@]} > tests_directories.json
shell: bash
- name: Get plugins to build and/or test
id: get_plugins
if: ${{ needs.changes.outputs.changes_common == 'true' || needs.changes.outputs.changes_packages == 'true' || needs.changes.outputs.changes_plugins == 'true' || needs.changes.outputs.changes_tests == 'true' }}
env:
CHANGES_COMMON: ${{ needs.changes.outputs.changes_common == 'true' }}
MAX_RUNNERS: ${{ env.max_testing_jobs }}
run: |
list_plugins=($(python3 .github/scripts/list-plugins-to-build-and-test.py --common="$CHANGES_COMMON" --max_runners="$MAX_RUNNERS"))
echo "package_plugins=$(echo ${list_plugins[0]})" >> $GITHUB_OUTPUT
echo "test_plugins=$(echo ${list_plugins[1]})" >> $GITHUB_OUTPUT
runners_ids=( $(seq 1 ${list_plugins[2]}) )
echo "index_matrix=$(jq -cn '$ARGS.positional' --args "${runners_ids[@]}")" >> $GITHUB_OUTPUT
if [ ! -s plugins.json ]; then
echo "::notice::There are no modifications to the plugins packages"
fi
shell: bash
- uses: actions/cache/save@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: ./plugins.json
key: plugins-${{ github.sha }}-${{ github.run_id }}
# Add to your PR the label upload-artifacts to get plugin.json as artifact
- if: ${{ contains(github.event.pull_request.labels.*.name, 'upload-artifacts') }}
name: Upload plugins.json artifacts
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: plugins_json
path: ./plugins.json
retention-days: 1
unit-tests:
needs: [get-environment, get-plugins]
if: |
needs.get-environment.outputs.skip_workflow == 'false' &&
needs.get-environment.outputs.stability != 'stable' &&
! cancelled() &&
! contains(needs.*.result, 'failure') &&
! contains(needs.*.result, 'cancelled')
strategy:
fail-fast: false
max-parallel: 3
matrix:
image: [unit-tests-alma8, unit-tests-alma9, unit-tests-alma10, unit-tests-bullseye, unit-tests-bullseye-arm64, unit-tests-bookworm, unit-tests-trixie, unit-tests-jammy, unit-tests-noble]
include:
- runner_name: ubuntu-24.04
- package_extension: rpm
image: unit-tests-alma8
distrib: el8
- package_extension: rpm
image: unit-tests-alma9
distrib: el9
- package_extension: rpm
image: unit-tests-alma10
distrib: el10
- package_extension: deb
image: unit-tests-bullseye
distrib: bullseye
- package_extension: deb
image: unit-tests-bullseye-arm64
runner_name: ubuntu-24.04-arm
distrib: bullseye
- package_extension: deb
image: unit-tests-bookworm
distrib: bookworm
- package_extension: deb
image: unit-tests-trixie
distrib: trixie
- package_extension: deb
image: unit-tests-jammy
distrib: jammy
- package_extension: deb
image: unit-tests-noble
distrib: noble
runs-on: ${{ matrix.runner_name }}
container:
image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ matrix.image }}
credentials:
username: ${{ secrets.HARBOR_CENTREON_PULL_USERNAME }}
password: ${{ secrets.HARBOR_CENTREON_PULL_TOKEN }}
name: "Unit tests on ${{ matrix.distrib }}"
steps:
- name: Checkout sources
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Run unit tests
uses: ./.github/actions/unit-tests
- name: Upload logs as artifacts if tests failed
if: failure()
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: plugin-installation-${{ matrix.distrib }}-${{ matrix.runner_name }}
path: ./lastlog.jsonl
retention-days: 1
fatpacker:
needs: [get-environment, get-plugins, unit-tests]
if: |
needs.get-environment.outputs.skip_workflow == 'false' &&
needs.get-plugins.outputs.package_plugins == 'True' &&
! cancelled() &&
! contains(needs.*.result, 'failure') &&
! contains(needs.*.result, 'cancelled')
runs-on: ubuntu-24.04
steps:
- name: Checkout sources
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: ./plugins.json
key: plugins-${{ github.sha }}-${{ github.run_id }}
fail-on-cache-miss: true
- name: Prepare FatPacker
uses: shogo82148/actions-setup-perl@b6cfc127f1b0a63ac98797800f641494d80f42f8 # v1.37.1
with:
perl-version: '5.34'
install-modules-with: cpm
install-modules: App::FatPacker File::Copy::Recursive JSON
- name: Run FatPacker
env:
VERSION: ${{ needs.get-environment.outputs.version }}
run: |
COMMIT=$(git log -1 HEAD --pretty=format:%h)
perl .github/scripts/fatpack-plugins.pl "$(jq -r 'to_entries[] | select(.value.build == true) | .key' plugins.json | tr '\n' ' ')" "$VERSION ($COMMIT)"
- uses: actions/cache/save@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: ./build/
key: fatpacked-plugins-${{ github.sha }}-${{ github.run_id }}
package:
runs-on: ubuntu-24.04
needs: [get-environment, get-plugins, fatpacker]
if: |
needs.get-environment.outputs.skip_workflow == 'false' &&
needs.get-plugins.outputs.package_plugins == 'True' &&
needs.get-environment.outputs.stability != 'stable' &&
! cancelled() &&
! contains(needs.*.result, 'failure') &&
! contains(needs.*.result, 'cancelled')
strategy:
fail-fast: false
max-parallel: 5
matrix:
include:
- package_extension: rpm
image: packaging-plugins-alma8
distrib: el8
- package_extension: rpm
image: packaging-plugins-alma9
distrib: el9
- package_extension: rpm
image: packaging-plugins-alma10
distrib: el10
- package_extension: deb
image: packaging-plugins-bullseye
distrib: bullseye
- package_extension: deb
image: packaging-plugins-bookworm
distrib: bookworm
- package_extension: deb
image: packaging-plugins-trixie
distrib: trixie
- package_extension: deb
image: packaging-plugins-jammy
distrib: jammy
- package_extension: deb
image: packaging-plugins-noble
distrib: noble
container:
image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ matrix.image }}
credentials:
username: ${{ secrets.HARBOR_CENTREON_PULL_USERNAME }}
password: ${{ secrets.HARBOR_CENTREON_PULL_TOKEN }}
name: "Package ${{ matrix.distrib }}"
steps:
- name: Checkout sources
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: ./build/
key: fatpacked-plugins-${{ github.sha }}-${{ github.run_id }}
fail-on-cache-miss: true
- uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: ./plugins.json
key: plugins-${{ github.sha }}-${{ github.run_id }}
fail-on-cache-miss: true
- env:
PACKAGE_EXTENSION: ${{ matrix.package_extension }}
DISTRIB: ${{ matrix.distrib }}
run: |
.github/scripts/prepare-package-plugins.sh "plugins.json" "$PACKAGE_EXTENSION" "$DISTRIB"
shell: bash
- uses: ./.github/actions/package-nfpm
with:
nfpm_file_pattern: ".github/packaging/*.yaml"
distrib: ${{ matrix.distrib }}
package_extension: ${{ matrix.package_extension }}
version: ${{ needs.get-environment.outputs.version }}
release: ${{ needs.get-environment.outputs.release }}
commit_hash: ${{ github.sha }}
cache_key: ${{ github.sha }}-${{ github.run_id }}-${{ matrix.package_extension }}-${{ matrix.distrib }}
rpm_gpg_key: ${{ secrets.RPM_GPG_SIGNING_KEY }}
rpm_gpg_signing_key_id: ${{ secrets.RPM_GPG_SIGNING_KEY_ID }}
rpm_gpg_signing_passphrase: ${{ secrets.RPM_GPG_SIGNING_PASSPHRASE }}
stability: ${{ needs.get-environment.outputs.stability }}
test-plugins:
needs: [get-environment, get-plugins, package]
if: |
always() &&
needs.get-environment.outputs.skip_workflow == 'false' &&
needs.get-plugins.outputs.test_plugins == 'True' &&
needs.get-environment.outputs.stability != 'stable' &&
(needs.package.result == 'success' || needs.package.result == 'skipped') &&
! cancelled() &&
! contains(needs.*.result, 'failure') &&
! contains(needs.*.result, 'cancelled')
strategy:
fail-fast: false
matrix:
image: [testing-plugins-alma8, testing-plugins-alma9, testing-plugins-alma10, testing-plugins-jammy, testing-plugins-bullseye, testing-plugins-bookworm, testing-plugins-trixie, testing-plugins-noble, testing-plugins-bullseye-arm64]
include:
- skip_robot_tests: false
- package_extension: rpm
image: testing-plugins-alma8
distrib: el8
arch: amd64
- package_extension: rpm
image: testing-plugins-alma9
distrib: el9
arch: amd64
- package_extension: rpm
image: testing-plugins-alma10
distrib: el10
arch: amd64
skip_robot_tests: true
- package_extension: deb
image: testing-plugins-bullseye
distrib: bullseye
arch: amd64
- package_extension: deb
image: testing-plugins-bookworm
distrib: bookworm
arch: amd64
- package_extension: deb
image: testing-plugins-trixie
distrib: trixie
arch: amd64
skip_robot_tests: true
- package_extension: deb
image: testing-plugins-jammy
distrib: jammy
arch: amd64
- package_extension: deb
image: testing-plugins-noble
distrib: noble
arch: amd64
- package_extension: deb
image: testing-plugins-bullseye-arm64
distrib: bullseye
arch: arm64
name: "test-plugins ${{ matrix.distrib }} ${{ matrix.arch }}"
uses: ./.github/workflows/plugins-robot-tests.yml
with:
image: ${{ matrix.image }}
indexes: ${{ needs.get-plugins.outputs.index_matrix }}
distrib: ${{ matrix.distrib }}
arch: ${{ matrix.arch }}
get-packages: ${{ needs.get-plugins.outputs.package_plugins }}
package-extension: ${{ matrix.package_extension }}
packages-cache-key: ${{ github.sha }}-${{ github.run_id }}-${{ matrix.package_extension }}-${{ matrix.distrib }}
plugins-json-cache-key: plugins-${{ github.sha }}-${{ github.run_id }}
skip-robot-tests: ${{ matrix.skip_robot_tests }}
exclude-robot-tags: centreon-generic-snmp
secrets:
registry_username: ${{ secrets.HARBOR_CENTREON_PULL_USERNAME }}
registry_password: ${{ secrets.HARBOR_CENTREON_PULL_TOKEN }}
deliver-packages:
needs: [get-environment, get-plugins, test-plugins]
if: |
needs.get-environment.outputs.skip_workflow == 'false' &&
needs.get-plugins.outputs.package_plugins == 'True' &&
(contains(fromJson('["testing", "unstable"]'), needs.get-environment.outputs.stability) || (needs.get-environment.outputs.stability == 'stable' && github.event_name != 'workflow_dispatch')) &&
! cancelled() &&
! contains(needs.*.result, 'failure') &&
! contains(needs.*.result, 'cancelled')
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
include:
- distrib: el8
package_extension: rpm
- distrib: el9
package_extension: rpm
- distrib: el10
package_extension: rpm
- distrib: bullseye
package_extension: deb
- distrib: bookworm
package_extension: deb
- distrib: trixie
package_extension: deb
- distrib: jammy
package_extension: deb
- distrib: noble
package_extension: deb
name: deliver ${{ matrix.distrib }}
steps:
- name: Checkout sources
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Delivery
uses: ./.github/actions/package-delivery
with:
module_name: plugins
distrib: ${{ matrix.distrib }}
cache_key: ${{ github.sha }}-${{ github.run_id }}-${{ matrix.package_extension }}-${{ matrix.distrib }}
stability: ${{ needs.get-environment.outputs.stability }}
release_type: ${{ needs.get-environment.outputs.release_type }}
artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }}
deliver-sources:
needs: [get-environment, fatpacker]
if: |
needs.get-environment.outputs.stability == 'stable' &&
github.event_name == 'push'
runs-on: centreon-common
steps:
- name: Checkout sources
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: ./build/
key: fatpacked-plugins-${{ github.sha }}-${{ github.run_id }}
fail-on-cache-miss: true
- name: Deliver sources
uses: ./.github/actions/release-sources
with:
bucket_directory: centreon-plugins
module_directory: build
module_name: centreon-plugins
version: ${{ needs.get-environment.outputs.version }}
release: ${{ needs.get-environment.outputs.release }}
token_download_centreon_com: ${{ secrets.TOKEN_DOWNLOAD_CENTREON_COM }}
release-tag:
needs: [get-environment]
if: ${{ needs.get-environment.outputs.stability == 'stable' && github.event_name == 'push' }}
runs-on: ubuntu-24.04
steps:
- name: Checkout sources
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Push git release tag
env:
VERSION: ${{ needs.get-environment.outputs.version }}
run: |
RELEASE="plugins-${VERSION}"
EXISTING_TAG=$(git tag --list "$RELEASE" | head -n 1)
git config --global user.email "release@centreon.com"
git config --global user.name "Centreon"
if [ -z "$EXISTING_TAG" ]; then
git tag -a "$RELEASE" -m "release $RELEASE"
git push --follow-tags
else
echo "::warning::Release tag $RELEASE already exists"
fi
shell: bash
set-skip-label:
needs: [get-environment, deliver-packages]
if: |
needs.get-environment.outputs.skip_workflow == 'false' &&
! cancelled() &&
! contains(needs.*.result, 'failure') &&
! contains(needs.*.result, 'cancelled')
uses: ./.github/workflows/set-pull-request-skip-label.yml
create-jira-nightly-ticket:
runs-on: ubuntu-24.04
needs: [
get-environment,
deliver-packages
]
if: |
needs.get-environment.outputs.is_nightly == 'true' && github.run_attempt == 1 &&
(failure() || cancelled() || contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled'))
steps:
- name: Checkout sources
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Create Jira ticket based on nightly build failure
uses: ./.github/actions/create-jira-ticket
with:
jira_base_url: ${{ secrets.JIRA_BASE_URL }}
jira_user_email: ${{ secrets.XRAY_JIRA_USER_EMAIL }}
jira_api_token: ${{ secrets.XRAY_JIRA_TOKEN }}
module_name: "centreon-plugins"
ticket_reason_for_creation: "Nightly"