-
Notifications
You must be signed in to change notification settings - Fork 4
1091 lines (962 loc) · 41.6 KB
/
web.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
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
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
name: web
run-name: ${{ (github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && github.event.inputs.is_nightly == 'true')) && format('web 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
schedule:
- cron: "0 3 * * 1-5"
pull_request_target:
types:
- opened
- synchronize
- reopened
- ready_for_review
paths:
- "centreon/**"
- "!centreon/cypress/**"
- "!centreon/features/**"
- "!centreon/lighthouse/**"
- "!centreon/tests/**"
- "!centreon/.veracode-exclusions"
- "!centreon/veracode.json"
- "!centreon/packages/**"
push:
branches:
- develop
- dev-[2-9][0-9].[0-9][0-9].x
- master
- "[2-9][0-9].[0-9][0-9].x"
paths:
- "centreon/**"
- "!centreon/cypress/**"
- "!centreon/features/**"
- "!centreon/lighthouse/**"
- "!centreon/tests/**"
- "!centreon/.veracode-exclusions"
- "!centreon/veracode.json"
- "!centreon/packages/**"
env:
base_directory: centreon
widgets_directory: centreon/www/widgets
jobs:
get-version:
uses: ./.github/workflows/get-version.yml
with:
version_file: centreon/www/install/insertBaseConf.sql
changes:
runs-on: ubuntu-22.04
needs: [get-version]
outputs:
has_frontend_changes: ${{ steps.filter.outputs.has_frontend_changes }}
has_backend_changes: ${{ steps.filter.outputs.has_backend_changes }}
has_features_changes: ${{ steps.filter.outputs.has_features_changes }}
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
id: filter
with:
filters: |
has_frontend_changes:
- '**/*.[jt]sx?'
- '**/www/front_src/**'
- '**/www/widgets/src/**'
- '**/tests/e2e/**'
- '**/package*'
- '**/lighthouse/**'
- '**/tsconfig.json'
- '**/cypress/**|**/pnpm-*'
has_backend_changes:
- '**/*.php'
- '**/phpstan*.neon'
- 'centreon/codingstyle.xml'
- 'centreon/config/**/*.xml'
- 'centreon/phpunit.xml'
- 'centreon/ruleset.xml'
- 'centreon/www/**/*.xml'
- '**/bin/**'
- '**/tmpl/**'
- '**/features/**'
- '/centreon/src/**'
- '**/config/**'
- '**/composer.*'
- '**/tests/api/**'
- '**/tests/rest_api/collections/**'
- '**/tests/php/**'
- '**/tests/clapi_export/**'
- '**/www/!(front_src)/**'
- '**/doc/API/**'
has_features_changes:
- '**/tests/e2e/**/*.feature'
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
gherkin-lint:
runs-on: ubuntu-22.04
needs: [changes]
if: needs.changes.outputs.has_features_changes == 'true'
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: ./.github/actions/gherkin-lint
with:
features_path: centreon/tests/e2e/features
dispatch-to-maintained-branches:
if: |
github.run_attempt == 1 &&
github.event_name == 'schedule' &&
github.ref_name == 'develop' &&
github.event.pull_request.base.repo.name == 'centreon'
runs-on: ubuntu-22.04
steps:
- name: Checkout sources
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- run: |
NIGHTLY_TARGETS=("dev-22.10.x" "dev-23.04.x" "dev-23.10.x" "dev-24.04.x")
for target in "${NIGHTLY_TARGETS[@]}"; do
echo "[INFO] - Dispatching nightly run to $target branch."
gh workflow run web.yml -r "$target" -f is_nightly=true
done
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
veracode-analysis:
needs: [get-version]
uses: ./.github/workflows/veracode-analysis.yml
with:
module_directory: centreon
module_name: centreon-web
major_version: ${{ needs.get-version.outputs.major_version }}
minor_version: ${{ needs.get-version.outputs.minor_version }}
stability: ${{ needs.get-version.outputs.stability }}
secrets:
veracode_api_id: ${{ secrets.VERACODE_API_ID_WEB }}
veracode_api_key: ${{ secrets.VERACODE_API_KEY_WEB_2 }}
veracode_srcclr_token: ${{ secrets.VERACODE_SRCCLR_TOKEN }}
jira_base_url: ${{ secrets.JIRA_BASE_URL }}
jira_user_email: ${{ secrets.XRAY_JIRA_USER_EMAIL }}
jira_api_token: ${{ secrets.XRAY_JIRA_TOKEN }}
frontend-web-build:
needs: [get-version]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: ./.github/actions/frontend-build
with:
base_directory: ${{ env.base_directory }}
dependencies_lock_file: ${{ env.base_directory }}/pnpm-lock.yaml
index_file: ${{ env.base_directory }}/www/index.html
static_directory: ${{ env.base_directory }}/www/static
index_cache_key: ${{ github.sha }}-${{ github.run_id }}-index
static_cache_key: ${{ github.sha }}-${{ github.run_id }}-static
build_command: pnpm centreon:build
frontend-widgets-build:
needs: [get-version]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: ./.github/actions/frontend-build
with:
base_directory: ${{ env.widgets_directory }}
dependencies_lock_file: ${{ env.base_directory }}/pnpm-lock.yaml
static_directory: ${{ env.widgets_directory }}/src
static_cache_key: ${{ github.sha }}-${{ github.run_id }}-widgets-static
backend-dependencies:
needs: [get-version]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: ./.github/actions/backend-dependencies
with:
base_directory: ${{ env.base_directory }}
cache_key: ${{ github.sha }}-${{ github.run_id }}-vendor
translation-build:
needs: [get-version]
runs-on: ubuntu-22.04
container:
image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/translation:${{ needs.get-version.outputs.major_version }}
credentials:
username: ${{ secrets.DOCKER_REGISTRY_ID }}
password: ${{ secrets.DOCKER_REGISTRY_PASSWD }}
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- run: |
cd centreon
mkdir -p www/locale/en_US.UTF-8/LC_MESSAGES
php bin/centreon-translations.php en lang/fr_FR.UTF-8/LC_MESSAGES/messages.po www/locale/en_US.UTF-8/LC_MESSAGES/messages.ser
for i in lang/* ; do
localefull=`basename $i`
langcode=`echo $localefull | cut -d _ -f 1`
mkdir -p "www/locale/$localefull/LC_MESSAGES"
msgfmt "lang/$localefull/LC_MESSAGES/messages.po" -o "www/locale/$localefull/LC_MESSAGES/messages.mo" || exit 1
msgfmt "lang/$localefull/LC_MESSAGES/help.po" -o "www/locale/$localefull/LC_MESSAGES/help.mo" || exit 1
php bin/centreon-translations.php "$langcode" "lang/$localefull/LC_MESSAGES/messages.po" "www/locale/$localefull/LC_MESSAGES/messages.ser"
done
shell: bash
- uses: actions/cache/save@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: ${{ env.base_directory }}/www/locale
key: ${{ github.sha }}-${{ github.run_id }}-translation
frontend-web-lint:
runs-on: ubuntu-22.04
needs: [changes, get-version]
if: |
needs.changes.outputs.has_frontend_changes == 'true' &&
needs.get-version.outputs.stability != 'stable'
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: ./.github/actions/frontend-lint
with:
frontend_directory: ${{ env.base_directory }}
module_name: centreon
dependencies_lock_file: ${{ env.base_directory }}/pnpm-lock.yaml
pat: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
lint_path: ./www/front_src/
frontend-widgets-lint:
runs-on: ubuntu-22.04
needs: [changes, get-version]
if: |
needs.changes.outputs.has_frontend_changes == 'true' &&
needs.get-version.outputs.stability != 'stable'
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: ./.github/actions/frontend-lint
with:
frontend_directory: ${{ env.widgets_directory }}
module_name: centreon-widgets
dependencies_lock_file: ${{ env.base_directory }}/pnpm-lock.yaml
pat: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
frontend-unit-test:
runs-on: ubuntu-22.04
needs: [changes, get-version]
if: |
needs.changes.outputs.has_frontend_changes == 'true' &&
needs.get-version.outputs.stability != 'stable'
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0
with:
version: 8
run_install: false
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
with:
node-version: 20
cache: pnpm
cache-dependency-path: ${{ env.base_directory }}/pnpm-lock.yaml
- name: Install dependencies
run: pnpm install --frozen-lockfile
working-directory: centreon
env:
CYPRESS_INSTALL_BINARY: "0"
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "1"
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: "true"
- name: Unit test
run: pnpm t --silent --reporter=jest-junit
working-directory: centreon
- if: failure()
uses: ./.github/actions/publish-report
with:
path: "centreon/junit.xml"
frontend-component-test:
needs: [changes, get-version]
if: |
needs.changes.outputs.has_frontend_changes == 'true' &&
needs.get-version.outputs.stability != 'stable'
uses: ./.github/workflows/cypress-component-parallelization.yml
secrets:
AWS_ACCESS_KEY_ID: ${{ secrets.LIGHTHOUSE_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.LIGHTHOUSE_SECRET }}
with:
name: centreon
module_name: centreon
specs_path: www/**
dependencies_lock_file: centreon/pnpm-lock.yaml
backend-unit-test:
runs-on: ubuntu-22.04
needs: [changes, get-version]
if: |
needs.changes.outputs.has_backend_changes == 'true' &&
needs.get-version.outputs.stability != 'stable'
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Setup PHP
uses: shivammathur/setup-php@c541c155eee45413f5b09a52248675b1a2575231 # v2.31.1
with:
php-version: 8.1
coverage: none
env:
runner: ubuntu-22.04
- name: Install dependencies
uses: ramsey/composer-install@57532f8be5bda426838819c5ee9afb8af389d51a # v3.0.0
with:
working-directory: centreon
composer-options: "--optimize-autoloader"
- name: Unit test
run: XDEBUG_MODE=coverage composer run-script test:ci
working-directory: centreon
- if: failure()
uses: ./.github/actions/publish-report
with:
path: "centreon/build/phpunit.xml"
format: "php-junit"
backend-lint:
runs-on: ubuntu-22.04
needs: [changes, get-version]
if: |
needs.changes.outputs.has_backend_changes == 'true' &&
needs.get-version.outputs.stability != 'stable'
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Setup PHP
uses: shivammathur/setup-php@c541c155eee45413f5b09a52248675b1a2575231 # v2.31.1
with:
php-version: 8.1
coverage: none
env:
runner: ubuntu-22.04
- name: Install Dependencies
run: composer install --optimize-autoloader
working-directory: centreon
shell: bash
- name: Run of php-cs-fixer with strict_type
run: vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php --verbose --dry-run --diff
working-directory: centreon
- name: Run of php-cs-fixer without strict_type
run: vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.unstrict.php --verbose --dry-run --diff
working-directory: centreon
- name: Run of phpstan on /src at level 4
run: vendor/bin/phpstan analyse --no-progress --level=4 --configuration=phpstan.neon
working-directory: centreon
- name: Run of phpstan on /src/Core at level 8 + Centreon Custom Rules
run: vendor/bin/phpstan analyse --no-progress --level=8 --configuration=phpstan.core.neon
working-directory: centreon
- name: Run of phpstan on /tests at level 2
run: vendor/bin/phpstan analyse --no-progress --level=2 --configuration=phpstan.test.neon
working-directory: centreon
package:
needs:
[
gherkin-lint,
get-version,
translation-build,
backend-dependencies,
backend-lint,
backend-unit-test,
frontend-web-build,
frontend-web-lint,
frontend-widgets-build,
frontend-widgets-lint,
frontend-unit-test,
frontend-component-test,
]
if: |
!cancelled() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled') &&
needs.get-version.outputs.stability != 'stable'
strategy:
fail-fast: false
matrix:
include:
- package_extension: rpm
image: packaging-nfpm-alma8
distrib: el8
- package_extension: rpm
image: packaging-nfpm-alma9
distrib: el9
- package_extension: deb
image: packaging-nfpm-bullseye
distrib: bullseye
- package_extension: deb
image: packaging-nfpm-bookworm
distrib: bookworm
- package_extension: deb
image: packaging-nfpm-jammy
distrib: jammy
runs-on: ubuntu-22.04
container:
image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ matrix.image }}:${{ needs.get-version.outputs.major_version }}
credentials:
username: ${{ secrets.DOCKER_REGISTRY_ID }}
password: ${{ secrets.DOCKER_REGISTRY_PASSWD }}
name: package ${{ matrix.distrib }}
steps:
- name: Checkout sources
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Restore translation from cache
uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: centreon/www/locale
key: ${{ github.sha }}-${{ github.run_id }}-translation
fail-on-cache-miss: true
- name: Restore web index.html from cache
uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: centreon/www/index.html
key: ${{ github.sha }}-${{ github.run_id }}-index
fail-on-cache-miss: true
- name: Restore web frontend from cache
uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: centreon/www/static
key: ${{ github.sha }}-${{ github.run_id }}-static
fail-on-cache-miss: true
- name: Restore widget frontend from cache
uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: centreon/www/widgets/src
key: ${{ github.sha }}-${{ github.run_id }}-widgets-static
fail-on-cache-miss: true
- name: Move widgets directory
run: mv centreon/www/widgets/src/* centreon/www/widgets/
shell: bash
- name: Restore vendor directory from cache
uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: centreon/vendor
key: ${{ github.sha }}-${{ github.run_id }}-vendor
fail-on-cache-miss: true
- name: Set perl vendor lib path according to distrib
run: |
if [[ "${{ matrix.package_extension }}" == "deb" ]]; then
PERL_VENDORLIB="/usr/share/perl5"
else
PERL_VENDORLIB="/usr/share/perl5/vendor_perl"
fi
echo "PERL_VENDORLIB=$PERL_VENDORLIB" >> $GITHUB_ENV
shell: bash
- name: Create centreon web configuration file
run: mv centreon/config/centreon.config.php.template centreon/config/centreon.config.php
shell: bash
- name: Remove compilation related files
run: |
rm -rf centreon/www/front_src
rm -rf centreon/www/widgets/src
find centreon/www/widgets/ -maxdepth 1 -type f ! -name "*.php" ! -name "*.ts" -delete
shell: bash
- name: Replace macros in source code
run: |
MACRO_REPLACEMENT_FILE="centreon/packaging/src/centreon-macroreplacement.txt"
if [[ "${{ matrix.package_extension }}" == "rpm" ]]; then
APACHE_USER="apache"
else
APACHE_USER="www-data"
fi
echo "s#@WEB_USER@#$APACHE_USER#g" >> $MACRO_REPLACEMENT_FILE
find ./centreon -type f -not -path "./vendor/*" | grep -v $MACRO_REPLACEMENT_FILE | xargs --delimiter='\n' sed -i -f $MACRO_REPLACEMENT_FILE
shell: bash
- name: Generate selinux binaries
if: ${{ matrix.package_extension == 'rpm' }}
run: |
cd centreon/selinux
sed -i "s/@VERSION@/${{ needs.get-version.outputs.major_version }}.${{ needs.get-version.outputs.minor_version }}/g" *.te
make -f /usr/share/selinux/devel/Makefile
shell: bash
- name: Remove selinux packaging files on debian
if: ${{ matrix.package_extension == 'deb' }}
run: rm -f centreon/packaging/*-selinux.yaml
shell: bash
- name: Package Centreon
uses: ./.github/actions/package-nfpm
with:
nfpm_file_pattern: "centreon/packaging/*.yaml"
distrib: ${{ matrix.distrib }}
package_extension: ${{ matrix.package_extension }}
major_version: ${{ needs.get-version.outputs.major_version }}
minor_version: ${{ needs.get-version.outputs.minor_version }}
release: ${{ needs.get-version.outputs.release }}
arch: all
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-version.outputs.stability }}
dockerize:
runs-on: ubuntu-22.04
needs: [get-version, package]
if: |
!cancelled() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled') &&
needs.get-version.outputs.stability != 'stable'
env:
project: centreon-web
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.get-version.outputs.os_and_database_matrix).operating_systems }}
name: dockerize ${{ matrix.operating_system }}
steps:
- name: Checkout sources
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Generate information according to matrix os
id: matrix_include
run: |
if [ "${{ matrix.operating_system }}" = "alma8" ]; then
DISTRIB=el8
PACKAGE_EXTENSION=rpm
elif [ "${{ matrix.operating_system }}" = "alma9" ]; then
DISTRIB=el9
PACKAGE_EXTENSION=rpm
elif [ "${{ matrix.operating_system }}" = "bullseye" ]; then
DISTRIB=bullseye
PACKAGE_EXTENSION=deb
elif [ "${{ matrix.operating_system }}" = "bookworm" ]; then
DISTRIB=bookworm
PACKAGE_EXTENSION=deb
elif [ "${{ matrix.operating_system }}" = "jammy" ]; then
DISTRIB=jammy
PACKAGE_EXTENSION=deb
else
echo "::error::${{ matrix.operating_system }} is not managed"
exit 1
fi
echo "distrib=$DISTRIB" >> $GITHUB_OUTPUT
echo "package_extension=$PACKAGE_EXTENSION" >> $GITHUB_OUTPUT
shell: bash
- name: Login to registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}
username: ${{ secrets.DOCKER_REGISTRY_ID }}
password: ${{ secrets.DOCKER_REGISTRY_PASSWD }}
- name: Restore ${{ steps.matrix_include.outputs.package_extension }} files
uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: ./*.${{ steps.matrix_include.outputs.package_extension }}
key: ${{ github.sha }}-${{ github.run_id }}-${{ steps.matrix_include.outputs.package_extension }}-${{ steps.matrix_include.outputs.distrib }}
fail-on-cache-miss: true
- uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3.6.1
- name: Build and push web image
uses: docker/build-push-action@16ebe778df0e7752d2cfcbd924afdbbd89c1a755 # v6.6.1
env:
DOCKER_BUILD_CHECKS_ANNOTATIONS: false
DOCKER_BUILD_SUMMARY: false
DOCKER_BUILD_RECORD_UPLOAD: false
with:
file: .github/docker/${{ env.project }}/${{ matrix.operating_system }}/Dockerfile
context: .
build-args: |
"REGISTRY_URL=${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}"
"VERSION=${{ needs.get-version.outputs.major_version }}"
"MYDUMPER_VERSION=0.16.3-5"
pull: true
push: true
load: true
tags: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ env.project }}-${{ matrix.operating_system }}:${{ github.head_ref || github.ref_name }}
- name: Setup docker slim
run: curl -sL https://raw.githubusercontent.com/slimtoolkit/slim/master/scripts/install-slim.sh | sudo -E bash -s -- 1.40.11
shell: bash
- name: Build slim image
run: |
export WEB_IMAGE="${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ env.project }}-${{ matrix.operating_system }}:${{ github.head_ref || github.ref_name }}"
sed -i '/openid:/,$d' .github/docker/docker-compose.yml # remove all services after openid
docker compose -f .github/docker/docker-compose.yml pull db
slim build \
--compose-file .github/docker/docker-compose.yml \
--compose-env-file .github/docker/.env \
--target-compose-svc web \
--show-clogs \
--show-blogs \
--include-shell \
--include-new=false \
--http-probe-off \
--exec-file .github/docker/centreon-web/${{ matrix.operating_system }}/slim-configuration/exec.txt \
--include-path-file .github/docker/centreon-web/${{ matrix.operating_system }}/slim-configuration/include-path.txt \
--include-bin-file .github/docker/centreon-web/${{ matrix.operating_system }}/slim-configuration/include-bin.txt \
--path-perms-file .github/docker/centreon-web/${{ matrix.operating_system }}/slim-configuration/path-perms.txt \
--tag ${{ env.project }}-slim-${{ matrix.operating_system }}:${{ github.head_ref || github.ref_name }}
docker tag ${{ env.project }}-slim-${{ matrix.operating_system }}:${{ github.head_ref || github.ref_name }} ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ env.project }}-slim-${{ matrix.operating_system }}:${{ github.head_ref || github.ref_name }}
shell: bash
- name: Push slim image
run: docker push ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ env.project }}-slim-${{ matrix.operating_system }}:${{ github.head_ref || github.ref_name }}
shell: bash
- name: Store slim image in local archive
run: |
mkdir -p /tmp/cache/docker-image
docker save --output /tmp/cache/docker-image/${{ env.project }}-slim-${{ matrix.operating_system }}.tar ${{ env.project }}-slim-${{ matrix.operating_system }}:${{ github.head_ref || github.ref_name }}
shell: bash
- name: Clear previous docker image from cache
run: |
curl \
-X DELETE \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/centreon/centreon/actions/caches?key=docker-image-${{ env.project }}-slim-${{ matrix.operating_system }}-${{ github.head_ref || github.ref_name }}
shell: bash
- name: Store slim image in cache
uses: actions/cache/save@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: /tmp/cache/docker-image
key: docker-image-${{ env.project }}-slim-${{ matrix.operating_system }}-${{ github.head_ref || github.ref_name }}
create-xray-test-plan-and-test-execution:
needs: [get-version, dockerize]
if: |
!cancelled() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled') &&
( needs.get-version.outputs.stability == 'testing' || github.event_name == 'schedule' ) &&
github.event.pull_request.base.repo.name == 'centreon'
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.get-version.outputs.os_and_database_matrix).operating_systems }}
name: create-xray-test-plan-and-test-execution-${{ matrix.operating_system }}
uses: ./.github/workflows/create-xray-test-plan-and-test-execution.yml
with:
major_version: ${{ needs.get-version.outputs.major_version }}
minor_version: ${{ needs.get-version.outputs.minor_version }}
os: ${{ matrix.operating_system }}
secrets:
xray_client_id: ${{ secrets.XRAY_CLIENT_ID }}
xray_client_secret: ${{ secrets.XRAY_CLIENT_SECRET }}
xray_jira_user_email: ${{ secrets.XRAY_JIRA_USER_EMAIL }}
xray_jira_token: ${{ secrets.XRAY_JIRA_TOKEN }}
newman-test:
needs: [get-version, changes, create-xray-test-plan-and-test-execution, dockerize]
if: |
!cancelled() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled') &&
needs.changes.outputs.has_backend_changes == 'true'
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.get-version.outputs.os_and_database_matrix).databases }}
name: newman-test-${{ matrix.operating_system }}-${{ matrix.database }}
uses: ./.github/workflows/newman.yml
with:
collection_path: centreon/tests/rest_api/collections
image_name: centreon-web
os: ${{ matrix.operating_system }}
container_name: my_centreon_container
centreon_url: http://localhost
centreon_image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/centreon-web-slim-${{ matrix.operating_system }}:${{ github.head_ref || github.ref_name }}
database_image: bitnami/${{ matrix.database }}
dependencies_lock_file: centreon/pnpm-lock.yaml
major_version: ${{ needs.get-version.outputs.major_version }}
stability: ${{ needs.get-version.outputs.stability }}
xray_keys_and_ids: ${{ toJson(needs.create-xray-test-plan-and-test-execution.outputs) }}
secrets:
registry_username: ${{ secrets.DOCKER_REGISTRY_ID }}
registry_password: ${{ secrets.DOCKER_REGISTRY_PASSWD }}
client_id: ${{ secrets.XRAY_CLIENT_ID }}
client_secret: ${{ secrets.XRAY_CLIENT_SECRET }}
jira_user: ${{ secrets.XRAY_JIRA_USER_EMAIL }}
jira_token_test: ${{ secrets.XRAY_JIRA_TOKEN }}
legacy-e2e-test:
needs: [get-version, changes, dockerize]
if: |
!cancelled() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled') &&
needs.changes.outputs.has_backend_changes == 'true' &&
needs.get-version.outputs.stability != 'stable'
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.get-version.outputs.os_and_database_matrix).operating_systems }}
name: legacy-e2e-test-${{ matrix.operating_system }}-${{ matrix.database }}
uses: ./.github/workflows/behat-test.yml
with:
name: legacy-e2e
module_name: centreon
database_image: bitnami/${{ matrix.database }}
image_name: centreon-web
os: ${{ matrix.operating_system }}
features_path: features
test_tags: ${{ matrix.test_tags }}
secrets:
registry_username: ${{ secrets.DOCKER_REGISTRY_ID }}
registry_password: ${{ secrets.DOCKER_REGISTRY_PASSWD }}
composer_token: ${{ secrets.CENTREON_TECHNIQUE_PAT }}
e2e-test:
needs: [get-version, dockerize, create-xray-test-plan-and-test-execution]
if: |
!cancelled() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled') &&
needs.get-version.outputs.stability != 'stable'
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.get-version.outputs.os_and_database_matrix).operating_systems }}
name: e2e-test-${{ matrix.operating_system }}-${{ matrix.database }}
uses: ./.github/workflows/cypress-e2e-parallelization.yml
with:
name: e2e
module_name: centreon
image_name: centreon-web
database_image: bitnami/${{ matrix.database }}
os: ${{ matrix.operating_system }}
features_path: tests/e2e/features
major_version: ${{ needs.get-version.outputs.major_version }}
minor_version: ${{ needs.get-version.outputs.minor_version }}
stability: ${{ needs.get-version.outputs.stability }}
package_cache_key: ${{ format('{0}-{1}-{2}', github.sha, github.run_id, matrix.operating_system == 'alma8' && 'rpm-el8' || matrix.operating_system == 'alma9' && 'rpm-el9' || matrix.operating_system == 'bullseye' && 'deb-bullseye' || 'deb-bookworm' ) }}
package_directory: centreon/tests/e2e/fixtures/packages
test_tags: ${{ matrix.test_tags }}
dependencies_lock_file: centreon/pnpm-lock.yaml
xray_keys_and_ids: ${{ toJson(needs.create-xray-test-plan-and-test-execution.outputs) }}
is_cloud: ${{ needs.get-version.outputs.release_cloud == '1' && true || false }}
secrets:
registry_username: ${{ secrets.DOCKER_REGISTRY_ID }}
registry_password: ${{ secrets.DOCKER_REGISTRY_PASSWD }}
xray_client_id: ${{ secrets.XRAY_CLIENT_ID }}
xray_client_secret: ${{ secrets.XRAY_CLIENT_SECRET }}
artifactory_internal_repo_username: ${{ secrets.ARTIFACTORY_INTERNAL_REPO_USERNAME }}
artifactory_internal_repo_password: ${{ secrets.ARTIFACTORY_INTERNAL_REPO_PASSWORD }}
performances-test:
runs-on: ubuntu-22.04
needs: [get-version, dockerize]
if: |
!cancelled() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled') &&
needs.get-version.outputs.stability != 'stable'
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.get-version.outputs.os_and_database_matrix).main }}
name: performances-test-${{ matrix.operating_system }}-${{ matrix.database }}
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Login to registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}
username: ${{ secrets.DOCKER_REGISTRY_ID }}
password: ${{ secrets.DOCKER_REGISTRY_PASSWD }}
- name: Run Lighthouse
uses: ./.github/actions/lighthouse-performance-testing
with:
path: "centreon/lighthouse"
image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/centreon-web-slim-alma9
image_version: ${{ github.head_ref || github.ref_name }}
database_image: bitnami/mariadb:10.11
image_lighthouse_version: ${{ needs.get-version.outputs.major_version }}
module: centreon
dependencies_lock_file: centreon/pnpm-lock.yaml
- name: Publish report to S3
if: |
github.event_name == 'push' &&
github.event.pull_request.base.repo.name == 'centreon'
uses: ./.github/actions/lighthouse-to-s3
with:
report_path: centreon/lighthouse/report/lighthouseci-index.html
report_target: s3://centreon-lighthouse-report/
access_key_id: ${{ secrets.LIGHTHOUSE_ID }}
secret_access_key: ${{ secrets.LIGHTHOUSE_SECRET }}
- name: Publish report
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
with:
name: lighthouse-report
path: centreon/lighthouse/report/lighthouseci-index.html
retention-days: 1
deliver-sources:
runs-on: [self-hosted, common]
needs:
[
get-version,
e2e-test,
performances-test,
legacy-e2e-test,
]
if: |
!cancelled() &&
contains(fromJson('["stable"]'), needs.get-version.outputs.stability) &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled') &&
github.event_name != 'workflow_dispatch' &&
github.event.pull_request.base.repo.name == 'centreon'
steps:
- name: Checkout sources
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Deliver sources
uses: ./.github/actions/release-sources
with:
bucket_directory: centreon
module_directory: centreon
module_name: centreon-web
frontend_index_cache_key: ${{ github.sha }}-${{ github.run_id }}-index
frontend_index_file: centreon/www/index.html
frontend_static_cache_key: ${{ github.sha }}-${{ github.run_id }}-static
frontend_static_directory: centreon/www/static
backend_vendor_cache_key: ${{ github.sha }}-${{ github.run_id }}-vendor
backend_vendor_directory: centreon/vendor
translation_cache_key: ${{ github.sha }}-${{ github.run_id }}-translation
translation_directory: centreon/www/locale
major_version: ${{ needs.get-version.outputs.major_version }}
minor_version: ${{ needs.get-version.outputs.minor_version }}
token_download_centreon_com: ${{ secrets.TOKEN_DOWNLOAD_CENTREON_COM }}
publish-openapi-documentation:
runs-on: [self-hosted, infra]
needs: [get-version]
if: |
!cancelled() &&
contains(fromJson('["stable"]'), needs.get-version.outputs.stability) &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled') &&
github.event_name != 'workflow_dispatch' &&
github.event.pull_request.base.repo.name == 'centreon'
steps:
- name: Checkout sources
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0
with:
version: 9
run_install: false
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
with:
node-version: 20
- name: Install redocly cli
run: pnpm add -g @redocly/[email protected]
shell: bash
- name: Build openapi documentation
run: |
if [[ "${{ needs.get-version.outputs.release_cloud }}" == "1" && -f "centreon/doc/API/centreon-cloud-api.yaml" ]]; then
OPENAPI_FILE="centreon/doc/API/centreon-cloud-api.yaml"
elif [[ -f "centreon/doc/API/centreon-api.yaml" ]]; then
OPENAPI_FILE="centreon/doc/API/centreon-api.yaml"
elif [[ -f "centreon/doc/API/centreon-api-v${{ needs.get-version.outputs.major_version }}.yaml" ]]; then
OPENAPI_FILE="centreon/doc/API/centreon-api-v${{ needs.get-version.outputs.major_version }}.yaml"
else
echo "::error::openapi file not found"
exit 1
fi
echo "Building API doc from $OPENAPI_FILE"
redocly build-docs --theme.openapi.hideDownloadButton=true $OPENAPI_FILE -o index.html
shell: bash
- name: Setup awscli
run: |
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
sudo unzip -q awscliv2.zip
sudo ./aws/install
shell: bash
- uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2
with:
aws-region: eu-west-1
role-to-assume: ${{ secrets.CLOUDFRONT_ROLE_DOC_PRODUCTION }}
role-session-name: InvalidDocCache
role-skip-session-tagging: true
role-duration-seconds: 900
- name: Copy to AWS S3 centreon-documentation-api
run: |
if [[ "${{ needs.get-version.outputs.release_cloud }}" == "1" ]]; then
BUCKET_PATH="s3://centreon-documentation-api/api/centreon-web/cloud"
else
BUCKET_PATH="s3://centreon-documentation-api/api/centreon-web/${{ needs.get-version.outputs.major_version }}"
fi
aws s3 cp "index.html" "${BUCKET_PATH}/index.html"
aws s3 cp "centreon/doc/API/centreon-logo.png" "${BUCKET_PATH}/centreon-logo.png"
shell: bash
- name: Invalid AWS Cloudfront cache
run: aws cloudfront create-invalidation --distribution-id ${{ secrets.CLOUDFRONT_ID_DOC_API }} --paths "/*"
shell: bash
- name: Upload built openapi doc
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: openapi-doc
path: |
index.html
centreon-logo.png
retention-days: 1
deliver-rpm:
runs-on: [self-hosted, common]
needs:
[
get-version,
e2e-test,
performances-test,
legacy-e2e-test
]
if: |
!cancelled() &&
contains(fromJson('["testing", "unstable", "pkgtest"]'), needs.get-version.outputs.stability) &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled') &&