Skip to content

web nightly develop #125

web nightly develop

web nightly develop #125

Workflow file for this run

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') &&
github.event.pull_request.base.repo.name == 'centreon'
environment: ${{ needs.get-version.outputs.environment }}
strategy:
matrix:
distrib: [el8, el9]
steps:
- name: Checkout sources
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Delivery
uses: ./.github/actions/rpm-delivery
with:
module_name: web
distrib: ${{ matrix.distrib }}
version: ${{ needs.get-version.outputs.major_version }}
artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }}
cache_key: ${{ github.sha }}-${{ github.run_id }}-rpm-${{ matrix.distrib }}
stability: ${{ needs.get-version.outputs.stability }}
release_type: ${{ needs.get-version.outputs.release_type }}
release_cloud: ${{ needs.get-version.outputs.release_cloud }}
deliver-deb:
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') &&
github.event.pull_request.base.repo.name == 'centreon'
environment: ${{ needs.get-version.outputs.environment }}
strategy:
matrix:
distrib: [bullseye, bookworm, jammy]
steps:
- name: Checkout sources
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Delivery
uses: ./.github/actions/deb-delivery
with:
module_name: web
distrib: ${{ matrix.distrib }}
version: ${{ needs.get-version.outputs.major_version }}
artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }}
cache_key: ${{ github.sha }}-${{ github.run_id }}-deb-${{ matrix.distrib }}
stability: ${{ needs.get-version.outputs.stability }}
release_type: ${{ needs.get-version.outputs.release_type }}
release_cloud: ${{ needs.get-version.outputs.release_cloud }}
promote:
needs: [get-version, deliver-deb, deliver-rpm]
if: |
(contains(fromJson('["stable", "testing"]'), needs.get-version.outputs.stability) && github.event_name != 'workflow_dispatch') &&
! cancelled() &&
! contains(needs.*.result, 'failure') &&
! contains(needs.*.result, 'cancelled') &&
github.event.pull_request.base.repo.name == 'centreon' &&
needs.get-version.outputs.environment == 'internal_contributor'
runs-on: [self-hosted, common]
strategy:
matrix:
distrib: [el8, el9, bullseye, bookworm]
steps:
- name: Checkout sources
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Promote ${{ matrix.distrib }} to stable
uses: ./.github/actions/promote-to-stable
with:
artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }}
module: web
distrib: ${{ matrix.distrib }}
major_version: ${{ needs.get-version.outputs.major_version }}
minor_version: ${{ needs.get-version.outputs.minor_version }}
stability: ${{ needs.get-version.outputs.stability }}
github_ref_name: ${{ github.ref_name }}
release_type: ${{ needs.get-version.outputs.release_type }}
release_cloud: ${{ needs.get-version.outputs.release_cloud }}