Skip to content

Commit

Permalink
add compile-package action
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-christophe81 committed Jul 19, 2024
1 parent 3fdcb34 commit 9036718
Show file tree
Hide file tree
Showing 4 changed files with 248 additions and 181 deletions.
188 changes: 188 additions & 0 deletions .github/actions/compile-package/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
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

runs:
using: composite

steps:
- name: Checkout sources
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- 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
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} \
-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
141 changes: 6 additions & 135 deletions .github/workflows/package-collect.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,146 +85,17 @@ jobs:
- name: Checkout sources
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Install sccache
run: |
if [ "${{ matrix.package_extension }}" = "deb" ]; then
apt-get update
apt-get install -y wget
elif [ "${{ matrix.package_extension }}" = "rpm" ]; then
dnf install -y wget
fi
if [ "${{ matrix.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 [ "${{ matrix.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
- name: Generate selinux binaries
if: ${{ matrix.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: ${{ matrix.package_extension == 'deb' }}
run: rm -f packaging/*-selinux.yaml
shell: bash

- name: Compile sources
run: |
CMAKE="cmake3"
if [ "${{ matrix.package_extension }}" = "deb" ]; then
CMAKE="cmake"
fi
if [ "${{ matrix.arch }}" = "arm64" ]; then
export VCPKG_FORCE_SYSTEM_BINARIES=1
export TRIPLET=arm64-linux-release
else
export TRIPLET=x64-linux-release
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} \
-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
- name: compile and package
uses: ./.github/actions/compile-package
with:
nfpm_file_pattern: "packaging/*.yaml"
distrib: ${{ matrix.distrib }}
package_extension: ${{ matrix.package_extension }}
major_version: ${{ inputs.major_version }}
minor_version: ${{ inputs.minor_version }}
release: ${{ inputs.release }}
distrib: ${{ matrix.distrib }}
package_extension: ${{ matrix.package_extension }}
arch: ${{ matrix.arch }}
release: ${{ inputs.release }}
commit_hash: ${{ inputs.commit_hash }}
cache_key: ${{ github.run_id }}-${{ github.sha }}-${{ matrix.package_extension}}-centreon-collect-${{ matrix.distrib }}-${{ matrix.arch }}-${{ github.head_ref || github.ref_name }}
stability: ${{ inputs.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 }}
stability: ${{ inputs.stability }}

- name: Cleaning not needed packages
shell: bash
run: rm -rf *-debuginfo*.${{ matrix.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-${{ matrix.distrib }}-${{ matrix.arch }}
path: ./*.${{ matrix.package_extension}}
retention-days: 1
3 changes: 1 addition & 2 deletions .github/workflows/windows-agent-build-vcpkg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
steps:
- name: Checkout sources
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: install msvc command prompt
uses: ilammy/msvc-dev-cmd@v1.4.1

Expand Down Expand Up @@ -51,4 +51,3 @@ jobs:
Write-Host "aws s3 cp $file_name_extension s3://centreon-collect-robot-report/$file_name_extension"
[System.Environment]::SetEnvironmentVariable("AWS_EC2_METADATA_DISABLED","true")
aws s3 cp $file_name_extension s3://centreon-collect-robot-report/$file_name_extension
Loading

0 comments on commit 9036718

Please sign in to comment.