Skip to content

Commit

Permalink
t Merge branch 'MON-156626-align-plugins-release-number-to-branch-nam…
Browse files Browse the repository at this point in the history
…e' of https://github.com/centreon/centreon-plugins into MON-156626-align-plugins-release-number-to-branch-name
  • Loading branch information
mushroomempires committed Jan 14, 2025
2 parents dbc0509 + 3bc633e commit d860e90
Show file tree
Hide file tree
Showing 128 changed files with 91,320 additions and 459 deletions.
7 changes: 6 additions & 1 deletion .github/actions/package-delivery/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,11 @@ runs:
const path = require('path');
const globber = await glob.create('*.${{ steps.parse-distrib.outputs.package_extension }}');
let stableRpmSubdirectory = '';
if ('${{ inputs.stability }}' === 'stable') {
stableRpmSubdirectory = 'RPMS/';
}
const debTargetProps = '${{ inputs.stability }}' == 'testing' ? '--target-props "release_type=${{ inputs.release_type }}"' : '';
for await (const file of globber.globGenerator()) {
Expand All @@ -188,7 +193,7 @@ runs:
arch = 'x86_64';
}
await exec.exec(
`jf rt upload "${fileName}" "${{ steps.get_repository_stability_path.outputs.repository_stability_path }}/${arch}/${{ inputs.module_name }}/" --flat`
`jf rt upload "${fileName}" "${{ steps.get_repository_stability_path.outputs.repository_stability_path }}/${arch}/${stableRpmSubdirectory}${{ inputs.module_name }}/" --flat`
);
} else if ('${{ steps.parse-distrib.outputs.package_extension }}' === 'deb') {
let arch = 'all';
Expand Down
12 changes: 9 additions & 3 deletions .github/actions/promote-to-stable/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,21 @@ runs:
shell: bash

- name: Promote DEB package to stable
if: ${{ contains(fromJSON('["bullseye", "bookworm"]'), inputs.distrib) }}
if: ${{ contains(fromJSON('["bullseye", "bookworm", "jammy"]'), inputs.distrib) }}
run: |
set -eux
echo "[DEBUG] - Distrib: ${{ inputs.distrib }}"
echo "[DEBUG] - Distrib: ${{ inputs.module }}"
if [[ "${{ inputs.distrib }}" == "jammy" ]]; then
repo="ubuntu-plugins"
else
repo="apt-plugins"
fi
echo "[DEBUG] - Get path of testing DEB packages to promote to stable."
SRC_PATHS=$(jf rt search --include-dirs apt-plugins-testing/pool/${{ inputs.module }}/*${{ steps.parse-distrib.outputs.package_distrib_name }}*.deb | jq -r '.[].path')
SRC_PATHS=$(jf rt search --include-dirs $repo-testing/pool/${{ inputs.module }}/*${{ steps.parse-distrib.outputs.package_distrib_name }}*.deb | jq -r '.[].path')
if [[ ${SRC_PATHS[@]} ]]; then
for SRC_PATH in ${SRC_PATHS[@]}; do
Expand All @@ -86,7 +92,7 @@ runs:
fi
echo "[DEBUG] - Build target path."
TARGET_PATH="apt-plugins-${{ inputs.stability }}/pool/${{ inputs.module }}/"
TARGET_PATH="$repo-${{ inputs.stability }}/pool/${{ inputs.module }}/"
echo "[DEBUG] - Target path: $TARGET_PATH"
echo "[DEBUG] - Promoting DEB testing artifacts to stable."
Expand Down
4 changes: 2 additions & 2 deletions .github/docker/testing/Dockerfile.testing-plugins-bookworm
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<EOF
Expand All @@ -15,7 +15,7 @@ apt-get clean

EOF

ENV LANG en_US.utf8
ENV LANG=en_US.utf8

RUN bash -e <<EOF

Expand Down
4 changes: 2 additions & 2 deletions .github/docker/testing/Dockerfile.testing-plugins-bullseye
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ARG REGISTRY_URL=docker.io

FROM ${REGISTRY_URL}/debian:bullseye

ENV DEBIAN_FRONTEND noninteractive
ENV DEBIAN_FRONTEND=noninteractive

# fix locale
RUN bash -e <<EOF
Expand All @@ -15,7 +15,7 @@ apt-get clean

EOF

ENV LANG en_US.utf8
ENV LANG=en_US.utf8

RUN bash -e <<EOF

Expand Down
4 changes: 2 additions & 2 deletions .github/docker/testing/Dockerfile.testing-plugins-jammy
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ARG REGISTRY_URL=docker.io

FROM ${REGISTRY_URL}/ubuntu:jammy

ENV DEBIAN_FRONTEND noninteractive
ENV DEBIAN_FRONTEND=noninteractive

# fix locale
RUN bash -e <<EOF
Expand All @@ -15,7 +15,7 @@ apt-get clean

EOF

ENV LANG en_US.utf8
ENV LANG=en_US.utf8

RUN bash -e <<EOF

Expand Down
57 changes: 48 additions & 9 deletions .github/scripts/pod_spell_check.t
Original file line number Diff line number Diff line change
@@ -1,23 +1,62 @@
use strict;
use warnings;

use Test::More;
use Test::Spelling;
use List::MoreUtils qw(uniq);

# the command must have at least one argument
if (!@ARGV) {
die "Usage: perl pod_spell_check.t module.pm stopwords.t";
}
# the first argument is the module to check
my $module_to_check = $ARGV[0];

# the second (optional) argument is the additional dictionary
my $stopword_filename='tests/resources/spellcheck/stopwords.txt';
if(defined($ARGV[1])){
$stopword_filename=$ARGV[1];
}
open(FILE, "<", $stopword_filename)
or die "Could not open $stopword_filename";
printf("Using dictionary: ".$stopword_filename." \n");

add_stopwords(<FILE>);
close(FILE);
set_spell_cmd('hunspell -l');
all_pod_files_spelling_ok($ARGV[0]);
# get_stopwords(): reads the text file and returns its content as an array or strings
sub get_stopwords {
my ($file) = @_;

open(FILE, "<", $stopword_filename)
or die "Could not open $stopword_filename";
printf("Using dictionary: ".$stopword_filename." \n");
my @stop_words;
for my $line (<FILE>) {
chomp $line;
push @stop_words, $line;
}
close(FILE);

return @stop_words;
}

# get_module_options(): reads the Perl module file's POD and returns all the encountered --options
sub get_module_options {
my ($module) = @_;

my @cmd_result = `perldoc -T $module_to_check`;
my @new_words;

for my $pod_line (@cmd_result) {
chomp $pod_line;
my @parsed_options = $pod_line =~ /(--[\w-]+){1,}\s?/mg or next;
push @new_words, @parsed_options;
}

return uniq(sort(@new_words));
}

my @known_words = get_stopwords($stopword_filename);
my @module_options = get_module_options($module_to_check);

# take all words from the text file and the module's options as valid words
add_stopwords(@known_words, @module_options);

# prepare the spelling check command
set_spell_cmd('hunspell -d en_US -l');

# check that all is correct in the Perl module file given as an argument
all_pod_files_spelling_ok($module_to_check);
180 changes: 180 additions & 0 deletions .github/workflows/check-status.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
name: check-status

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

on:
pull_request:
branches:
- develop
- master
- hotfix-*
- release-*

jobs:
check-status:
runs-on: ubuntu-24.04
steps:
- name: Check workflow statuses and display token usage
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "current rest api rate usage:"
curl -s -H "Accept: application/vnd.github+json" -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/rate_limit | jq .rate
echo ""
echo ""
echo "current graphql rate usage:"
curl -s -H "Accept: application/vnd.github+json" -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/rate_limit | jq .resources.graphql
echo ""
echo ""
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.number }}
with:
script: |
await exec.exec("sleep 20s");
for (let i = 0; i < 120; i++) {
const failure = [];
const cancelled = [];
const pending = [];
const result = await github.rest.checks.listSuitesForRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "${{ github.head_ref }}"
});
result.data.check_suites.forEach(({ app: { slug }, conclusion, id}) => {
if (slug === 'github-actions') {
if (conclusion === 'failure' || conclusion === 'cancelled') {
failure.push(id);
} else if (conclusion === null) {
pending.push(id);
}
console.log(`check suite ${id} => ${conclusion === null ? 'pending' : conclusion}`);
}
});
if (pending.length === 0) {
core.setFailed("Cannot get pull request check status");
return;
}
if (failure.length > 0) {
let failureMessage = '';
const failedCheckRuns = [];
for await (const suite_id of failure) {
const resultCheckRuns = await github.rest.checks.listForSuite({
owner: context.repo.owner,
repo: context.repo.repo,
check_suite_id: suite_id
});
resultCheckRuns.data.check_runs.forEach(({ conclusion, name, html_url }) => {
if (conclusion === 'failure' || conclusion === 'cancelled') {
failedCheckRuns.push(`<a href="${html_url}">${name} (${conclusion})</a>`);
}
});
}
core.summary.addRaw(`${failedCheckRuns.length} job(s) failed:`, true)
core.summary.addList(failedCheckRuns);
core.summary.write()
if (failedCheckRuns.length > 0) {
core.setFailed(`${failedCheckRuns.length} job(s) failed`);
return;
}
}
if (pending.length === 1) {
core.info("All workflows are ok");
return;
}
core.info(`${pending.length} workflows in progress`);
await exec.exec("sleep 30s");
}
core.setFailed("Timeout: some jobs are still in progress");
get-environment:
if: |
contains(fromJSON('["pull_request", "pull_request_target"]') , github.event_name) &&
(startsWith(github.base_ref, 'release-') || startsWith(github.base_ref, 'hotfix-'))
uses: ./.github/workflows/get-environment.yml

check-cherry-pick:
needs: [get-environment, check-status]
runs-on: ubuntu-24.04
if: |
contains(fromJSON('["pull_request", "pull_request_target"]') , github.event_name) &&
needs.get-environment.outputs.target_stability == 'testing' &&
! contains(needs.get-environment.outputs.labels, 'skip-cherry-pick')
steps:
- name: Check if the PR is a cherry-pick from dev branch
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
env:
LINKED_DEV_BRANCH: develop
with:
script: |
let linkedPrs = [];
let errorMessage = `This pull request is not a cherry-pick from ${process.env.LINKED_DEV_BRANCH} or has no reference to a pull request which has been merged on ${process.env.LINKED_DEV_BRANCH}\n`;
try {
const pull = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number
});
const { title, body } = pull.data;
[title, body].forEach((text) => {
const linkedPrMatches = text.matchAll(/(?:#|\/pull\/)(\d+)/g);
if (linkedPrMatches) {
[...linkedPrMatches].forEach((match) => {
linkedPrs.push(Number(match[1]));
});
}
});
// remove duplicates
linkedPrs = [...new Set(linkedPrs)];
console.log(`Linked pull requests found in PR title and body: ${linkedPrs.join(', ')}`);
} catch (e) {
throw new Error(`Failed to get information of pull request #${context.issue.number}: ${e}`);
}
for await (const prNumber of linkedPrs) {
try {
const pull = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: prNumber
});
if (pull.data.base.ref === process.env.LINKED_DEV_BRANCH) {
if (pull.data.state === 'closed' && pull.data.merged === true) {
console.log(`This pull request is a cherry-pick from pull request #${prNumber} on ${process.env.LINKED_DEV_BRANCH}`);
return;
} else {
errorMessage += `This pull request seems to be a cherry-pick from pull request #${prNumber} on ${process.env.LINKED_DEV_BRANCH} but it is not merged yet\n`;
}
} else {
errorMessage += `Pull request #${prNumber} is linked to ${pull.data.base.ref} instead of ${process.env.LINKED_DEV_BRANCH}\n`;
}
} catch (e) {
errorMessage += `Failed to get information on pull request #${prNumber}: ${e}\n`;
}
}
errorMessage += `\nIf you are sure this PR does not need to be a cherry-pick from ${process.env.LINKED_DEV_BRANCH} or must be merged urgently, `;
errorMessage += `open the pull request on ${process.env.LINKED_DEV_BRANCH} and add label "skip-cherry-pick" to the PR and re-run all jobs of workflow check-status\n`;
throw new Error(errorMessage);
Loading

0 comments on commit d860e90

Please sign in to comment.