enh(ci): package plugins using nfpm (#4473)

This commit is contained in:
Kevin Duret 2023-06-27 15:55:12 +02:00 committed by GitHub
parent 6143363aac
commit 058eb41733
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
50 changed files with 401 additions and 552 deletions

View File

@ -24,10 +24,11 @@ runs:
using: "composite"
steps:
- name: Use cache DEB files
uses: actions/cache@v3
uses: actions/cache/restore@v3
with:
path: ./*.deb
key: ${{ inputs.cache_key }}
fail-on-cache-miss: true
- name: Publish DEBs to Nexus
run: |

View File

@ -24,10 +24,11 @@ runs:
using: "composite"
steps:
- name: Use cache DEB files
uses: actions/cache@v3
uses: actions/cache/restore@v3
with:
path: ./*.deb
key: ${{ inputs.cache_key }}
fail-on-cache-miss: true
- uses: jfrog/setup-jfrog-cli@v3
env:

View File

@ -1,84 +1,85 @@
name: package
description: Package module
description: Package module using nfpm
inputs:
nfpm_file_pattern:
description: The pattern of the nfpm configuration file(s)
required: true
package_extension:
description: The package extension (deb or rpm)
required: true
distrib:
description: The package distrib (el8, bullseye...)
required: true
image_name:
description: The docker image name
required: true
script_name:
description: The packaging script name
plugins:
description: List of plugins to package
description: The package distrib
required: true
version:
description: The plugins version
required: true
description: The package version
required: false
release:
description: The release number
description: The package release number
required: false
commit_hash:
description: The commit hash
required: true
cache_key:
description: The package files cache key
required: true
sign:
description: Wether to sign the package or not
default: ""
registry_url:
description: Docker registry url
rpm_gpg_key:
description: The rpm gpg key
required: true
registry_username:
description: Docker registry username
rpm_gpg_signing_key_id:
description: The rpm gpg signing key identifier
required: true
registry_password:
description: Docker registry password
rpm_gpg_signing_passphrase:
description: The rpm gpg signing passphrase
required: true
runs:
using: composite
steps:
- name: Login to Registry
uses: docker/login-action@v2
with:
registry: ${{ inputs.registry_url }}
username: ${{ inputs.registry_username }}
password: ${{ inputs.registry_password }}
- name: Import gpg key
env:
RPM_GPG_SIGNING_KEY: ${{ inputs.rpm_gpg_key }}
run: echo -n "$RPM_GPG_SIGNING_KEY" > key.gpg
shell: bash
- name: Package
uses: ./.github/actions/runner-docker
with:
script_name: ${{ inputs.script_name }}
image_name: ${{ inputs.image_name }}
image_version: latest
registry_url: ${{ inputs.registry_url }}
registry_username: ${{ inputs.registry_username }}
registry_password: ${{ inputs.registry_password }}
params: ${{ inputs.version }} ${{ inputs.release }} "${{ inputs.plugins }}"
- name: Build ${{ inputs.package_extension }} files
env:
RPM_GPG_SIGNING_KEY_ID: ${{ inputs.rpm_gpg_signing_key_id }}
RPM_GPG_SIGNING_PASSPHRASE: ${{ inputs.rpm_gpg_signing_passphrase }}
run: |
export VERSION="${{ inputs.version }}"
export RELEASE="${{ inputs.release }}"
- name: Sign
if: ${{ inputs.sign != '' && inputs.package_extension == 'rpm' }}
uses: ./.github/actions/runner-docker
with:
script_name: rpm-signing
image_name: rpm-signing
image_version: ubuntu
registry_url: ${{ inputs.registry_url }}
registry_username: ${{ inputs.registry_username }}
registry_password: ${{ inputs.registry_password }}
if [ "${{ inputs.package_extension }}" = "rpm" ]; then
export DIST=".${{ inputs.distrib }}"
else
export DIST=""
fi
- name: Cache packaged files
uses: actions/cache@v3
with:
path: ./*.${{ inputs.package_extension }}
key: ${{ inputs.cache_key }}
export RPM_SIGNING_KEY_FILE="$(pwd)/key.gpg"
export RPM_SIGNING_KEY_ID="$RPM_GPG_SIGNING_KEY_ID"
export NFPM_RPM_PASSPHRASE="$RPM_GPG_SIGNING_PASSPHRASE"
- if: ${{ inputs.distrib == 'el8' }}
for FILE in ${{ inputs.nfpm_file_pattern }}; do
DIRNAME=$(dirname $FILE)
BASENAME=$(basename $FILE)
cd $DIRNAME
sed -i "s/@COMMIT_HASH@/${{ inputs.commit_hash }}/g" $BASENAME
nfpm package --config $BASENAME --packager ${{ inputs.package_extension }}
cd -
mv $DIRNAME/*.${{ inputs.package_extension }} ./
done
shell: bash
- name: Upload package artifacts
uses: actions/upload-artifact@v3
with:
name: packages-${{ inputs.distrib }}
path: ./*.${{ inputs.package_extension }}
retention-days: 1
- name: Cache packages
uses: actions/cache/save@v3
with:
path: ./*.${{ inputs.package_extension }}
key: ${{ inputs.cache_key }}

View File

@ -36,10 +36,11 @@ runs:
using: "composite"
steps:
- name: Use cache RPM files
uses: actions/cache@v3
uses: actions/cache/restore@v3
with:
path: ./*.rpm
key: ${{ inputs.cache_key }}
fail-on-cache-miss: true
- name: Setup awscli
run: |

View File

@ -21,10 +21,11 @@ runs:
using: "composite"
steps:
- name: Use cache RPM files
uses: actions/cache@v3
uses: actions/cache/restore@v3
with:
path: ./*.rpm
key: ${{ inputs.cache_key }}
fail-on-cache-miss: true
- uses: jfrog/setup-jfrog-cli@v3
env:

View File

@ -10,7 +10,7 @@ baseurl=https://repo.goreleaser.com/yum/
enabled=1
gpgcheck=0' | tee /etc/yum.repos.d/goreleaser.repo
dnf -y install git gettext rpm-build dos2unix python3 epel-release nfpm zstd
dnf -y install git gettext rpm-build dos2unix python3 epel-release nfpm jq zstd
dnf -y install perl-App-cpanminus perl-JSON
cpanm App::FatPacker
cpanm File::Copy::Recursive

View File

@ -10,7 +10,7 @@ baseurl=https://repo.goreleaser.com/yum/
enabled=1
gpgcheck=0' | tee /etc/yum.repos.d/goreleaser.repo
dnf -y install git gettext rpm-build dos2unix python3 epel-release nfpm zstd
dnf -y install git gettext rpm-build dos2unix python3 epel-release nfpm jq zstd
dnf -y install perl-App-cpanminus perl-JSON
cpanm App::FatPacker
cpanm File::Copy::Recursive

View File

@ -10,8 +10,8 @@ baseurl=https://repo.goreleaser.com/yum/
enabled=1
gpgcheck=0' | tee /etc/yum.repos.d/goreleaser.repo
yum -y install git gettext rpm-build dos2unix python3 epel-release nfpm zstd
yum -y install perl-App-FatPacker perl-File-Copy-Recursive perl-JSON
yum -y install git gettext rpm-build dos2unix python3 epel-release nfpm
yum -y install perl-App-FatPacker perl-File-Copy-Recursive perl-JSON jq zstd
yum clean all
EOF

View File

@ -0,0 +1,88 @@
name: "@PACKAGE_NAME@"
arch: "all"
platform: "linux"
version_schema: "none"
version: "${VERSION}"
release: "${RELEASE}${DIST}"
section: "default"
priority: "optional"
maintainer: "Centreon <contact@centreon.com>"
description: |
@SUMMARY@
Commit: @COMMIT_HASH@
vendor: "Centreon"
homepage: "https://centreon.com"
license: "Apache-2.0"
contents:
- src: "../../build/@PLUGIN_NAME@/*"
dst: "/usr/lib/centreon/plugins/"
file_info:
mode: 0775
conflicts:
[@CONFLICTS@]
replaces:
[@REPLACES@]
provides:
[@PROVIDES@]
overrides:
rpm:
depends: [
perl(Digest::MD5),
perl(Pod::Find),
perl-Net-Curl,
perl(URI::Encode),
perl(LWP::UserAgent),
perl(LWP::Protocol::https),
perl(IO::Socket::SSL),
perl(URI),
perl(HTTP::ProxyPAC),
perl-CryptX,
perl(MIME::Base64),
perl(JSON::XS),
perl-JSON-Path,
perl-KeePass-Reader,
perl(Storable),
perl(POSIX),
perl(Encode),
@RPM_DEPENDENCIES@
]
conflicts:
[@RPM_CONFLICTS@]
replaces:
[@RPM_REPLACES@]
provides:
[@RPM_PROVIDES@]
deb:
depends: [
libpod-parser-perl,
libnet-curl-perl,
liburi-encode-perl,
libwww-perl,
liblwp-protocol-https-perl,
libhttp-cookies-perl,
libio-socket-ssl-perl,
liburi-perl,
libhttp-proxypac-perl,
libcryptx-perl,
libjson-xs-perl,
libjson-path-perl,
libcrypt-argon2-perl,
libkeepass-reader-perl,
libdatetime-perl,
@RPM_DEPENDENCIES@
]
conflicts:
[@DEB_CONFLICTS@]
replaces:
[@DEB_REPLACES@]
provides:
[@DEB_PROVIDES@]
rpm:
compression: zstd
signature:
key_file: ${RPM_SIGNING_KEY_FILE}
key_id: ${RPM_SIGNING_KEY_ID}

View File

@ -1,24 +0,0 @@
Package: @NAME@
Architecture: all
Description: @SUMMARY@@CUSTOM_PKG_DATA@
Depends:
${shlibs:Depends},
${misc:Depends},
libpod-parser-perl,
libnet-curl-perl,
liburi-encode-perl,
libwww-perl,
liblwp-protocol-https-perl,
libhttp-cookies-perl,
libio-socket-ssl-perl,
liburi-perl,
libhttp-proxypac-perl,
libcryptx-perl,
libjson-xs-perl,
libjson-path-perl,
libcrypt-argon2-perl,
libkeepass-reader-perl,
libdatetime-perl,
@REQUIRES@

View File

@ -1,12 +0,0 @@
Source: centreon-plugins
Section: net
Priority: optional
Maintainer: Centreon <contact@centreon.com>
Build-Depends:
debhelper-compat (= 12),
libapp-fatpacker-perl,
libfile-copy-recursive-perl,
libjson-perl
Standards-Version: 4.5.0
Homepage: https://www.centreon.com

View File

@ -1,29 +0,0 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: centreon-collect
Upstream-Contact: Centreon <contact@centreon.com>
Source: https://www.centreon.com
Files: *
Copyright: 2023 Centreon
License: Apache-2.0
Files: debian/*
Copyright: 2023 Centreon
License: Apache-2.0
License: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
.
https://www.apache.org/licenses/LICENSE-2.0
.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
.
On Debian systems, the complete text of the Apache version 2.0 license
can be found in "/usr/share/common-licenses/Apache-2.0".

View File

@ -1 +0,0 @@
plugins/@DIR@/@NAME@ usr/lib/centreon/plugins

View File

@ -1,7 +0,0 @@
#!/usr/bin/make -f
%:
dh $@
override_dh_clean:
override_dh_auto_build:

View File

@ -1 +0,0 @@
3.0 (quilt)

View File

@ -1,48 +0,0 @@
Name: @NAME@
Version: @VERSION@
Release: @RELEASE@%{?dist}
Source0: %{name}-%{version}.tar.gz
Summary: @SUMMARY@
Group: Development/Libraries
License: Apache-2.0
URL: https://www.centreon.com/
BuildArch: noarch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
AutoReqProv: no
AutoReqProv: no
Requires: perl(Digest::MD5)
Requires: perl(Pod::Find)
Requires: perl-Net-Curl
Requires: perl(URI::Encode)
Requires: perl(LWP::UserAgent)
Requires: perl(LWP::Protocol::https)
Requires: perl(IO::Socket::SSL)
Requires: perl(URI)
Requires: perl(HTTP::ProxyPAC)
Requires: perl-CryptX
Requires: perl(MIME::Base64)
Requires: perl(JSON::XS)
Requires: perl-JSON-Path
Requires: perl-KeePass-Reader
Requires: perl(Storable)
Requires: perl(POSIX)
Requires: perl(Encode)
@REQUIRES@
@CUSTOM_PKG_DATA@
%description
Centreon plugin
%prep
%setup -q
%install
rm -rf %{buildroot}
mkdir -p %{buildroot}/usr/lib/centreon/plugins/
%{__install} -m 775 *.pl %{buildroot}%{_prefix}/lib/centreon/plugins/
%files
%defattr(-,root,root,-)
%{_prefix}/lib/centreon/plugins/@PLUGIN_NAME@

View File

@ -1,55 +0,0 @@
#!/bin/bash
set -e
VERSION="$1"
RELEASE="$2"
PLUGINS="$3"
cd /src
mkdir -p centreon-plugins/plugins
cp -R .github/packaging/debian centreon-plugins/debian
mv centreon-plugins/debian/control.head.template centreon-plugins/debian/control
for PLUGIN in $PLUGINS; do
PACKAGE_PATH=$PLUGIN
if [[ "$PLUGIN" =~ (.+)"=>"(.+) ]]; then
PACKAGE_PATH=$(echo ${BASH_REMATCH[1]})
PLUGIN=$(echo ${BASH_REMATCH[2]})
fi
PLUGIN_NAME_LOWER=$(echo "$PLUGIN" | tr '[:upper:]' '[:lower:]')
echo "::group::Preparing $PLUGIN_NAME_LOWER"
mkdir centreon-plugins/plugins/$PLUGIN
cp -R build/$PLUGIN/*.pl centreon-plugins/plugins/$PLUGIN
# Process package files
pkg_values=($(cat "packaging/$PACKAGE_PATH/pkg.json" | jq -r '.pkg_name,.plugin_name'))
pkg_summary=$(echo "${pkg_values[0]}")
plugin_name=$(echo "${pkg_values[1]}")
deb_dependencies=$(cat "packaging/$PACKAGE_PATH/deb.json" | jq -r '.dependencies | join(",\\n ")')
deb_custom_pkg_data=$(cat "packaging/$PACKAGE_PATH/deb.json" | jq -r '.custom_pkg_data // "" | if . != "" then ("\\n" + .) else "" end')
sed -e "s/@NAME@/$PLUGIN_NAME_LOWER/g" \
-e "s/@SUMMARY@/$pkg_summary/g" \
-e "s/@REQUIRES@/$deb_dependencies/g" \
-e "s/@CUSTOM_PKG_DATA@/$deb_custom_pkg_data/g" \
< centreon-plugins/debian/control.body.template \
>> centreon-plugins/debian/control
# .install file
sed -e "s/@DIR@/$PLUGIN/g" -e "s/@NAME@/$plugin_name/g" < centreon-plugins/debian/plugin.install.template >> centreon-plugins/debian/$PLUGIN_NAME_LOWER.install
echo "::endgroup::"
done
rm -f centreon-plugins/debian/*.template
tar czf centreon-plugins-${VERSION}-${RELEASE}.tar.gz centreon-plugins
cd centreon-plugins
debmake -f "Centreon" -e "contact@centreon.com" -u "${VERSION}-${RELEASE}" -y -r "bullseye"
debuild-pbuilder --no-lintian

View File

@ -1,37 +0,0 @@
#!/bin/bash
set -e
VERSION="$1"
RELEASE="$2"
PLUGINS="$3"
for PLUGIN_NAME in $PLUGINS; do
echo "::group::Packaging $PLUGIN_NAME"
PACKAGE_PATH=$PLUGIN_NAME
if [[ "$PLUGIN_NAME" =~ (.+)"=>"(.+) ]]; then
PACKAGE_PATH=$(echo ${BASH_REMATCH[1]})
PLUGIN_NAME=$(echo ${BASH_REMATCH[2]})
fi
# Process specfile
rm -f plugin.specfile
python3 .github/scripts/create-spec-file.py "$PACKAGE_PATH" "$PLUGIN_NAME" "$VERSION" "$RELEASE"
rm -rf $HOME/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
mkdir -p $HOME/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
mv build/$PLUGIN_NAME $PLUGIN_NAME-$VERSION
tar czf $PLUGIN_NAME-$VERSION.tar.gz $PLUGIN_NAME-$VERSION
mv $PLUGIN_NAME-$VERSION.tar.gz $HOME/rpmbuild/SOURCES/
cd $PLUGIN_NAME-$VERSION
rpmbuild -ba ../plugin.specfile
find $HOME/rpmbuild/RPMS -name *.rpm -exec mv {} /src/ \;
cd -
echo "::endgroup::"
done

View File

@ -1,5 +0,0 @@
#!/bin/bash
set -ex
export GPG_TTY=$(tty)
rpmsign --addsign /src/*.rpm

View File

@ -29,6 +29,7 @@ jobs:
package:
needs:
- get-environment
runs-on: ubuntu-22.04
strategy:
matrix:
include:
@ -41,18 +42,32 @@ jobs:
- package_extension: deb
image: packaging-plugins-bullseye
distrib: bullseye
container:
image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ matrix.image }}
credentials:
username: ${{ secrets.DOCKER_REGISTRY_ID }}
password: ${{ secrets.DOCKER_REGISTRY_PASSWD }}
name: package ${{ matrix.distrib }}
uses: ./.github/workflows/package.yml
with:
nfpm_file_pattern: "connectors/vmware/packaging/centreon-plugin-virtualization-vmware-daemon.yaml"
distrib: ${{ matrix.distrib }}
package_extension: ${{ matrix.package_extension }}
image_name: ${{ matrix.image }}
version: ${{ needs.get-environment.outputs.version }}
release: ${{ needs.get-environment.outputs.release }}
cache_key: ${{ github.sha }}-${{ github.run_id }}-${{ matrix.package_extension }}-${{ matrix.distrib }}
secrets: inherit
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Package
uses: ./.github/actions/package
with:
nfpm_file_pattern: "connectors/vmware/packaging/centreon-plugin-virtualization-vmware-daemon.yaml"
distrib: ${{ matrix.distrib }}
package_extension: ${{ matrix.package_extension }}
version: ${{ needs.get-environment.outputs.version }}
release: ${{ needs.get-environment.outputs.release }}
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 }}
deliver-rpm:
needs:

View File

@ -1,117 +0,0 @@
on:
workflow_call:
inputs:
nfpm_file_pattern:
type: string
description: The pattern of the nfpm configuration file(s)
required: true
distrib:
type: string
description: The distrib
required: true
package_extension:
type: string
description: The package extension (deb or rpm)
required: true
image_name:
type: string
description: The image name
required: true
version:
type: string
description: The package version
required: false
release:
type: string
description: The release number
required: false
source_cache_key:
type: string
description: The source files cache key
required: false
source_cache_path:
type: string
description: The source files path
required: false
cache_key:
type: string
description: The package files cache key
required: true
jobs:
package:
runs-on: ubuntu-22.04
container:
image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ inputs.image_name }}
credentials:
username: ${{ secrets.DOCKER_REGISTRY_ID }}
password: ${{ secrets.DOCKER_REGISTRY_PASSWD }}
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Import gpg key
env:
RPM_GPG_SIGNING_KEY: ${{ secrets.RPM_GPG_SIGNING_KEY }}
run: echo -n "$RPM_GPG_SIGNING_KEY" > key.gpg
shell: bash
- if: ${{ inputs.source_cache_key != '' && inputs.source_cache_path != '' }}
name: Import source files
uses: actions/cache/restore@v3
with:
path: ${{ inputs.source_cache_path }}
key: ${{ inputs.source_cache_key }}
fail-on-cache-miss: true
- name: Build ${{ inputs.package_extension }} files
env:
RPM_GPG_SIGNING_KEY_ID: ${{ secrets.RPM_GPG_SIGNING_KEY_ID }}
RPM_GPG_SIGNING_PASSPHRASE: ${{ secrets.RPM_GPG_SIGNING_PASSPHRASE }}
run: |
export VERSION="${{ inputs.version }}"
export RELEASE="${{ inputs.release }}"
if [ "${{ inputs.package_extension }}" = "rpm" ]; then
export DIST=".${{ inputs.distrib }}"
export APACHE_USER="apache"
export APACHE_GROUP="apache"
else
export DIST=""
export APACHE_USER="www-data"
export APACHE_GROUP="www-data"
fi
export PERL_SITELIB="$(eval "$(perl -V:installsitelib)"; echo $installsitelib)"
export PERL_VENDORLIB="$(eval "$(perl -V:installvendorlib)"; echo $installvendorlib)"
export RPM_SIGNING_KEY_FILE="$(pwd)/key.gpg"
export RPM_SIGNING_KEY_ID="$RPM_GPG_SIGNING_KEY_ID"
export NFPM_RPM_PASSPHRASE="$RPM_GPG_SIGNING_PASSPHRASE"
for FILE in ${{ inputs.nfpm_file_pattern }}; do
DIRNAME=$(dirname $FILE)
BASENAME=$(basename $FILE)
cd $DIRNAME
sed -i \
"s/@COMMIT_HASH@/${{ github.sha }}/g; s#@PERL_SITELIB@#${PERL_SITELIB}#g; s#@PERL_VENDORLIB@#${PERL_VENDORLIB}#g" \
$BASENAME
nfpm package --config $BASENAME --packager ${{ inputs.package_extension }}
cd -
mv $DIRNAME/*.${{ inputs.package_extension }} ./
done
shell: bash
- name: Upload package artifacts
uses: actions/upload-artifact@v3
with:
name: packages-${{ inputs.distrib }}
path: ./*.${{ inputs.package_extension }}
retention-days: 1
- name: Cache packages
uses: actions/cache@v3
with:
path: ./*.${{ inputs.package_extension }}
key: ${{ inputs.cache_key }}

View File

@ -49,6 +49,7 @@ jobs:
package:
needs:
- get-sources
runs-on: ubuntu-22.04
strategy:
matrix:
include:
@ -61,18 +62,37 @@ jobs:
- package_extension: deb
image: packaging-plugins-bullseye
distrib: bullseye
container:
image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ matrix.image }}
credentials:
username: ${{ secrets.DOCKER_REGISTRY_ID }}
password: ${{ secrets.DOCKER_REGISTRY_PASSWD }}
name: package ${{ matrix.distrib }}
uses: ./.github/workflows/package.yml
with:
nfpm_file_pattern: "dependencies/perl-vmware-vsphere/packaging/perl-vmware-vsphere.yaml"
distrib: ${{ matrix.distrib }}
package_extension: ${{ matrix.package_extension }}
image_name: ${{ matrix.image }}
source_cache_key: ${{ github.sha }}-${{ github.run_id }}-sources-perl-vmware-vsphere
source_cache_path: vmware-vsphere-cli-distrib
cache_key: ${{ github.sha }}-${{ github.run_id }}-${{ matrix.package_extension }}-${{ matrix.distrib }}
secrets: inherit
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Import source files
uses: actions/cache/restore@v3
with:
path: vmware-vsphere-cli-distrib
key: ${{ github.sha }}-${{ github.run_id }}-sources-perl-vmware-vsphere
fail-on-cache-miss: true
- name: Package
uses: ./.github/actions/package
with:
nfpm_file_pattern: "dependencies/perl-vmware-vsphere/packaging/perl-vmware-vsphere.yaml"
distrib: ${{ matrix.distrib }}
package_extension: ${{ matrix.package_extension }}
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 }}
deliver-rpm:
needs:

View File

@ -46,10 +46,11 @@ jobs:
- name: Checkout sources
uses: actions/checkout@v3
- uses: actions/cache@v3
- uses: actions/cache/restore@v3
with:
path: ./build/
key: fatpacked-plugins-${{ github.sha }}-${{ github.run_id }}
fail-on-cache-miss: true
- name: Deliver sources
uses: ./.github/actions/release-sources

View File

@ -1,88 +0,0 @@
on:
workflow_call:
inputs:
plugins:
required: true
type: string
version:
required: true
type: string
release:
required: true
type: string
secrets:
registry_username:
required: true
registry_password:
required: true
jobs:
fatpacker:
runs-on: ubuntu-22.04
steps:
- name: Checkout sources
uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Prepare FatPacker
uses: shogo82148/actions-setup-perl@v1
with:
perl-version: '5.34'
install-modules-with: cpm
install-modules: App::FatPacker File::Copy::Recursive JSON
- name: Run FatPacker
run: |
COMMIT=$(git log -1 HEAD --pretty=format:%h)
perl .github/scripts/plugins-source.container.pl "${{ inputs.plugins }}" "${{ inputs.version }} ($COMMIT)"
- uses: actions/cache@v3
with:
path: ./build/
key: fatpacked-plugins-${{ github.sha }}-${{ github.run_id }}
package:
runs-on: ubuntu-22.04
needs: [fatpacker]
strategy:
matrix:
include:
- package_extension: rpm
image: packaging-plugins-centos7
distrib: el7
- package_extension: rpm
image: packaging-plugins-alma8
distrib: el8
- package_extension: rpm
image: packaging-plugins-alma9
distrib: el9
- package_extension: deb
image: packaging-plugins-bullseye
distrib: bullseye
name: "package ${{ matrix.distrib }}"
steps:
- name: Checkout sources
uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: ./build/
key: fatpacked-plugins-${{ github.sha }}-${{ github.run_id }}
- uses: ./.github/actions/package
with:
package_extension: ${{ matrix.package_extension }}
distrib: ${{ matrix.distrib }}
image_name: ${{ matrix.image }}
script_name: plugin-packaging-${{ matrix.package_extension }}
plugins: ${{ inputs.plugins }}
version: ${{ inputs.version }}
release: ${{ inputs.release }}
cache_key: ${{ github.sha }}-${{ github.run_id }}-${{ matrix.package_extension }}-${{ matrix.distrib }}
sign: true
registry_url: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}
registry_username: ${{ secrets.registry_username }}
registry_password: ${{ secrets.registry_password }}

View File

@ -84,17 +84,144 @@ jobs:
fi
shell: bash
package:
fatpacker:
if: ${{ needs.get-plugins.outputs.plugins != '' }}
needs: [get-environment, get-plugins]
uses: ./.github/workflows/plugin-package.yml
with:
plugins: ${{ needs.get-plugins.outputs.plugins }}
version: ${{ needs.get-environment.outputs.version }}
release: ${{ needs.get-environment.outputs.release }}
secrets:
registry_username: ${{ secrets.DOCKER_REGISTRY_ID }}
registry_password: ${{ secrets.DOCKER_REGISTRY_PASSWD }}
runs-on: ubuntu-22.04
steps:
- name: Checkout sources
uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Prepare FatPacker
uses: shogo82148/actions-setup-perl@v1
with:
perl-version: '5.34'
install-modules-with: cpm
install-modules: App::FatPacker File::Copy::Recursive JSON
- name: Run FatPacker
run: |
COMMIT=$(git log -1 HEAD --pretty=format:%h)
perl .github/scripts/plugins-source.container.pl "${{ needs.get-plugins.outputs.plugins }}" "${{ needs.get-environment.outputs.version }} ($COMMIT)"
- uses: actions/cache/save@v3
with:
path: ./build/
key: fatpacked-plugins-${{ github.sha }}-${{ github.run_id }}
package:
runs-on: ubuntu-22.04
needs: [get-environment, get-plugins, fatpacker]
strategy:
fail-fast: false
matrix:
include:
- package_extension: rpm
image: packaging-plugins-centos7
distrib: el7
- package_extension: rpm
image: packaging-plugins-alma8
distrib: el8
- package_extension: rpm
image: packaging-plugins-alma9
distrib: el9
- package_extension: deb
image: packaging-plugins-bullseye
distrib: bullseye
container:
image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ matrix.image }}
credentials:
username: ${{ secrets.DOCKER_REGISTRY_ID }}
password: ${{ secrets.DOCKER_REGISTRY_PASSWD }}
name: "package ${{ matrix.distrib }}"
steps:
- name: Checkout sources
uses: actions/checkout@v3
- uses: actions/cache/restore@v3
with:
path: ./build/
key: fatpacked-plugins-${{ github.sha }}-${{ github.run_id }}
fail-on-cache-miss: true
- run: |
PLUGINS="${{ needs.get-plugins.outputs.plugins }}"
for PLUGIN in $PLUGINS; do
PACKAGE_PATH=$PLUGIN
if [[ "$PLUGIN" =~ (.+)"=>"(.+) ]]; then
PACKAGE_PATH=$(echo ${BASH_REMATCH[1]})
PLUGIN=$(echo ${BASH_REMATCH[2]})
fi
PLUGIN_NAME_LOWER=$(echo "$PLUGIN" | tr '[:upper:]' '[:lower:]')
echo "::group::Preparing $PLUGIN_NAME_LOWER"
# Process package files
pkg_values=($(cat "packaging/$PACKAGE_PATH/pkg.json" | jq -r '.pkg_name,.plugin_name'))
pkg_summary=$(echo "${pkg_values[0]}")
plugin_name=$(echo "${pkg_values[1]}")
conflicts=$(cat "packaging/$PACKAGE_PATH/pkg.json" | jq -r '.conflicts // [] | join(",")')
replaces=$(cat "packaging/$PACKAGE_PATH/pkg.json" | jq -r '.replaces // [] | join(",")')
provides=$(cat "packaging/$PACKAGE_PATH/pkg.json" | jq -r '.provides // [] | join(",")')
deb_dependencies=$(cat "packaging/$PACKAGE_PATH/deb.json" | jq -r '.dependencies // [] | join(",")')
deb_conflicts=$(cat "packaging/$PACKAGE_PATH/deb.json" | jq -r '.conflicts // [] | join(",")')
deb_replaces=$(cat "packaging/$PACKAGE_PATH/deb.json" | jq -r '.replaces // [] | join(",")')
deb_provides=$(cat "packaging/$PACKAGE_PATH/deb.json" | jq -r '.provides // [] | join(",")')
rpm_dependencies=$(cat "packaging/$PACKAGE_PATH/rpm.json" | jq -r '.dependencies // [] | join(",")')
rpm_conflicts=$(cat "packaging/$PACKAGE_PATH/rpm.json" | jq -r '.conflicts // [] | join(",")')
rpm_replaces=$(cat "packaging/$PACKAGE_PATH/rpm.json" | jq -r '.replaces // [] | join(",")')
rpm_provides=$(cat "packaging/$PACKAGE_PATH/rpm.json" | jq -r '.provides // [] | join(",")')
sed -e "s/@PLUGIN_NAME@/$PLUGIN/g;" \
-e "s/@SUMMARY@/$pkg_summary/g" \
-e "s/@CONFLICTS@/$conflicts/g" \
-e "s/@REPLACES@/$replaces/g" \
-e "s/@PROVIDES@/$provides/g" \
-e "s/@DEB_DEPENDENCIES@/$deb_dependencies/g" \
-e "s/@DEB_CONFLICTS@/$deb_conflicts/g" \
-e "s/@DEB_REPLACES@/$deb_replaces/g" \
-e "s/@DEB_PROVIDES@/$deb_provides/g" \
-e "s/@RPM_DEPENDENCIES@/$rpm_dependencies/g" \
-e "s/@RPM_CONFLICTS@/$rpm_conflicts/g" \
-e "s/@RPM_REPLACES@/$rpm_replaces/g" \
-e "s/@RPM_PROVIDES@/$rpm_provides/g" \
< .github/packaging/centreon-plugin.yaml.template \
>> .github/packaging/$PLUGIN.yaml
if [ "${{ matrix.package_extension }}" = "rpm" ]; then
sed -i "s/@PACKAGE_NAME@/$PLUGIN/g" \
.github/packaging/$PLUGIN.yaml
else
sed -i "s/@PACKAGE_NAME@/$PLUGIN_NAME_LOWER/g" \
.github/packaging/$PLUGIN.yaml
fi
cat .github/packaging/$PLUGIN.yaml
echo "::endgroup::"
done
shell: bash
- uses: ./.github/actions/package
with:
nfpm_file_pattern: ".github/packaging/*.yaml"
distrib: ${{ matrix.distrib }}
package_extension: ${{ matrix.package_extension }}
version: ${{ needs.get-environment.outputs.version }}
release: ${{ needs.get-environment.outputs.release }}
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 }}
deliver:
needs: [get-environment, package]

View File

@ -1,4 +1,9 @@
name: Functional tests
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
on:
workflow_dispatch:
pull_request:
@ -8,16 +13,19 @@ on:
jobs:
AWS_tests:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version: "16.x"
- name: Install Mockoon CLI
run: npm install -D @mockoon/cli
- name: Install perl dependencies
uses: shogo82148/actions-setup-perl@v1
with:
@ -38,8 +46,10 @@ jobs:
Storable
URI
URI::Encode
- name: Run Mockoon CLI
run: npx mockoon-cli start --data tests/resources/mockoon/cloud-aws-cloudtrail.json --port 3000
- name: Run plugin
run: |
sudo chmod -R +x tests/functional/

View File

@ -90,12 +90,6 @@ The following files are included by default:
* centreon/plugins/templates/hardware.pm,
* centreon/plugins/values.pm.
Extra entries can be used, for example to make a package obsoleting another one:
```bash
"custom_pkg_data": "Obsoletes: centreon-plugin-Old-Plugin",
```
#### Create package dependencies management files
In the previously created directory, create two new JSON files named *rpm.json* and *deb.json*.
@ -126,6 +120,14 @@ Example of *deb.json* file:
}
```
Extra entries can be used in *rpm.json* and *deb.json*, for example to make a package obsoleting another one:
```bash
"conflicts": "centreon-plugin-Old-Plugin",
"replaces": "centreon-plugin-Old-Plugin",
"provides": "centreon-plugin-Old-Plugin",
```
### Commit and push changes
In the project directory, create a new branch:

View File

@ -1,5 +1,6 @@
{
"dependencies": [
],
"custom_pkg_data": "Provides: centreon-plugin-network-cisco-ssms-restapi\\nReplaces: centreon-plugin-network-cisco-ssms-restapi\\nConflicts: centreon-plugin-network-cisco-ssms-restapi"
"dependencies": [],
"provides": ["centreon-plugin-network-cisco-ssms-restapi"],
"replaces": ["centreon-plugin-network-cisco-ssms-restapi"],
"conflicts": ["centreon-plugin-network-cisco-ssms-restapi"]
}

View File

@ -1,5 +1,5 @@
{
"dependencies": [
],
"custom_pkg_data": "Obsoletes: centreon-plugin-Network-Cisco-Ssms-Restapi"
"replaces": ["centreon-plugin-Network-Cisco-Ssms-Restapi"]
}

View File

@ -1,5 +1,4 @@
{
"dependencies": [
],
"custom_pkg_data": "Obsoletes: centreon-plugin-Applications-Elasticsearch"
"dependencies": [],
"replaces": ["centreon-plugin-Applications-Elasticsearch"]
}

View File

@ -6,5 +6,5 @@
"perl(DBI)",
"perl(DBD::mysql)"
],
"custom_pkg_data": "Obsoletes: centreon-plugin-meta"
"replaces": ["centreon-plugin-meta"]
}

View File

@ -4,5 +4,5 @@
"perl(Digest::MD5)",
"perl(NetAddr::IP)"
],
"custom_pkg_data": "Obsoletes: centreon-plugin-Generic-Snmp"
"replaces": ["centreon-plugin-Generic-Snmp"]
}

View File

@ -2,5 +2,5 @@
"dependencies": [
"perl(SNMP)"
],
"custom_pkg_data": "Obsoletes: centreon-plugin-App-Video-Openheadend-Snmp"
"replaces": ["centreon-plugin-App-Video-Openheadend-Snmp"]
}

View File

@ -2,5 +2,5 @@
"dependencies": [
"perl(DateTime)"
],
"custom_pkg_data": "Obsoletes: centreon-plugin-Cloud-Aws-Api"
"replaces": ["centreon-plugin-Cloud-Aws-Api"]
}

View File

@ -2,5 +2,5 @@
"dependencies": [
"perl(DateTime)"
],
"custom_pkg_data": "Obsoletes: centreon-plugin-Cloud-Aws-Api"
"replaces": ["centreon-plugin-Cloud-Aws-Api"]
}

View File

@ -3,5 +3,5 @@
"perl(DateTime)",
"perl(Digest::SHA)"
],
"custom_pkg_data": "Obsoletes: centreon-plugin-Cloud-Azure-Compute-Api"
"replaces": ["centreon-plugin-Cloud-Azure-Compute-Api"]
}

View File

@ -3,5 +3,5 @@
"perl(DateTime)",
"perl(Digest::SHA)"
],
"custom_pkg_data": "Obsoletes: centreon-plugin-Cloud-Azure-Monitor-Api"
"replaces": ["centreon-plugin-Cloud-Azure-Monitor-Api"]
}

View File

@ -5,5 +5,5 @@
"perl(DateTime-Format-Duration-ISO8601)",
"perl(DateTime::Duration)"
],
"custom_pkg_data": "Obsoletes: centreon-plugin-Cloud-Azure-Resources-Api"
"replaces": ["centreon-plugin-Cloud-Azure-Resources-Api"]
}

View File

@ -3,5 +3,5 @@
"perl(DateTime)",
"perl(Digest::SHA)"
],
"custom_pkg_data": "Obsoletes: centreon-plugin-Cloud-Azure-Nework-LoadBalancer-Api"
"replaces": ["centreon-plugin-Cloud-Azure-Nework-LoadBalancer-Api"]
}

View File

@ -3,5 +3,5 @@
"perl(DateTime)",
"perl(Digest::SHA)"
],
"custom_pkg_data": "Obsoletes: centreon-plugin-Cloud-Azure-Network-Api"
"replaces": ["centreon-plugin-Cloud-Azure-Network-Api"]
}

View File

@ -3,5 +3,5 @@
"perl(DateTime)",
"perl(Digest::SHA)"
],
"custom_pkg_data": "Obsoletes: centreon-plugin-Cloud-Azure-Storage-Api"
"replaces": ["centreon-plugin-Cloud-Azure-Storage-Api"]
}

View File

@ -1,5 +1,8 @@
{
"dependencies": [
"libsnmp-perl"
]
],
"replaces": ["centreon-plugin-hardware-devices-masterclock-ntpserver-snmp"],
"conflicts": ["centreon-plugin-hardware-devices-masterclock-ntpserver-snmp"],
"provides": ["centreon-plugin-hardware-devices-masterclock-ntpserver-snmp"]
}

View File

@ -7,6 +7,5 @@
"centreon/plugins/snmp.pm",
"snmp_standard/mode/uptime.pm",
"hardware/devices/masterclock/ntp100gps/snmp/"
],
"custom_pkg_data": "Obsoletes: centreon-plugin-Hardware-Devices-Masterclock-Ntpserver-Snmp"
]
}

View File

@ -1,5 +1,8 @@
{
"dependencies": [
"perl(SNMP)"
]
],
"replaces": ["centreon-plugin-Hardware-Devices-Masterclock-Ntpserver-Snmp"],
"conflicts": ["centreon-plugin-Hardware-Devices-Masterclock-Ntpserver-Snmp"],
"provides": ["centreon-plugin-Hardware-Devices-Masterclock-Ntpserver-Snmp"]
}

View File

@ -2,5 +2,5 @@
"dependencies": [
"perl(XML::Simple)"
],
"custom_pkg_data": "Obsoletes: centreon-plugin-Hardware-Servers-Hp-Ilo-Xmlapii"
"replaces": ["centreon-plugin-Hardware-Servers-Hp-Ilo-Xmlapii"]
}

View File

@ -8,5 +8,5 @@
"hardware/server/ibm/mgmt_cards/imm/snmp/",
"snmp_standard/mode/ntp.pm"
],
"custom_pkg_data": "Obsoletes: centreon-plugin-Hardware-servers-ibm-imm-snmp"
"replaces": ["centreon-plugin-Hardware-servers-ibm-imm-snmp"]
}

View File

@ -2,5 +2,5 @@
"dependencies": [
"perl(SNMP)"
],
"custom_pkg_data": "Obsoletes: centreon-plugin-Hardware-Storage-Oracle-Zfs-Snmp"
"replaces": ["centreon-plugin-Hardware-Storage-Oracle-Zfs-Snmp"]
}

View File

@ -1,5 +1,5 @@
{
"dependencies": [
],
"custom_pkg_data": "Obsoletes: centreon-plugin-Network-Cisco-Meraki-Restap"
"replaces": ["centreon-plugin-Network-Cisco-Meraki-Restap"]
}

View File

@ -4,5 +4,5 @@
"perl(DateTime)",
"perl(Digest::SHA)"
],
"custom_pkg_data": "Obsoletes: centreon-plugin-Network-Fritzbox"
"replaces": ["centreon-plugin-Network-Fritzbox"]
}

View File

@ -3,5 +3,5 @@
"perl(SNMP)",
"perl(DateTime)"
],
"custom_pkg_data": "Obsoletes: centreon-plugin-Operatingsystems-Hpuux-Snmp"
"replaces": ["centreon-plugin-Operatingsystems-Hpuux-Snmp"]
}