mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-29 16:45:04 +02:00
enh(ci): new build of generic-snmp
This commit is contained in:
parent
6efddfe69d
commit
f36fc3be02
126
.github/workflows/generic-plugins.yml
vendored
126
.github/workflows/generic-plugins.yml
vendored
@ -21,3 +21,129 @@ jobs:
|
||||
uses: ./.github/workflows/get-environment.yml
|
||||
with:
|
||||
version_file: experimental/Cargo.toml
|
||||
|
||||
package:
|
||||
needs: [get-environment]
|
||||
if: |
|
||||
needs.get-environment.outputs.skip_workflow == 'false' &&
|
||||
needs.get-environment.outputs.stability != 'stable'
|
||||
runs-on: ubuntu-22.04
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- package_extension: rpm
|
||||
image: packaging-plugins-alma8
|
||||
distrib: el8
|
||||
arch: x86_64
|
||||
- package_extension: rpm
|
||||
image: packaging-plugins-alma9
|
||||
distrib: el9
|
||||
arch: x86_64
|
||||
- package_extension: deb
|
||||
image: packaging-plugins-bullseye
|
||||
distrib: bullseye
|
||||
arch: amd64
|
||||
- package_extension: deb
|
||||
image: packaging-plugins-bookworm
|
||||
distrib: bookworm
|
||||
arch: amd64
|
||||
- package_extension: deb
|
||||
image: packaging-plugins-jammy
|
||||
distrib: jammy
|
||||
arch: amd64
|
||||
- package_extension: deb
|
||||
image: packaging-plugins-noble
|
||||
distrib: noble
|
||||
arch: amd64
|
||||
|
||||
container:
|
||||
image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ matrix.image }}
|
||||
credentials:
|
||||
username: ${{ secrets.HARBOR_CENTREON_PULL_USERNAME }}
|
||||
password: ${{ secrets.HARBOR_CENTREON_PULL_TOKEN }}
|
||||
|
||||
name: package ${{ matrix.distrib }}
|
||||
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
|
||||
- name: Prepare files for packaging
|
||||
run: source .cargo/env.sh
|
||||
shell: bash
|
||||
|
||||
- name: Build using Cargo
|
||||
run: cargo build --release
|
||||
|
||||
- name: Package
|
||||
uses: ./.github/actions/package-nfpm
|
||||
with:
|
||||
nfpm_file_pattern: "experimental/packaging/generic-plugins.yaml"
|
||||
distrib: ${{ matrix.distrib }}
|
||||
package_extension: ${{ matrix.package_extension }}
|
||||
version: ${{ needs.get-environment.outputs.version }}
|
||||
release: 1
|
||||
arch: ${{ matrix.arch }}
|
||||
commit_hash: ${{ github.sha }}
|
||||
cache_key: ${{ github.sha }}-${{ github.run_id }}-${{ matrix.package_extension }}-generic-plugins-${{ 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 }}
|
||||
stability: ${{ needs.get-environment.outputs.stability }}
|
||||
|
||||
- name: Save to cache
|
||||
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
|
||||
with:
|
||||
path: ./*.${{ matrix.package_extension }}
|
||||
key: ${{ github.sha }}-${{ github.run_id }}-${{ matrix.package_extension }}-${{ matrix.distrib }}
|
||||
|
||||
deliver-packages:
|
||||
needs: [get-environment, package]
|
||||
if: |
|
||||
needs.get-environment.outputs.skip_workflow == 'false' &&
|
||||
(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
|
||||
- distrib: noble
|
||||
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: generic-plugins
|
||||
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 }}
|
||||
|
||||
set-skip-label:
|
||||
needs: [get-environment, deliver-packages]
|
||||
if: |
|
||||
needs.get-environment.outputs.skip_workflow == 'false' &&
|
||||
! cancelled() &&
|
||||
! contains(needs.*.result, 'failure') &&
|
||||
! contains(needs.*.result, 'cancelled')
|
||||
uses: ./.github/workflows/set-pull-request-skip-label.yml
|
||||
|
50
experimental/benches/bench.rs
Normal file
50
experimental/benches/bench.rs
Normal file
@ -0,0 +1,50 @@
|
||||
extern crate criterion;
|
||||
|
||||
use criterion::{criterion_group, criterion_main, Criterion};
|
||||
use std::hint::black_box;
|
||||
|
||||
fn average_for(v: &Vec<f64>) -> f64 {
|
||||
let mut sum = 0.0;
|
||||
let mut count = 0;
|
||||
|
||||
for &x in v.iter() {
|
||||
if !x.is_nan() {
|
||||
sum += x;
|
||||
count += 1;
|
||||
}
|
||||
}
|
||||
|
||||
if count == 0 {
|
||||
0.0
|
||||
} else {
|
||||
sum / count as f64
|
||||
}
|
||||
}
|
||||
|
||||
fn average_fold(v: &Vec<f64>) -> f64 {
|
||||
let (sum, count) = v
|
||||
.iter()
|
||||
.filter(|x| !x.is_nan())
|
||||
.fold((0.0, 0), |(s, c), &x| (s + x, c + 1));
|
||||
|
||||
if count == 0 {
|
||||
0.0
|
||||
} else {
|
||||
sum / count as f64
|
||||
}
|
||||
}
|
||||
|
||||
fn benchmark_averages(c: &mut Criterion) {
|
||||
let data: Vec<f64> = (0..100_000)
|
||||
.map(|i| if i % 1000 == 0 { f64::NAN } else { i as f64 })
|
||||
.collect();
|
||||
|
||||
c.bench_function("average_for", |b| b.iter(|| average_for(black_box(&data))));
|
||||
|
||||
c.bench_function("average_fold", |b| {
|
||||
b.iter(|| average_fold(black_box(&data)))
|
||||
});
|
||||
}
|
||||
|
||||
criterion_group!(benches, benchmark_averages);
|
||||
criterion_main!(benches);
|
29
experimental/packaging/centreon-generic-plugins.yaml
Normal file
29
experimental/packaging/centreon-generic-plugins.yaml
Normal file
@ -0,0 +1,29 @@
|
||||
name: "centreon-generic-plugins"
|
||||
arch: "${ARCH}"
|
||||
platform: "linux"
|
||||
version_schema: "none"
|
||||
version: "2.0.6"
|
||||
release: "${RELEASE}${DIST}"
|
||||
section: "default"
|
||||
priority: "optional"
|
||||
maintainer: "Centreon <contact@centreon.com>"
|
||||
description: |
|
||||
Centreon Generic Plugins is a collection of plugins for Centreon that allows monitoring of various systems and applications.
|
||||
vendor: "Centreon"
|
||||
homepage: "https://www.centreon.com"
|
||||
license: "Apache-2.0"
|
||||
|
||||
contents:
|
||||
- src: "target/release/generic-snmp" # VARIABLE VERSION REQUIRED HERE
|
||||
dst: "/usr/bin" # VARIABLE VERSION REQUIRED HERE
|
||||
expand: true
|
||||
file_info:
|
||||
mode: 0755
|
||||
owner: "root"
|
||||
group: "root"
|
||||
|
||||
rpm:
|
||||
summary: Centreon Generic Plugins
|
||||
signature:
|
||||
key_file: ${RPM_SIGNING_KEY_FILE}
|
||||
key_id: ${RPM_SIGNING_KEY_ID}
|
Loading…
x
Reference in New Issue
Block a user