diff --git a/.github/docker/testing/Dockerfile.testing-plugins-bookworm b/.github/docker/testing/Dockerfile.testing-plugins-bookworm index 4a7b868615..f5e70048ea 100644 --- a/.github/docker/testing/Dockerfile.testing-plugins-bookworm +++ b/.github/docker/testing/Dockerfile.testing-plugins-bookworm @@ -2,7 +2,7 @@ ARG REGISTRY_URL=docker.io FROM ${REGISTRY_URL}/debian:bookworm -ENV DEBIAN_FRONTEND noninteractive +ENV DEBIAN_FRONTEND=noninteractive # fix locale RUN bash -e <> $GITHUB_OUTPUT + shell: bash + + - if: ${{ contains(matrix.build_distribs, matrix.distrib) }} + uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 + with: + name: packages-${{ matrix.package_extension }}-${{ matrix.distrib }}-${{ steps.package-name.outputs.name_with_dash }} + path: ./*.${{ matrix.package_extension }} + retention-days: 1 + + merge-package-rpm-artifacts: + needs: [package-rpm] + runs-on: ubuntu-24.04 + strategy: + matrix: + distrib: [el8, el9] + + steps: + - name: Merge Artifacts + uses: actions/upload-artifact/merge@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 + with: + name: packages-rpm-${{ matrix.distrib }} + pattern: packages-rpm-${{ matrix.distrib }}-* + delete-merged: false # cannot be set to true due to random fails: Failed to DeleteArtifact: Unable to make request: ECONNRESET + retention-days: 1 + + - name: Delete merged artifacts + uses: geekyeggo/delete-artifact@f275313e70c08f6120db482d7a6b98377786765b # v5.1.0 + with: + name: packages-rpm-${{ matrix.distrib }}-* + failOnError: false + + sign-rpm: + needs: [merge-package-rpm-artifacts] + + runs-on: ubuntu-24.04 + strategy: + matrix: + distrib: [el8, el9] + name: sign rpm ${{ matrix.distrib }} + container: + image: docker.centreon.com/centreon-private/rpm-signing:latest + options: -t + credentials: + username: ${{ secrets.HARBOR_RPM_GPG_SIGNING_REPO_USERNAME }} + password: ${{ secrets.HARBOR_RPM_GPG_SIGNING_REPO_TOKEN }} + + steps: + - run: apt-get install -y zstd + shell: bash + + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + + - uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 + with: + name: packages-rpm-${{ matrix.distrib }} + path: ./ + + - run: echo "HOME=/root" >> $GITHUB_ENV + shell: bash + + - run: rpmsign --addsign ./*.rpm + shell: bash + + - uses: actions/cache/save@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 + with: + path: ./*.rpm + key: ${{ github.sha }}-${{ github.run_id }}-rpm-${{ matrix.distrib }} + + package-deb: + needs: [get-environment] + if: ${{ needs.get-environment.outputs.stability != 'stable' }} + + runs-on: ${{ matrix.runner_name }} + strategy: + fail-fast: false + matrix: + image: [packaging-plugins-bullseye, packaging-plugins-bookworm, packaging-plugins-jammy, packaging-plugins-bullseye-arm64] + name: + [ + "ARGV::Struct", + "Authen::SCRAM::Client" + ] + include: + - runner_name: ubuntu-24.04 + - arch: amd64 + - build_distribs: "bullseye,bookworm,jammy" + - deb_dependencies: "" + - rpm_provides: "" + - version: "" + - use_dh_make_perl: "true" + - spec_file: "" + - no-auto-depends: true + - distrib: bullseye + package_extension: deb + image: packaging-plugins-bullseye + - distrib: bookworm + package_extension: deb + image: packaging-plugins-bookworm + - distrib: jammy + package_extension: deb + image: packaging-plugins-jammy + - distrib: bullseye + package_extension: deb + image: packaging-plugins-bullseye-arm64 + arch: arm64 + runner_name: ["self-hosted", "collect-arm64"] + name: package ${{ matrix.distrib }} ${{ matrix.arch }} ${{ matrix.name }} + container: + image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ matrix.image }}:latest + credentials: + username: ${{ secrets.HARBOR_CENTREON_PULL_USERNAME }} + password: ${{ secrets.HARBOR_CENTREON_PULL_TOKEN }} + + steps: + - if: ${{ contains(matrix.build_distribs, matrix.distrib) }} + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + + - if: ${{ contains(matrix.build_distribs, matrix.distrib) }} + name: Parse distrib name + id: parse-distrib + uses: ./.github/actions/parse-distrib + with: + distrib: ${{ matrix.distrib }} + + - if: ${{ contains(matrix.build_distribs, matrix.distrib) }} + name: Get package version + id: package-version + run: | + apt-get update + apt-get install -y cpanminus + + if [ -z "${{ matrix.version }}" ]; then + CPAN_PACKAGE_VERSION=$(cpanm --info ${{ matrix.name }} | sed 's/\.tar\.gz$//' | sed 's/.*\-//' | sed 's/v//') + + if [[ ! $CPAN_PACKAGE_VERSION =~ ^[0-9]+\.[0-9]+ ]]; then + echo "::error::Invalid version number: ${CPAN_PACKAGE_VERSION}" + exit 1 + fi + + PACKAGE_VERSION="${CPAN_PACKAGE_VERSION}" + else + PACKAGE_VERSION="${{ matrix.version }}" + fi + + echo "package_version=$(echo $PACKAGE_VERSION)" >> $GITHUB_OUTPUT + shell: bash + + - if: ${{ contains(matrix.build_distribs, matrix.distrib) && matrix.use_dh_make_perl == 'false' }} + run: | + apt-get install -y ruby libcurl4-openssl-dev libssh-dev uuid-dev libczmq-dev + + if [ -z "${{ matrix.deb_dependencies }}" ]; then + PACKAGE_DEPENDENCIES="" + else + for PACKAGE_DEPENDENCY in `echo ${{ matrix.deb_dependencies }}`; do + PACKAGE_DEPENDENCIES="$PACKAGE_DEPENDENCIES --depends $PACKAGE_DEPENDENCY" + done + fi + + if [ ! -z "${{ matrix.no-auto-depends }}" ]; then + PACKAGE_DEPENDENCIES="$PACKAGE_DEPENDENCIES --no-auto-depends" + fi + + cpanm Module::Build::Tiny + cpanm Module::Install + + gem install fpm + # Patch to apply fpm fix for debian package generation while waiting for the official fix to be released. + patch -i .github/patch/fpm-deb.rb.diff $(find / -type f -name "deb.rb") + + fpm -a native -s cpan -t ${{ matrix.package_extension }} --deb-dist ${{ matrix.distrib }} --iteration ${{ steps.parse-distrib.outputs.package_distrib_name }} --verbose --cpan-verbose --no-cpan-test$PACKAGE_DEPENDENCIES -v ${{ steps.package-version.outputs.package_version }} ${{ matrix.name }} + shell: bash + + - if: ${{ contains(matrix.build_distribs, matrix.distrib) && matrix.use_dh_make_perl == 'true' }} + run: | + apt-get install -y libcurl4-openssl-dev dh-make-perl libssh-dev uuid-dev libczmq-dev libmodule-install-perl libmodule-build-tiny-perl + # module-build-tiny is required for Mojo::IOLoop::Signal build. + + DEB_BUILD_OPTIONS="nocheck nodocs notest" dh-make-perl make --dist ${{ matrix.distrib }} --build --version ${{ steps.package-version.outputs.package_version }}${{ steps.parse-distrib.outputs.package_distrib_separator }}${{ steps.parse-distrib.outputs.package_distrib_name }} --cpan ${{ matrix.name }} + shell: bash + + - if: ${{ contains(matrix.build_distribs, matrix.distrib) }} + name: Replace '::' with - in the feature path + id: package-name + run: | + name="${{ matrix.name }}" + name_with_dash="${name//::/-}" + echo "Modified Name: $name_with_dash" + echo "name_with_dash=$name_with_dash" >> $GITHUB_OUTPUT + shell: bash + + - if: ${{ contains(matrix.build_distribs, matrix.distrib) }} + uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 + with: + name: packages-${{ matrix.package_extension }}-${{ matrix.distrib }}-${{ matrix.arch }}-${{ steps.package-name.outputs.name_with_dash}} + path: ./*.${{ matrix.package_extension }} + retention-days: 1 + + merge-package-deb-artifacts: + needs: [package-deb] + runs-on: ubuntu-24.04 + strategy: + matrix: + distrib: [bullseye, bookworm, jammy] + + steps: + - name: Merge Artifacts + uses: actions/upload-artifact/merge@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 + with: + name: packages-deb-${{ matrix.distrib }} + pattern: packages-deb-${{ matrix.distrib }}-* + delete-merged: false # cannot be set to true due to random fails: Failed to DeleteArtifact: Unable to make request: ECONNRESET + retention-days: 1 + + - name: Delete merged artifacts + uses: geekyeggo/delete-artifact@f275313e70c08f6120db482d7a6b98377786765b # v5.1.0 + with: + name: packages-deb-${{ matrix.distrib }}-* + failOnError: false + + download-and-cache-deb: + needs: [merge-package-deb-artifacts] + runs-on: ubuntu-24.04 + strategy: + matrix: + distrib: [bullseye, bookworm, jammy] + steps: + - uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 + with: + name: packages-deb-${{ matrix.distrib }} + path: ./ + + - uses: actions/cache/save@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 + with: + path: ./*.deb + key: ${{ github.sha }}-${{ github.run_id }}-deb-${{ matrix.distrib }} + + test-packages: + needs: [get-environment, sign-rpm, download-and-cache-deb] + strategy: + fail-fast: false + matrix: + include: + - package_extension: rpm + image: almalinux:8 + distrib: el8 + runner_name: ubuntu-24.04 + - package_extension: rpm + image: almalinux:9 + distrib: el9 + runner_name: ubuntu-24.04 + - package_extension: deb + image: debian:bullseye + distrib: bullseye + runner_name: ubuntu-24.04 + - package_extension: deb + image: debian:bookworm + distrib: bookworm + runner_name: ubuntu-24.04 + - package_extension: deb + image: ubuntu:jammy + distrib: jammy + runner_name: ubuntu-24.04 + - package_extension: deb + image: arm64v8/debian:bullseye + distrib: bullseye + arch: arm64 + runner_name: ["self-hosted", "collect-arm64"] + + runs-on: ${{ matrix.runner_name }} + container: + image: ${{ matrix.image }} + + steps: + - name: Install zstd, perl and CentOS GPG key for el8/el9 + run: | + if [ "${{ matrix.package_extension }}" == "rpm" ]; then + yum install -y zstd perl + rpm --import https://yum-gpg.centreon.com/RPM-GPG-KEY-CES + else + apt-get update + apt-get install -y zstd perl + fi + shell: bash + - name: Restore packages from cache + uses: actions/cache/restore@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 + with: + path: ./*.${{ matrix.package_extension }} + key: ${{ github.sha }}-${{ github.run_id }}-${{ matrix.package_extension }}-${{ matrix.distrib }} + fail-on-cache-miss: true + - name: Install packages + run: | + if [ "${{ matrix.package_extension }}" == "rpm" ]; then + for package in ./*.rpm; do + # Install package + rpm -i $package + # Uninstall package + rpm -e $package + done + else + apt-get update + for package in ./*.deb; do + # Install package + dpkg -i $package + # Uninstall package + dpkg -r $package + done + fi + shell: bash + + deliver-packages: + needs: [get-environment, sign-rpm, download-and-cache-deb] + if: | + (contains(fromJson('["testing", "unstable"]'), needs.get-environment.outputs.stability) || ( needs.get-environment.outputs.stability == 'stable' && github.event_name != 'workflow_dispatch')) && + ! cancelled() && + ! contains(needs.*.result, 'failure') && + ! contains(needs.*.result, 'cancelled') + runs-on: ubuntu-24.04 + strategy: + fail-fast: false + matrix: + include: + - distrib: el8 + package_extension: rpm + - distrib: el9 + package_extension: rpm + - distrib: bullseye + package_extension: deb + - distrib: bookworm + package_extension: deb + - distrib: jammy + package_extension: deb + + name: deliver ${{ matrix.distrib }} + steps: + - name: Checkout sources + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 + + - name: Delivery + uses: ./.github/actions/package-delivery + with: + module_name: perl-cpan-libraries + distrib: ${{ matrix.distrib }} + cache_key: ${{ github.sha }}-${{ github.run_id }}-${{ matrix.package_extension }}-${{ matrix.distrib }} + stability: ${{ needs.get-environment.outputs.stability }} + release_type: ${{ needs.get-environment.outputs.release_type }} + artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }}