Skip to content

web

web #23190

Workflow file for this run

name: web
run-name: ${{ (github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && 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 * * *"
pull_request:
paths:
- "centreon/**"
- "!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/.veracode-exclusions"
- "!centreon/veracode.json"
- "!centreon/packages/**"
env:
base_directory: centreon
widgets_directory: centreon/www/widgets
jobs:
changes:
runs-on: ubuntu-22.04
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@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: dorny/paths-filter@ebc4d7e9ebcb0b1eb21480bb8f43113e996ac77a # v3.0.1
id: filter
with:
filters: |
has_frontend_changes:
- '**/*.[jt]sx?'
- '**/www/front_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@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: ./.github/actions/gherkin-lint
with:
features_path: centreon/tests/e2e/features
dispatch-to-maintained-branches:
if: ${{ github.event_name == 'schedule' && github.ref_name == 'develop' }}
runs-on: ubuntu-22.04
steps:
- name: Checkout sources
uses: actions/checkout@v4
- run: |
NIGHTLY_TARGETS=("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 }}
get-version:
uses: ./.github/workflows/get-version.yml
with:
version_file: centreon/www/install/insertBaseConf.sql
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@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- 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@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- 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@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- 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@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- 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@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: ./.github/actions/frontend-lint
with:
frontend_directory: ${{ env.base_directory }}
module_name: centreon
dependencies_lock_file: ${{ env.base_directory }}/pnpm-lock.yaml
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@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: ./.github/actions/frontend-lint
with:
frontend_directory: ${{ env.widgets_directory }}
module_name: centreon-widgets
dependencies_lock_file: ${{ env.base_directory }}/pnpm-lock.yaml
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@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d # v3.0.0
with:
version: 8
run_install: false
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
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
with:
name: component
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@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Setup PHP
uses: shivammathur/setup-php@6d7209f44a25a59e904b1ee9f3b0c33ab2cd888d # v2.29.0
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@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Setup PHP
uses: shivammathur/setup-php@6d7209f44a25a59e904b1ee9f3b0c33ab2cd888d # v2.29.0
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@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- 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:
os: ${{ fromJson(needs.get-version.outputs.dockerize_matrix) }}
steps:
- name: Checkout sources
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Generate information according to matrix os
id: matrix_include
run: |
if [ "${{ matrix.os }}" = "alma8" ]; then
DISTRIB=el8
PACKAGE_EXTENSION=rpm
elif [ "${{ matrix.os }}" = "alma9" ]; then
DISTRIB=el9
PACKAGE_EXTENSION=rpm
elif [ "${{ matrix.os }}" = "bullseye" ]; then
DISTRIB=bullseye
PACKAGE_EXTENSION=deb
elif [ "${{ matrix.os }}" = "bookworm" ]; then
DISTRIB=bookworm
PACKAGE_EXTENSION=deb
elif [ "${{ matrix.os }}" = "jammy" ]; then
DISTRIB=jammy
PACKAGE_EXTENSION=deb
else
echo "::error::${{ matrix.os }} 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@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.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@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
- name: Build web image
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5.1.0
with:
file: .github/docker/${{ env.project }}/${{ matrix.os }}/Dockerfile
context: .
build-args: |
"REGISTRY_URL=${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}"
"VERSION=${{ needs.get-version.outputs.major_version }}"
pull: true
load: true
tags: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ env.project }}-${{ matrix.os }}:${{ github.head_ref || github.ref_name }}
- name: Push web image
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5.1.0
with:
file: .github/docker/${{ env.project }}/${{ matrix.os }}/Dockerfile
context: .
build-args: |
"REGISTRY_URL=${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}"
"VERSION=${{ needs.get-version.outputs.major_version }}"
pull: false
push: true
tags: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ env.project }}-${{ matrix.os }}:${{ 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.os }}:${{ 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.os }}/slim-configuration/exec.txt \
--include-path-file .github/docker/centreon-web/${{ matrix.os }}/slim-configuration/include-path.txt \
--include-bin-file .github/docker/centreon-web/${{ matrix.os }}/slim-configuration/include-bin.txt \
--path-perms-file .github/docker/centreon-web/${{ matrix.os }}/slim-configuration/path-perms.txt \
--tag ${{ env.project }}-slim-${{ matrix.os }}:${{ github.head_ref || github.ref_name }}
docker tag ${{ env.project }}-slim-${{ matrix.os }}:${{ github.head_ref || github.ref_name }} ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ env.project }}-slim-${{ matrix.os }}:${{ github.head_ref || github.ref_name }}
shell: bash
- name: Push slim image
run: docker push ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ env.project }}-slim-${{ matrix.os }}:${{ 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.os }}.tar ${{ env.project }}-slim-${{ matrix.os }}:${{ 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.os }}-${{ 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.os }}-${{ github.head_ref || github.ref_name }}
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:
os: ${{ fromJson(needs.get-version.outputs.dockerize_matrix) }}
uses: ./.github/workflows/newman.yml
with:
collection_path: centreon/tests/rest_api/collections
image_name: centreon-web
os: ${{ matrix.os }}
container_name: my_centreon_container
centreon_url: http://localhost
centreon_image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/centreon-web-slim-${{ matrix.os }}:${{ github.head_ref || github.ref_name }}
database_image: bitnami/mariadb:10.11
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 }}
api-integration-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:
os: ${{ fromJson(needs.get-version.outputs.dockerize_matrix) }}
uses: ./.github/workflows/behat-test.yml
with:
name: api
module_name: centreon
database_image: bitnami/mariadb:10.11
image_name: centreon-web
os: ${{ matrix.os }}
features_path: tests/api/features
config_file: tests/api/behat.yml
secrets:
registry_username: ${{ secrets.DOCKER_REGISTRY_ID }}
registry_password: ${{ secrets.DOCKER_REGISTRY_PASSWD }}
composer_token: ${{ secrets.CENTREON_TECHNIQUE_PAT }}
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:
os: ${{ fromJson(needs.get-version.outputs.dockerize_matrix) }}
uses: ./.github/workflows/behat-test.yml
with:
name: legacy-e2e
module_name: centreon
database_image: bitnami/mariadb:10.11
image_name: centreon-web
os: ${{ matrix.os }}
features_path: features
secrets:
registry_username: ${{ secrets.DOCKER_REGISTRY_ID }}
registry_password: ${{ secrets.DOCKER_REGISTRY_PASSWD }}
composer_token: ${{ secrets.CENTREON_TECHNIQUE_PAT }}
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' ) }}
strategy:
fail-fast: false
matrix:
os: ${{ fromJson(needs.get-version.outputs.dockerize_matrix) }}
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.os }}
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 }}
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:
os: ${{ fromJson(needs.get-version.outputs.dockerize_matrix) }}
uses: ./.github/workflows/cypress-e2e-parallelization.yml
with:
name: e2e
module_name: centreon
image_name: centreon-web
database_image: bitnami/mariadb:10.11
os: ${{ matrix.os }}
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.os == 'alma8' && 'rpm-el8' || matrix.os == 'alma9' && 'rpm-el9' || matrix.os == 'bullseye' && 'deb-bullseye' || 'deb-bookworm' ) }}
package_directory: centreon/tests/e2e/fixtures/packages
dependencies_lock_file: centreon/pnpm-lock.yaml
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 }}
xray_client_id: ${{ secrets.XRAY_CLIENT_ID }}
xray_client_secret: ${{ secrets.XRAY_CLIENT_SECRET }}
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' }}
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Login to registry
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.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' }}
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,
api-integration-test,
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' }}
steps:
- name: Checkout sources
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- 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 }}
deliver-rpm:
runs-on: [self-hosted, common]
needs:
[
get-version,
api-integration-test,
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') }}
environment: ${{ needs.get-version.outputs.environment }}
strategy:
matrix:
distrib: [el8, el9]
steps:
- name: Checkout sources
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- 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,
api-integration-test,
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') }}
environment: ${{ needs.get-version.outputs.environment }}
strategy:
matrix:
distrib: [bullseye, bookworm, jammy]
steps:
- name: Checkout sources
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- 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]
if: ${{ contains(fromJson('["stable"]'), needs.get-version.outputs.stability) }}
runs-on: [self-hosted, common]
strategy:
matrix:
distrib: [el8, el9, bullseye, bookworm]
steps:
- name: Checkout sources
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- 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: "master"
release_type: "release"
release_cloud: ${{ needs.get-version.outputs.release_cloud }}
deploy-platform-nightly:
needs:
[
get-version,
api-integration-test,
e2e-test,
performances-test,
legacy-e2e-test,
deliver-rpm
]
if: ${{ github.event_name == 'schedule' && contains(fromJson('["unstable"]'), needs.get-version.outputs.stability) }}
runs-on: [self-hosted, common]
steps:
- name: Checkout sources
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Trigger platform deployment
uses: ./.github/actions/nightly-platform-deploy
with:
ref: main
bu: RD
poller_number: 1
system_name: Alma8
centreon_branch: develop
configured_resources: false
install_business_modules: false
instance_password: ${{ secrets.COD_NIGHTLY_INSTANCE_ADMIN_PWD }}
cod_service_token: ${{ secrets.CENTREON_TECHNIQUE_PAT }}