Skip to content

Commit 57fe495

Browse files
authored
docs(ci): new docs to explain plugins and cpan libs CI (#6150)
1 parent ca5bb2b commit 57fe495

8 files changed

Lines changed: 1462 additions & 8 deletions

File tree

.github/workflows/perl-cpan-libraries.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ on:
1313
push:
1414
branches:
1515
- develop
16-
- dev-[2-9][0-9].[0-9][0-9].x
1716
- master
18-
- "[2-9][0-9].[0-9][0-9].x"
1917
paths:
2018
- ".github/workflows/perl-cpan-libraries.yml"
2119
- ".github/packaging/cpan-libraries.json"

.github/workflows/perl-filesys-smbclient.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ on:
1313
push:
1414
branches:
1515
- develop
16-
- dev-[2-9][0-9].[0-9][0-9].x
1716
- master
18-
- "[2-9][0-9].[0-9][0-9].x"
1917
paths:
2018
- ".github/workflows/perl-filesys-smbclient.yml"
2119
- "dependencies/perl-filesys-smbclient/**"

.github/workflows/perl-keepass-reader.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ on:
1313
push:
1414
branches:
1515
- develop
16-
- dev-[2-9][0-9].[0-9][0-9].x
1716
- master
18-
- "[2-9][0-9].[0-9][0-9].x"
1917
paths:
2018
- ".github/workflows/perl-keepass-reader.yml"
2119
- "dependencies/perl-keepass-reader/**"

.github/workflows/plink.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ on:
1313
push:
1414
branches:
1515
- develop
16-
- dev-[2-9][0-9].[0-9][0-9].x
1716
- master
18-
- "[2-9][0-9].[0-9][0-9].x"
1917
paths:
2018
- ".github/workflows/plink.yml"
2119
- "dependencies/plink/**"
Lines changed: 320 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,320 @@
1+
# Perl CPAN Libraries CI/CD pipeline
2+
3+
## Purpose
4+
5+
Some Perl modules required by the plugins are not available in the official package repositories of supported Linux distributions (AlmaLinux, Debian, Ubuntu). The `perl-cpan-libraries` workflow builds and delivers these missing libraries as native `.rpm` and `.deb` packages so they can be installed as standard system packages alongside the plugins.
6+
7+
The pipeline is **smart**: before building anything, it checks whether a library is already available in the distribution's official repositories or in the Centreon stable Artifactory repository. Only libraries that are genuinely missing or at the wrong version are packaged.
8+
9+
---
10+
11+
## Overview
12+
13+
```mermaid
14+
flowchart TD
15+
TRIGGER([Trigger: PR / push / workflow_dispatch]) --> DEP[dependency-scan]
16+
DEP --> ENV[get-environment]
17+
18+
ENV --> CHK[check-official-repos\n8 distributions in parallel]
19+
ENV --> GPI[get-packaging-images\n9 images in parallel]
20+
21+
CHK --> GEN[generate-matrices\nMerge partials + filter stable Artifactory]
22+
GEN --> PRPM[package-rpm\nup to 50 in parallel]
23+
GEN --> PDEB[package-deb\nup to 50 in parallel]
24+
GPI --> PRPM
25+
GPI --> PDEB
26+
27+
PRPM --> MRPM[merge-package-rpm-artifacts]
28+
PDEB --> MDEB[merge-package-deb-artifacts]
29+
30+
MRPM --> SIGN[sign-rpm]
31+
MDEB --> CDEB[download-and-cache-deb]
32+
33+
SIGN --> TEST[test-packages\n9 distributions]
34+
CDEB --> TEST
35+
36+
TEST --> DP[deliver-packages\n8 distributions]
37+
DP --> SKIP[set-skip-label]
38+
39+
style TRIGGER fill:#555,color:#fff
40+
style DEP fill:#7b1fa2,color:#fff
41+
style ENV fill:#01579b,color:#fff
42+
style CHK fill:#01579b,color:#fff
43+
style GPI fill:#01579b,color:#fff
44+
style GEN fill:#01579b,color:#fff
45+
style PRPM fill:#1b5e20,color:#fff
46+
style PDEB fill:#1b5e20,color:#fff
47+
style MRPM fill:#1b5e20,color:#fff
48+
style MDEB fill:#1b5e20,color:#fff
49+
style SIGN fill:#1b5e20,color:#fff
50+
style CDEB fill:#1b5e20,color:#fff
51+
style TEST fill:#e65100,color:#fff
52+
style DP fill:#e65100,color:#fff
53+
style SKIP fill:#4a148c,color:#fff
54+
```
55+
56+
---
57+
58+
## Trigger conditions
59+
60+
| Event | Condition | Description |
61+
|---|---|---|
62+
| `pull_request` | Changes to `.github/workflows/perl-cpan-libraries.yml` or `.github/packaging/cpan-libraries.json` | Triggered when the workflow itself or the library catalogue is modified |
63+
| `push` | Branches `develop`, `master` + same paths | Triggered after merging a change to the workflow file or the library catalogue |
64+
| `workflow_dispatch` | Manual trigger (no inputs required) | Manual run at any time |
65+
66+
> **Important:** Unlike the plugins pipeline, this workflow does **not** trigger on changes to `src/**`, `packaging/**`, or `tests/**`. It only triggers when the workflow definition or `.github/packaging/cpan-libraries.json` changes, or when launched manually. To add or update a library, modify `cpan-libraries.json` directly — the CI will trigger automatically on the PR.
67+
68+
### Concurrency
69+
70+
One run per branch at a time; in-progress runs are cancelled when a new run starts on the same branch.
71+
72+
---
73+
74+
## Library catalogue: `cpan-libraries.json`
75+
76+
The single source of truth for all CPAN libraries to manage is `.github/packaging/cpan-libraries.json`. Each entry describes one CPAN module and its packaging configuration:
77+
78+
```json
79+
{
80+
"libraries": [
81+
{
82+
"name": "Crypt::OpenSSL::AES",
83+
"rpm": {
84+
"build_distribs": "el8,el9"
85+
},
86+
"deb": {
87+
"build_names": "bullseye-amd64,bookworm,trixie,jammy,noble,bullseye-arm64",
88+
"use_dh_make_perl": "false",
89+
"no-auto-depends": "true",
90+
"deb_dependencies": "libexporter-tiny-perl libxs-install-perl"
91+
}
92+
}
93+
]
94+
}
95+
```
96+
97+
### Key fields
98+
99+
| Field | Scope | Description |
100+
|---|---|---|
101+
| `name` | Both | CPAN module name (e.g. `Net::SNMP`) |
102+
| `rpm.build_distribs` | RPM | Comma-separated list of distributions to build for. Default: all RPM distribs (`el8,el9,el10`) |
103+
| `rpm.version` | RPM | Pin to a specific version. If absent, uses the latest from CPAN |
104+
| `rpm.rpm_dependencies` | RPM | Extra RPM dependencies |
105+
| `rpm.rpm_provides` | RPM | Additional `Provides:` entries in the spec file |
106+
| `rpm.no-auto-depends` | RPM | Disable automatic dependency detection |
107+
| `rpm.preinstall_cpanlibs` | RPM | CPAN modules to install before building (e.g. build tools) |
108+
| `rpm.preinstall_packages` | RPM | System packages to install before building |
109+
| `rpm.revision` | RPM | Package release revision (default: `1`) |
110+
| `rpm.spec_file` | RPM | Path to a custom `.spec` file, bypassing the automatic build script |
111+
| `deb.build_names` | DEB | Comma-separated build targets. Default: all DEB distribs |
112+
| `deb.use_dh_make_perl` | DEB | `"true"` to use `dh-make-perl` instead of `fpm` |
113+
| `deb.deb_dependencies` | DEB | Extra DEB dependencies |
114+
| `deb.deb_provides` | DEB | Additional `Provides:` entries |
115+
| `deb.no-auto-depends` | DEB | Disable automatic dependency detection |
116+
| `deb.preinstall_cpanlibs` | DEB | CPAN modules to install before building |
117+
| `deb.preinstall_packages` | DEB | System packages to install before building |
118+
| `deb.revision` | DEB | Package release revision |
119+
120+
A library with only an `rpm` key is built for RPM distributions only, and vice versa.
121+
122+
---
123+
124+
## Intelligent filtering
125+
126+
The pipeline avoids unnecessary builds through a two-level filtering process:
127+
128+
```mermaid
129+
flowchart TD
130+
LIB[Library in cpan-libraries.json] --> A{Available in\nofficial distrib repo\nat expected version?}
131+
A -->|Yes| SKIP1[Skip — no build needed]
132+
A -->|No| B{Already in\nCentreon stable\nArtifactory?}
133+
B -->|Yes, same version| SKIP2[Skip — already delivered]
134+
B -->|No / different version| BUILD[Build and package]
135+
```
136+
137+
### Level 1 — Official repository check (`check-official-repos`)
138+
139+
Runs inside the actual distribution container (e.g. `debian:bookworm`) using the real package manager:
140+
- **RPM**: queries `dnf` with EPEL + CRB/Powertools enabled
141+
- **DEB**: queries `apt-get` after `apt-get update`
142+
143+
Uses `cpanminus` to resolve the CPAN distribution name and version for each module. Produces a `partial-matrix-{distrib}.json` file listing only the libraries that need to be built for that distribution.
144+
145+
### Level 2 — Centreon stable Artifactory check (`generate-matrices`)
146+
147+
After collecting all partial matrices, `generate-matrices.py` additionally queries the Centreon public Artifactory instance (`packages.centreon.com`) for each library. If the package is already present in the stable repository at the expected version, it is excluded from the build matrix.
148+
149+
This prevents redundant rebuilds when re-running the workflow on a branch where no library actually changed.
150+
151+
---
152+
153+
## Jobs description
154+
155+
### `dependency-scan`
156+
157+
Runs the `centreon/security-tools` dependency vulnerability scan.
158+
159+
### `get-environment`
160+
161+
Determines stability, version, release, and skip status. See the [plugins CI documentation](plugins-ci.md#get-environment) for details — the logic is identical.
162+
163+
**Skipped entirely if** `stability == 'stable'` (no packaging on stable).
164+
165+
### `check-official-repos`
166+
167+
Runs in parallel on 8 distributions, each inside the official Docker image for that distribution (e.g. `almalinux:9`, `debian:bookworm`).
168+
169+
For each distribution:
170+
1. Installs `python3` and `cpanminus` via the system package manager.
171+
2. Enables EPEL and CRB/Powertools for RPM distributions.
172+
3. Runs `check-official-repos.py` which:
173+
- Filters the library catalogue to only the libs relevant for this distribution.
174+
- Calls `cpanm --info` for each library to get the CPAN distribution name and latest version.
175+
- Calls the package manager to check whether the library (or its distrib-packaged equivalent) is already available at the right version.
176+
- Produces `official-repos/partial-matrix-{distrib}.json`.
177+
4. Uploads the partial matrix as a GitHub Actions artifact.
178+
179+
### `get-packaging-images`
180+
181+
In parallel with `check-official-repos`, pulls the 9 internal Docker packaging images from the Centreon Harbor registry and saves them to the GitHub Actions cache.
182+
183+
Images pulled: `packaging-plugins-alma8/9/10`, `packaging-plugins-bullseye` (amd64 + arm64), `packaging-plugins-bookworm`, `packaging-plugins-trixie`, `packaging-plugins-jammy`, `packaging-plugins-noble`.
184+
185+
These images contain the tools needed to build packages (rpmbuild, fpm, dh-make-perl, etc.) with all required development headers pre-installed.
186+
187+
### `generate-matrices`
188+
189+
1. Downloads all `partial-matrix-*.json` artifacts.
190+
2. Optionally queries the Centreon stable Artifactory repository to exclude already-delivered packages.
191+
3. Generates two flat `include`-only matrices (no cross-product):
192+
- `matrix_rpm`: one entry per (library, RPM distrib) combination that needs building
193+
- `matrix_deb`: one entry per (library, DEB build target) combination that needs building
194+
4. Deletes the partial matrix artifacts (cleanup).
195+
196+
Each matrix entry carries all the parameters needed to build the package: `name`, `distrib`, `image`, `version`, `rpm_dependencies`, `deb_dependencies`, `use_dh_make_perl`, etc.
197+
198+
### `package-rpm`
199+
200+
Builds RPM packages. Up to 50 jobs run in parallel, one per (library, distrib) entry in `matrix_rpm`.
201+
202+
For each entry, inside the packaging Docker container:
203+
204+
**Standard mode** (no `spec_file`): runs `package-cpan-rpm.sh` which:
205+
1. Optionally installs pre-required CPAN modules (`preinstall_cpanlibs`) and system packages.
206+
2. Downloads and builds the module from CPAN using `cpanm`.
207+
3. Packages the result as an RPM using `cpanspec` and `rpmbuild`.
208+
209+
**Custom spec file mode** (`spec_file` set): runs `rpmbuild` directly with the provided spec file (for libraries that require complex build steps).
210+
211+
Output: one `.rpm` file per entry, uploaded as an individual artifact.
212+
213+
### `merge-package-rpm-artifacts`
214+
215+
Merges all individual RPM artifacts into one artifact per distribution (`packages-rpm-el8`, `packages-rpm-el9`, `packages-rpm-el10`) for easier downstream consumption, then deletes the individual artifacts.
216+
217+
### `sign-rpm`
218+
219+
Signs all `.rpm` files for each distribution using the Centreon GPG signing key. Runs sequentially (max-parallel: 1) inside a dedicated signing container.
220+
221+
Saves signed RPMs to cache with key `{sha}-{run_id}-rpm-{distrib}`.
222+
223+
### `package-deb`
224+
225+
Builds DEB packages. Up to 50 jobs run in parallel, one per (library, DEB build target) entry in `matrix_deb`. Supports two packaging methods:
226+
227+
**Method 1 — fpm** (`use_dh_make_perl: "false"`, default):
228+
Runs `package-cpan-deb-fpm.sh` which installs the module via `cpanm` and then repackages it as a `.deb` using `fpm`. Gives full control over dependencies (`deb_dependencies`) and metadata.
229+
230+
**Method 2 — dh-make-perl** (`use_dh_make_perl: "true"`):
231+
Runs `package-cpan-deb-dhmaker.sh` which uses `dh-make-perl` to automatically generate a proper Debian package following Debian packaging conventions. Used for libraries that need strict Debian-style packaging.
232+
233+
Output: one `.deb` file per entry, uploaded as an individual artifact.
234+
235+
### `merge-package-deb-artifacts`
236+
237+
Same as the RPM equivalent: merges individual DEB artifacts into one per distribution, then deletes the individual artifacts.
238+
239+
### `download-and-cache-deb`
240+
241+
Downloads the merged DEB artifacts and saves them to the GitHub Actions cache with key `{sha}-{run_id}-deb-{distrib}`.
242+
243+
### `test-packages`
244+
245+
Installs and tests all packaged libraries on the 9 supported distributions (using official images, not internal ones). Runs in matrix across:
246+
247+
| Distribution | Format | Architecture |
248+
|---|---|---|
249+
| el8 | RPM | amd64 |
250+
| el9 | RPM | amd64 |
251+
| el10 | RPM | amd64 |
252+
| bullseye | DEB | amd64 + arm64 |
253+
| bookworm | DEB | amd64 |
254+
| trixie | DEB | amd64 |
255+
| jammy | DEB | amd64 |
256+
| noble | DEB | amd64 |
257+
258+
Uses the `.github/actions/test-cpan-libs` action, which installs all packages for the distribution and verifies they load correctly via `perl -e "use Module::Name"`.
259+
260+
On failure, an error log artifact is uploaded as `install_error_log_{distrib}-{arch}`.
261+
262+
### `deliver-packages`
263+
264+
Uploads all packages to the Centreon Artifactory repository under the `perl-cpan-libraries` module name.
265+
266+
**Conditions:**
267+
- `stability` is `testing` or `unstable`, **OR** `stability == 'stable'` with a `push` event (not `workflow_dispatch`)
268+
- All previous jobs succeeded
269+
270+
### `set-skip-label`
271+
272+
Adds the label `skip-workflow-perl-cpan-libraries` to the PR after successful delivery, to avoid re-running if no relevant changes are detected on the next push.
273+
274+
---
275+
276+
## Cache usage summary
277+
278+
| Key | Content | Produced by | Consumed by |
279+
|---|---|---|---|
280+
| `{image}-{sha}-{run_id}` | Docker image tar | `get-packaging-images` | `package-rpm`, `package-deb` |
281+
| `{sha}-{run_id}-rpm-{distrib}` | Signed `.rpm` files | `sign-rpm` | `test-packages`, `deliver-packages` |
282+
| `{sha}-{run_id}-deb-{distrib}` | `.deb` files | `download-and-cache-deb` | `test-packages`, `deliver-packages` |
283+
284+
---
285+
286+
## Supported distributions
287+
288+
| Distribution | OS | Format | Built by |
289+
|---|---|---|---|
290+
| el8 | AlmaLinux 8 | RPM | `package-rpm` |
291+
| el9 | AlmaLinux 9 | RPM | `package-rpm` |
292+
| el10 | AlmaLinux 10 | RPM | `package-rpm` |
293+
| bullseye (amd64) | Debian 11 | DEB | `package-deb` |
294+
| bullseye (arm64) | Debian 11 | DEB | `package-deb` |
295+
| bookworm | Debian 12 | DEB | `package-deb` |
296+
| trixie | Debian 13 | DEB | `package-deb` |
297+
| jammy | Ubuntu 22.04 | DEB | `package-deb` |
298+
| noble | Ubuntu 24.04 | DEB | `package-deb` |
299+
300+
---
301+
302+
## Adding a new CPAN library
303+
304+
1. Edit `.github/packaging/cpan-libraries.json` and add a new entry:
305+
```json
306+
{
307+
"name": "My::New::Module",
308+
"rpm": {},
309+
"deb": {}
310+
}
311+
```
312+
Empty `rpm` and `deb` objects use all defaults (build for all distributions, latest CPAN version, automatic dependency detection).
313+
314+
2. Open a PR with that change — the CI will trigger automatically since `cpan-libraries.json` is in the path filter. Alternatively, trigger the workflow manually via `workflow_dispatch`.
315+
316+
3. The CI will check official repositories first. If the module is already packaged there, nothing will be built and the workflow completes successfully.
317+
318+
4. If the module is missing from official repos, it will be packaged, tested, and delivered automatically.
319+
320+
> **Tip:** For complex modules (XS/C extensions, unusual build systems), use `preinstall_cpanlibs`, `preinstall_packages`, or provide a custom `spec_file`. Refer to existing entries in `cpan-libraries.json` for examples.

0 commit comments

Comments
 (0)