From 3b1227f4e3b333081ec5f0676a5addb20633e66b Mon Sep 17 00:00:00 2001 From: Jean Christophe Roques Date: Fri, 13 Sep 2024 09:43:32 +0200 Subject: [PATCH] no compile-package action --- .github/actions/compile-package/action.yml | 194 ----------------- .github/workflows/centreon-collect.yml | 45 ++++ .github/workflows/package-collect.yml | 203 +++++++++++++----- .../workflows/windows-agent-robot-test.yml | 49 ++--- 4 files changed, 211 insertions(+), 280 deletions(-) delete mode 100644 .github/actions/compile-package/action.yml diff --git a/.github/actions/compile-package/action.yml b/.github/actions/compile-package/action.yml deleted file mode 100644 index 06861b91e69..00000000000 --- a/.github/actions/compile-package/action.yml +++ /dev/null @@ -1,194 +0,0 @@ -name: compile-package -description: compile and package collect -inputs: - major_version: - description: "collect major version" - required: true - minor_version: - description: "collect minor version" - required: true - distrib: - description: linux distrib (bookworm, bullseye...) - required: true - package_extension: - description: rpm or deb - required: true - arch: - description: amd64 or arm64 - required: true - release: - description: "release id" - required: true - commit_hash: - description: "github sha" - required: true - stability: - description: "unstable, testing, stable or canary " - required: true - rpm_gpg_key: - description: The rpm gpg key - required: true - rpm_gpg_signing_key_id: - description: The rpm gpg signing key identifier - required: true - rpm_gpg_signing_passphrase: - description: The rpm gpg signing passphrase - required: true - legacy_engine: - description: true to comile legacy configuration - required: true - -runs: - using: composite - - steps: - - name: Install sccache - run: | - if [ "${{ inputs.package_extension }}" = "deb" ]; then - apt-get update - apt-get install -y wget - elif [ "${{ inputs.package_extension }}" = "rpm" ]; then - dnf install -y wget - fi - if [ "${{ inputs.arch }}" = "amd64" ]; then - wget https://github.com/mozilla/sccache/releases/download/v0.7.4/sccache-v0.7.4-x86_64-unknown-linux-musl.tar.gz - tar xzf sccache-v0.7.4-x86_64-unknown-linux-musl.tar.gz - mv sccache-v0.7.4-x86_64-unknown-linux-musl/sccache /usr/bin/ - elif [ "${{ inputs.arch }}" = "arm64" ]; then - wget https://github.com/mozilla/sccache/releases/download/v0.7.4/sccache-v0.7.4-aarch64-unknown-linux-musl.tar.gz - tar xzf sccache-v0.7.4-aarch64-unknown-linux-musl.tar.gz - mv sccache-v0.7.4-aarch64-unknown-linux-musl/sccache /usr/bin/ - fi - ${SCCACHE_PATH} --start-server - shell: bash - - - name: Generate selinux binaries - if: ${{ inputs.package_extension == 'rpm' }} - run: | - cd selinux - for MODULE in "centreon-engine" "centreon-broker" "centreon-monitoring-agent"; do - cd $MODULE - sed -i "s/@VERSION@/${{ inputs.major_version }}.${{ inputs.minor_version }}/g" $MODULE.te - make -f /usr/share/selinux/devel/Makefile - cd - - done - shell: bash - - - name: Remove selinux packaging files on debian - if: ${{ inputs.package_extension == 'deb' }} - run: rm -f packaging/*-selinux.yaml - shell: bash - - - name: Compile sources - run: | - CMAKE="cmake3" - if [ "${{ inputs.package_extension }}" = "deb" ]; then - CMAKE="cmake" - fi - - if [ "${{ inputs.arch }}" = "arm64" ]; then - export VCPKG_FORCE_SYSTEM_BINARIES=1 - export TRIPLET=arm64-linux-release - else - export TRIPLET=x64-linux-release - fi - - if [ "${{ inputs.legacy_engine }}" == true ]; then - export LEGACY_ENGINE=ON - else - export LEGACY_ENGINE=OFF - fi - mv /root/.cache /github/home/ - export VCPKG_ROOT="/vcpkg" - export PATH="$VCPKG_ROOT:$PATH" - $CMAKE \ - -B build \ - -DVCPKG_OVERLAY_TRIPLETS=/custom-triplets \ - -DVCPKG_TARGET_TRIPLET=$TRIPLET \ - -DVCPKG_OVERLAY_PORTS=/overlays \ - -GNinja \ - -DDEBUG_ROBOT=OFF \ - -DWITH_TESTING=OFF \ - -DWITH_BENCH=ON \ - -DWITH_MODULE_SIMU=OFF \ - -DCMAKE_INSTALL_PREFIX=/usr \ - -DWITH_STARTUP_SCRIPT=systemd \ - -DWITH_ENGINE_LOGROTATE_SCRIPT=ON \ - -DWITH_USER_BROKER=centreon-broker \ - -DWITH_GROUP_BROKER=centreon-broker \ - -DWITH_USER_ENGINE=centreon-engine \ - -DWITH_GROUP_ENGINE=centreon-engine \ - -DWITH_VAR_DIR=/var/log/centreon-engine \ - -DWITH_DAEMONS=ON \ - -DWITH_CREATE_FILES=OFF \ - -DWITH_CONFIG_FILES=ON \ - -DCMAKE_BUILD_TYPE=RelWithDebInfo \ - -DCMAKE_C_COMPILER_LAUNCHER=${SCCACHE_PATH} \ - -DCMAKE_CXX_COMPILER_LAUNCHER=${SCCACHE_PATH} \ - -DLEGACY_ENGINE=$LEGACY_ENGINE \ - -S . - - ninja -Cbuild - shell: bash - - - name: Cache statistics - run: ${SCCACHE_PATH} --show-stats - shell: bash - - - name: Stop sccache server - run: ${SCCACHE_PATH} --stop-server - shell: bash - - - name: Generate debug files - run: | - for file in $(find build/{broker,engine,clib,connectors} -name '*.so' -type f); do - echo "Making a debug file of $file" - objcopy --only-keep-debug $file $file.debug - objcopy --strip-debug $file - objcopy --add-gnu-debuglink $file.debug $file - done - exe=("build/broker/cbd" - "build/broker/watchdog/cbwd" - "build/engine/centengine" - "build/engine/centenginestats" - "build/engine/modules/bench/centengine_bench_passive" - "build/connectors/perl/centreon_connector_perl" - "build/connectors/ssh/centreon_connector_ssh" - "build/ccc/ccc" - "build/agent/centagent") - for file in ${exe[@]}; do - echo "Making a debug file of $file" - objcopy --only-keep-debug $file $file.debug - objcopy --strip-debug $file - objcopy --add-gnu-debuglink $file.debug $file - done - shell: bash - - - uses: ./.github/actions/package - with: - nfpm_file_pattern: "packaging/*.yaml" - distrib: ${{ inputs.distrib }} - package_extension: ${{ inputs.package_extension }} - major_version: ${{ inputs.major_version }} - minor_version: ${{ inputs.minor_version }} - release: ${{ inputs.release }} - arch: ${{ inputs.arch }} - commit_hash: ${{ inputs.commit_hash }} - cache_key: ${{ github.run_id }}-${{ github.sha }}-${{ inputs.package_extension}}-centreon-collect-${{ inputs.distrib }}-${{ inputs.arch }}-${{ github.head_ref || github.ref_name }} - rpm_gpg_key: ${{ inputs.rpm_gpg_key }} - rpm_gpg_signing_key_id: ${{ inputs.rpm_gpg_signing_key_id }} - rpm_gpg_signing_passphrase: ${{ inputs.rpm_gpg_signing_passphrase }} - stability: ${{ inputs.stability }} - - - name: Cleaning not needed packages - shell: bash - run: rm -rf *-debuginfo*.${{ inputs.package_extension }} - - # set condition to true if artifacts are needed - - if: ${{ false }} - name: Upload package artifacts - uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 - with: - name: packages-${{ inputs.distrib }}-${{ inputs.arch }} - path: ./*.${{ inputs.package_extension}} - retention-days: 1 diff --git a/.github/workflows/centreon-collect.yml b/.github/workflows/centreon-collect.yml index 99c874773dc..5ed55927b0f 100644 --- a/.github/workflows/centreon-collect.yml +++ b/.github/workflows/centreon-collect.yml @@ -241,6 +241,46 @@ jobs: package: needs: [get-version] if: ${{ ! contains(fromJson('["stable"]'), needs.get-version.outputs.stability) }} + strategy: + fail-fast: false + matrix: + include: + - image: centreon-collect-alma8 + distrib: el8 + package_extension: rpm + runner: collect + arch: amd64 + - image: centreon-collect-alma9 + distrib: el9 + package_extension: rpm + runner: collect + arch: amd64 + - image: centreon-collect-debian-bullseye + distrib: bullseye + package_extension: deb + runner: collect + arch: amd64 + - image: centreon-collect-debian-bookworm + distrib: bookworm + package_extension: deb + runner: collect + arch: amd64 + - image: centreon-collect-ubuntu-jammy + distrib: jammy + package_extension: deb + runner: collect + arch: amd64 + - image: centreon-collect-debian-bullseye-arm64 + distrib: bullseye + package_extension: deb + runner: collect-arm64 + arch: arm64 + - image: centreon-collect-debian-bookworm-arm64 + distrib: bookworm + package_extension: deb + runner: collect-arm64 + arch: arm64 + uses: ./.github/workflows/package-collect.yml with: major_version: ${{ needs.get-version.outputs.major_version }} @@ -251,6 +291,11 @@ jobs: stability: ${{ needs.get-version.outputs.stability }} legacy_engine: ${{ github.event.inputs.legacy_engine == 'true' }} packages_in_artifact: ${{ github.event.inputs.packages_in_artifact == 'true' }} + image: ${{ matrix.image }} + distrib: ${{ matrix.distrib }} + package_extension: ${{ matrix.package_extension }} + runner: ${{ matrix.runner }} + arch: ${{ matrix.arch }} secrets: inherit robot-test: diff --git a/.github/workflows/package-collect.yml b/.github/workflows/package-collect.yml index d0464aca2ac..83e6ac57353 100644 --- a/.github/workflows/package-collect.yml +++ b/.github/workflows/package-collect.yml @@ -27,50 +27,26 @@ on: packages_in_artifact: required: true type: boolean + image: + required: true + type: string + distrib: + required: true + type: string + package_extension: + required: true + type: string + runner: + required: true + type: string + arch: + required: true + type: string + jobs: package: - strategy: - fail-fast: false - matrix: - include: - - image: centreon-collect-alma8 - distrib: el8 - package_extension: rpm - runner: collect - arch: amd64 - - image: centreon-collect-alma9 - distrib: el9 - package_extension: rpm - runner: collect - arch: amd64 - - image: centreon-collect-debian-bullseye - distrib: bullseye - package_extension: deb - runner: collect - arch: amd64 - - image: centreon-collect-debian-bookworm - distrib: bookworm - package_extension: deb - runner: collect - arch: amd64 - - image: centreon-collect-ubuntu-jammy - distrib: jammy - package_extension: deb - runner: collect - arch: amd64 - - image: centreon-collect-debian-bullseye-arm64 - distrib: bullseye - package_extension: deb - runner: collect-arm64 - arch: arm64 - - image: centreon-collect-debian-bookworm-arm64 - distrib: bookworm - package_extension: deb - runner: collect-arm64 - arch: arm64 - - runs-on: ${{ fromJson(format('["self-hosted", "{0}"]', matrix.runner)) }} + runs-on: ${{ fromJson(format('["self-hosted", "{0}"]', inputs.runner)) }} env: SCCACHE_PATH: "/usr/bin/sccache" @@ -80,42 +56,163 @@ jobs: AWS_SECRET_ACCESS_KEY: ${{ secrets.COLLECT_S3_SECRET_KEY }} container: - image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ matrix.image }}:${{ inputs.img_version }} + image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ inputs.image }}:${{ inputs.img_version }} credentials: username: ${{ secrets.DOCKER_REGISTRY_ID }} password: ${{ secrets.DOCKER_REGISTRY_PASSWD }} - name: package ${{ matrix.distrib }} ${{ matrix.arch }} + name: package ${{ inputs.distrib }} ${{ inputs.arch }} steps: - name: Checkout sources uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - - name: compile and package collect - uses: ./.github/actions/compile-package + - name: Install sccache + run: | + if [ "${{ inputs.package_extension }}" = "deb" ]; then + apt-get update + apt-get install -y wget + elif [ "${{ inputs.package_extension }}" = "rpm" ]; then + dnf install -y wget + fi + if [ "${{ inputs.arch }}" = "amd64" ]; then + wget https://github.com/mozilla/sccache/releases/download/v0.8.1/sccache-v0.8.1-x86_64-unknown-linux-musl.tar.gz + tar xzf sccache-v0.8.1-x86_64-unknown-linux-musl.tar.gz + mv sccache-v0.8.1-x86_64-unknown-linux-musl/sccache /usr/bin/ + elif [ "${{ inputs.arch }}" = "arm64" ]; then + wget https://github.com/mozilla/sccache/releases/download/v0.8.1/sccache-v0.8.1-aarch64-unknown-linux-musl.tar.gz + tar xzf sccache-v0.8.1-aarch64-unknown-linux-musl.tar.gz + mv sccache-v0.8.1-aarch64-unknown-linux-musl/sccache /usr/bin/ + fi + ${SCCACHE_PATH} --start-server + + - name: Generate selinux binaries + if: ${{ inputs.package_extension == 'rpm' }} + run: | + cd selinux + for MODULE in "centreon-engine" "centreon-broker" "centreon-monitoring-agent"; do + cd $MODULE + sed -i "s/@VERSION@/${{ inputs.major_version }}.${{ inputs.minor_version }}/g" $MODULE.te + make -f /usr/share/selinux/devel/Makefile + cd - + done + shell: bash + + - name: Remove selinux packaging files on debian + if: ${{ inputs.package_extension == 'deb' }} + run: rm -f packaging/*-selinux.yaml + shell: bash + + - name: Compile sources + run: | + CMAKE="cmake3" + if [ "${{ inputs.package_extension }}" = "deb" ]; then + CMAKE="cmake" + fi + + if [ "${{ inputs.arch }}" = "arm64" ]; then + export VCPKG_FORCE_SYSTEM_BINARIES=1 + export TRIPLET=arm64-linux-release + else + export TRIPLET=x64-linux-release + fi + + if [ "${{ inputs.legacy_engine }}" == true ]; then + export LEGACY_ENGINE=ON + else + export LEGACY_ENGINE=OFF + fi + mv /root/.cache /github/home/ + export VCPKG_ROOT="/vcpkg" + export PATH="$VCPKG_ROOT:$PATH" + $CMAKE \ + -B build \ + -DVCPKG_OVERLAY_TRIPLETS=/custom-triplets \ + -DVCPKG_TARGET_TRIPLET=$TRIPLET \ + -DVCPKG_OVERLAY_PORTS=/overlays \ + -GNinja \ + -DDEBUG_ROBOT=OFF \ + -DWITH_TESTING=OFF \ + -DWITH_BENCH=ON \ + -DWITH_MODULE_SIMU=OFF \ + -DCMAKE_INSTALL_PREFIX=/usr \ + -DWITH_STARTUP_SCRIPT=systemd \ + -DWITH_ENGINE_LOGROTATE_SCRIPT=ON \ + -DWITH_USER_BROKER=centreon-broker \ + -DWITH_GROUP_BROKER=centreon-broker \ + -DWITH_USER_ENGINE=centreon-engine \ + -DWITH_GROUP_ENGINE=centreon-engine \ + -DWITH_VAR_DIR=/var/log/centreon-engine \ + -DWITH_DAEMONS=ON \ + -DWITH_CREATE_FILES=OFF \ + -DWITH_CONFIG_FILES=ON \ + -DCMAKE_BUILD_TYPE=RelWithDebInfo \ + -DCMAKE_C_COMPILER_LAUNCHER=${SCCACHE_PATH} \ + -DCMAKE_CXX_COMPILER_LAUNCHER=${SCCACHE_PATH} \ + -DLEGACY_ENGINE=$LEGACY_ENGINE \ + -S . + + ninja -Cbuild + shell: bash + + - name: Cache statistics + run: ${SCCACHE_PATH} --show-stats + shell: bash + + - name: Stop sccache server + run: ${SCCACHE_PATH} --stop-server + shell: bash + + - name: Generate debug files + run: | + for file in $(find build/{broker,engine,clib,connectors} -name '*.so' -type f); do + echo "Making a debug file of $file" + objcopy --only-keep-debug $file $file.debug + objcopy --strip-debug $file + objcopy --add-gnu-debuglink $file.debug $file + done + exe=("build/broker/cbd" + "build/broker/watchdog/cbwd" + "build/engine/centengine" + "build/engine/centenginestats" + "build/engine/modules/bench/centengine_bench_passive" + "build/connectors/perl/centreon_connector_perl" + "build/connectors/ssh/centreon_connector_ssh" + "build/ccc/ccc" + "build/agent/centagent") + for file in "${exe[@]}"; do + echo "Making a debug file of $file" + objcopy --only-keep-debug $file $file.debug + objcopy --strip-debug $file + objcopy --add-gnu-debuglink $file.debug $file + done + shell: bash + + - uses: ./.github/actions/package with: + nfpm_file_pattern: "packaging/*.yaml" + distrib: ${{ inputs.distrib }} + package_extension: ${{ inputs.package_extension }} major_version: ${{ inputs.major_version }} minor_version: ${{ inputs.minor_version }} - distrib: ${{ matrix.distrib }} - package_extension: ${{ matrix.package_extension }} - arch: ${{ matrix.arch }} release: ${{ inputs.release }} + arch: ${{ inputs.arch }} commit_hash: ${{ inputs.commit_hash }} - stability: ${{ inputs.stability }} + cache_key: ${{ github.run_id }}-${{ github.sha }}-${{ inputs.package_extension}}-centreon-collect-${{ inputs.distrib }}-${{ inputs.arch }}-${{ github.head_ref || github.ref_name }} 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 }} - legacy_engine: ${{ inputs.legacy_engine }} + stability: ${{ inputs.stability }} - name: Cleaning not needed packages shell: bash - run: rm -rf *-debuginfo*.${{ matrix.package_extension }} + run: rm -rf *-debuginfo*.${{ inputs.package_extension }} # set condition to true if artifacts are needed - if: inputs.packages_in_artifact == true name: Upload package artifacts uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4 with: - name: packages-${{ matrix.distrib }}-${{ matrix.arch }} - path: ./*.${{ matrix.package_extension}} + name: packages-${{ inputs.distrib }}-${{ inputs.arch }} + path: ./*.${{ inputs.package_extension}} retention-days: 1 diff --git a/.github/workflows/windows-agent-robot-test.yml b/.github/workflows/windows-agent-robot-test.yml index def0150ae2d..9a741609d6a 100644 --- a/.github/workflows/windows-agent-robot-test.yml +++ b/.github/workflows/windows-agent-robot-test.yml @@ -17,41 +17,24 @@ jobs: build-collect: needs: [get-version] - runs-on: [self-hosted, collect] - - env: - SCCACHE_PATH: "/usr/bin/sccache" - SCCACHE_BUCKET: "centreon-github-sccache" - SCCACHE_REGION: "eu-west-1" - AWS_ACCESS_KEY_ID: ${{ secrets.COLLECT_S3_ACCESS_KEY }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.COLLECT_S3_SECRET_KEY }} - - container: + uses: ./.github/workflows/package-collect.yml + with: + major_version: ${{ needs.get-version.outputs.major_version }} + minor_version: ${{ needs.get-version.outputs.minor_version }} + img_version: ${{ needs.get-version.outputs.img_version }} + release: ${{ needs.get-version.outputs.release }} + commit_hash: ${{ github.sha }} + stability: ${{ needs.get-version.outputs.stability }} + legacy_engine: false + packages_in_artifact: ${{ github.event.inputs.packages_in_artifact == 'true' }} image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/centreon-collect-debian-bullseye:${{ needs.get-version.outputs.img_version }} - credentials: - username: ${{ secrets.DOCKER_REGISTRY_ID }} - password: ${{ secrets.DOCKER_REGISTRY_PASSWD }} - - steps: - - name: Checkout sources - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - - - name: compile and package collect - uses: ./.github/actions/compile-package - with: - major_version: ${{ needs.get-version.outputs.major_version }} - minor_version: ${{ needs.get-version.outputs.minor_version }} - distrib: bullseye - package_extension: deb - arch: amd64 - release: ${{ needs.get-version.outputs.release }} - commit_hash: ${{ github.sha }} - stability: ${{ needs.get-version.outputs.stability }} - 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 }} - legacy_engine: false + distrib: bullseye + package_extension: deb + runner: collect + arch: amd64 + secrets: inherit + build-agent-and-execute-test: needs: [build-collect] runs-on: windows-latest