Skip to content

Commit

Permalink
Adding cpan libs tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sdepassio committed Dec 10, 2024
1 parent 3609bca commit 263734e
Show file tree
Hide file tree
Showing 2 changed files with 701 additions and 12 deletions.
150 changes: 138 additions & 12 deletions .github/workflows/perl-cpan-libraries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ concurrency:

on:
workflow_dispatch:
pull_request:
paths:
- ".github/workflows/perl-cpan-libraries.yml"
push:
branches:
- develop
- dev-[2-9][0-9].[0-9][0-9].x
- master
- "[2-9][0-9].[0-9][0-9].x"
paths:
- ".github/workflows/perl-cpan-libraries.yml"
# pull_request:
# paths:
# - ".github/workflows/perl-cpan-libraries.yml"
# push:
# branches:
# - develop
# - dev-[2-9][0-9].[0-9][0-9].x
# - master
# - "[2-9][0-9].[0-9][0-9].x"
# paths:
# - ".github/workflows/perl-cpan-libraries.yml"

jobs:
get-environment:
Expand Down Expand Up @@ -508,8 +508,134 @@ jobs:
path: ./*.deb
key: ${{ github.sha }}-${{ github.run_id }}-deb-${{ matrix.distrib }}

deliver-packages:
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
arch: amd64
runner_name: ubuntu-24.04
- package_extension: rpm
image: almalinux:9
distrib: el9
arch: amd64
runner_name: ubuntu-24.04
- package_extension: deb
image: debian:bullseye
distrib: bullseye
arch: amd64
runner_name: ubuntu-24.04
- package_extension: deb
image: debian:bookworm
distrib: bookworm
arch: amd64
runner_name: ubuntu-24.04
- package_extension: deb
image: ubuntu:jammy
distrib: jammy
arch: amd64
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 }}

name: Test perl CPAN libs packages on ${{ matrix.package_extension }} ${{ matrix.distrib }} ${{ matrix.arch }}
steps:
- name: Install zstd, perl and Centreon repositories
run: |
if [ "${{ matrix.package_extension }}" == "rpm" ]; then
dnf install -y zstd perl epel-release 'dnf-command(config-manager)'
dnf config-manager --set-enabled powertools || true # alma 8
dnf config-manager --set-enabled crb || true # alma 9
# Add Centreon plugins repositories
echo -e '[centreon-plugins-stable]\nname=centreon plugins stable x86_64\nbaseurl=https://packages.centreon.com/rpm-plugins/${{ matrix.distrib }}/stable/x86_64\nenabled=1\ngpgcheck=1\ngpgkey=https://yum-gpg.centreon.com/RPM-GPG-KEY-CES\n[centreon-plugins-stable-noarch]\nname=centreon plugins stable noarch\nbaseurl=https://packages.centreon.com/rpm-plugins/${{ matrix.distrib }}/stable/noarch\nenabled=1\ngpgcheck=1\ngpgkey=https://yum-gpg.centreon.com/RPM-GPG-KEY-CES\n' >> /etc/yum.repos.d/centreon-plugins.repo
else
apt-get update
apt-get install -y zstd perl wget gpg apt-utils
# Add Centreon plugins repositories
if [ "${{ matrix.distrib }}" == "jammy" ]; then
echo "deb https://packages.centreon.com/ubuntu-plugins-stable/ ${{ matrix.distrib }} main" | tee /etc/apt/sources.list.d/centreon-plugins.list
else
echo "deb https://packages.centreon.com/apt-plugins-stable/ ${{ matrix.distrib }} main" | tee /etc/apt/sources.list.d/centreon-plugins.list
fi
wget -O- https://apt-key.centreon.com | gpg --dearmor | tee /etc/apt/trusted.gpg.d/centreon.gpg > /dev/null 2>&1
apt-get update
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
- if: ${{ matrix.package_extension == 'rpm' }}
name: Install packages
run: |
error_log="install_error_${{ matrix.distrib }}_${{ matrix.arch }}.log"
for package in ./*.rpm; do
# List dependencies
dependencies=$(rpm -qpR $package)
for dependency in $dependencies; do
# If the dependency has been built in the same workflow, install it
if [ -f $dependency*.rpm ]; then
dnf install -y $dependency*.rpm 2>> $error_log || { echo "Error during installation of $package" >> $error_log; true; }
fi
done
# Install package
dnf install -y $package 2>> $error_log || { echo "Error during installation of $package" >> $error_log; true; }
# Uninstall package with all his dependencies
dnf autoremove -y $(echo $package | sed 's/_[0-9].*\.rpm//' | sed 's/.\///') 2>> $error_log || true
done
# Si le fichier error_log existe et n'est pas vide, le workflow est en erreur
if [ -s $error_log ]; then
cat $error_log
exit 1
fi
shell: bash
- if: ${{ matrix.package_extension == 'deb' }}
name: Install packages
run: |
error_log="install_error_${{ matrix.distrib }}_${{ matrix.arch }}.log"
for package in ./*.deb; do
# List dependencies
dependencies=$(dpkg-deb -I $package | grep Depends | sed 's/Depends: //')
for dependency in $dependencies; do
# If the dependency has been built in the same workflow, install it
if [ -f $dependency*.deb ]; then
apt-get install -y $dependency*.deb 2>> $error_log || { echo "Error during installation of $package" >> $error_log; true; }
fi
done
# Install package
apt-get install -y $package 2>> $error_log || { echo "Error during installation of $package" >> $error_log; true; }
# Uninstall package with all his dependencies
# Package name is the name of the file less the version and the .deb extension, and without the "./" at the beginning
apt-get autoremove -y --purge $(echo $package | sed 's/_[0-9].*\.deb//' | sed 's/.\///') 2>> $error_log || true
done
# Si le fichier error_log existe et n'est pas vide, le workflow est en erreur
if [ -s $error_log ]; then
cat $error_log
exit 1
fi
shell: bash
- name: Upload error log
if: failure()
uses: actions/upload-artifact@v4
with:
name: install_error_log_${{ matrix.distrib }}-${{ matrix.arch }}
path: install_error_${{ matrix.distrib }}_${{ matrix.arch }}.log

deliver-packages:
needs: [get-environment, sign-rpm, download-and-cache-deb, test-packages]
if: |
(contains(fromJson('["testing", "unstable"]'), needs.get-environment.outputs.stability) || ( needs.get-environment.outputs.stability == 'stable' && github.event_name != 'workflow_dispatch')) &&
! cancelled() &&
Expand Down
Loading

0 comments on commit 263734e

Please sign in to comment.