enh(chore): reorganize folders and update doc (#4153)
This commit is contained in:
parent
0998a037de
commit
3d67f0857c
|
@ -4,6 +4,9 @@ inputs:
|
|||
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
|
||||
|
@ -62,15 +65,15 @@ runs:
|
|||
artifactory_username: ${{ inputs.artifactory_username }}
|
||||
artifactory_password: ${{ inputs.artifactory_password }}
|
||||
|
||||
- name: Upload package artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: packages-${{ inputs.package_extension }}
|
||||
path: ./*.${{ inputs.package_extension }}
|
||||
retention-days: 1
|
||||
|
||||
- name: Cache packaged files
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ./*.${{ inputs.package_extension }}
|
||||
key: ${{ inputs.cache_key }}
|
||||
|
||||
- if: ${{ inputs.distrib == 'el8' }}
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: packages-${{ inputs.distrib }}
|
||||
path: ./*.${{ inputs.package_extension }}
|
||||
retention-days: 1
|
||||
|
|
|
@ -8,7 +8,7 @@ use JSON;
|
|||
use Cwd qw(getcwd);
|
||||
|
||||
my $pwd = (getcwd . '/');
|
||||
my $plugins_dir = ($pwd . 'centreon-plugins');
|
||||
my $plugins_dir = ($pwd . 'src');
|
||||
my $packaging_dir = ($pwd . 'packaging');
|
||||
my $build_dir = ($pwd . 'build');
|
||||
|
||||
|
|
|
@ -7,19 +7,23 @@ import json
|
|||
|
||||
common = argv[1] == 'true'
|
||||
|
||||
n = len(argv[2])
|
||||
a = argv[2][1:n-1]
|
||||
f = open("package_directories.txt", "r")
|
||||
line_packages = f.readline()
|
||||
n = len(line_packages)
|
||||
a = line_packages[1:n-1]
|
||||
input_packages = a.split(',')
|
||||
packages = set()
|
||||
for package in input_packages:
|
||||
packages.add(package.strip('"/').removeprefix('centreon-plugins/'))
|
||||
packages.add(package.strip('"/').removeprefix('src/'))
|
||||
|
||||
n = len(argv[3])
|
||||
a = argv[3][1:n-1]
|
||||
f = open("plugins.txt", "r")
|
||||
line_plugins = f.readline()
|
||||
n = len(line_plugins)
|
||||
a = line_plugins[1:n-1]
|
||||
input_plugins = a.split(',')
|
||||
plugins = set()
|
||||
for plugin in input_plugins:
|
||||
plugins.add(plugin.strip('"/').removeprefix('centreon-plugins/'))
|
||||
plugins.add(plugin.strip('"/').removeprefix('src/'))
|
||||
|
||||
list_plugins = set()
|
||||
list_packages = set()
|
||||
|
@ -49,7 +53,7 @@ for filepath in os.popen('find packaging -type f -name pkg.json').read().split('
|
|||
list_packages.add(packaging_path)
|
||||
else:
|
||||
for pkg_file in packaging["files"]:
|
||||
pkg_file_dir = pkg_file.strip('/').removeprefix('centreon-plugins/')
|
||||
pkg_file_dir = pkg_file.strip('/').removeprefix('src/')
|
||||
if pkg_file_dir in list_plugins:
|
||||
list_packages.add(packaging_path)
|
||||
|
||||
|
|
|
@ -76,6 +76,7 @@ jobs:
|
|||
- 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 }}
|
||||
|
|
|
@ -9,17 +9,15 @@ on:
|
|||
pull_request:
|
||||
paths:
|
||||
- '.github/workflows/plugins.yml'
|
||||
- 'centreon-plugins/**'
|
||||
- 'src/**'
|
||||
- 'packaging/**'
|
||||
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/plugins.yml'
|
||||
- 'centreon-plugins/**'
|
||||
- 'src/**'
|
||||
- 'packaging/**'
|
||||
tags:
|
||||
- centreon-plugins-*
|
||||
|
@ -54,7 +52,6 @@ jobs:
|
|||
- added|modified: centreon-plugins/**
|
||||
|
||||
- name: transform to directories
|
||||
id: transform
|
||||
run: |
|
||||
folders=()
|
||||
for f in ${{ steps.filter.outputs.packages_files }}; \
|
||||
|
@ -63,7 +60,7 @@ jobs:
|
|||
folders+=($(dirname $f)); \
|
||||
done
|
||||
unique_folders=($(printf "%s\n" "${folders[@]}" | sort -u | tr '\n' ' '))
|
||||
echo "package_directories=$(jq --compact-output --null-input '$ARGS.positional' --args -- ${unique_folders[@]})" >> $GITHUB_OUTPUT
|
||||
jq --compact-output --null-input '$ARGS.positional' --args -- ${unique_folders[@]} > package_directories.txt
|
||||
|
||||
files=()
|
||||
for f in ${{ steps.filter.outputs.plugins_files }}; \
|
||||
|
@ -72,23 +69,21 @@ jobs:
|
|||
files+=($f); \
|
||||
done
|
||||
unique_files=($(printf "%s\n" "${files[@]}" | sort -u | tr '\n' ' '))
|
||||
echo "plugins=$(jq --compact-output --null-input '$ARGS.positional' --args -- ${unique_files[@]})" >> $GITHUB_OUTPUT
|
||||
jq --compact-output --null-input '$ARGS.positional' --args -- ${unique_files[@]} > plugins.txt
|
||||
shell: bash
|
||||
|
||||
- name: Get plugins for build
|
||||
id: get_plugins
|
||||
if: ${{ steps.filter.outputs.common == 'true' || steps.filter.outputs.packages == 'true' || steps.filter.outputs.plugins == 'true' }}
|
||||
run: |
|
||||
PLUGINS="$(python3 .github/scripts/process-plugins.py \
|
||||
'${{ steps.filter.outputs.common == 'true' }}' \
|
||||
'${{ steps.transform.outputs.package_directories }}' \
|
||||
'${{ steps.transform.outputs.plugins }}' \
|
||||
)"
|
||||
PLUGINS="$(python3 .github/scripts/process-plugins.py '${{ steps.filter.outputs.common == 'true' }}')"
|
||||
|
||||
echo "plugins=$(echo $PLUGINS)" >> $GITHUB_OUTPUT
|
||||
|
||||
if [ "$PLUGINS" == '' ]; then
|
||||
echo "::notice::There are no modifications to the plugins packages"
|
||||
fi
|
||||
shell: bash
|
||||
|
||||
package:
|
||||
needs: [get-environment, get-plugins]
|
||||
|
|
|
@ -81,6 +81,10 @@ I can set threshold with options ``--warning`` and ``--critical``:
|
|||
|
||||
For more information or help, please read ['doc/en/user/guide.rst'](./doc/en/user/guide.rst).
|
||||
|
||||
## Continuous integration
|
||||
|
||||
Please follow documentation [here](./doc/CI.md)
|
||||
|
||||
<!-- URL AND IMAGES FOR SHIELDS -->
|
||||
[contributors-shield]: https://img.shields.io/github/contributors/centreon/centreon-plugins?color=%2384BD00&label=CONTRIBUTORS&style=for-the-badge
|
||||
[stars-shield]: https://img.shields.io/github/stars/centreon/centreon-plugins?color=%23433b02a&label=STARS&style=for-the-badge
|
||||
|
|
|
@ -1,80 +1,41 @@
|
|||
# Centreon Plugins continuous integration
|
||||
# Continuous integration
|
||||
|
||||
## Introduction
|
||||
|
||||
Centreon Plugins continuous integration is carried by the Centreon Build project.
|
||||
This allow easy delivery of plugins on public repositories and better follow-up of changes.
|
||||
|
||||
This documentation presents the workflows to build and deliver packaged plugins on
|
||||
This chapter presents the workflows to build and deliver packaged plugins on
|
||||
unstable, testing and stable repositories.
|
||||
|
||||
### Basic principles
|
||||
|
||||
Packaged plugins are formed by two components:
|
||||
|
||||
* Source code from [Centreon-Plugins](<https://github.com/centreon/centreon-plugins>) project,
|
||||
* Configuration files for standalone plugin files build and package dependencies management.
|
||||
* [Source code](../src)
|
||||
* [Configuration files](../packaging) for standalone plugin files build and package dependencies management.
|
||||
|
||||
Those configuration files are hosted in this project.
|
||||
### Workflows
|
||||
|
||||
### Continuous integration workflows
|
||||
Workflows are available [here](<https://github.com/centreon/centreon-plugins/actions>).
|
||||
|
||||
As the packaging process is based on two components, the CI can be triggered by both.
|
||||
* Each time a commit is made on **develop** branch, a build is triggered and publish updated plugins in unstable repositories
|
||||
* Each time a commit is made on a branch name which begins by **release**, a build is triggered and publish updated plugins in testing repositories
|
||||
* Each time a commit is made on **master** branch, a build is triggered and publish updated plugins in stable repositories
|
||||
* Each time a pull request is opened or updated, a build is triggered and publish updated plugins as artifacts (zip file downloadable directly from workflow)
|
||||
|
||||
![workflow](.images/ci_workflow.png "Continuous integration workflows")
|
||||
|
||||
* Each time a commit is made on Centreon Plugins master branch, a build is automatically launched (green arrows),
|
||||
* Each time a new plugin configuration files are added, or existing files modified, a build as to
|
||||
be launched manually (purple arrows).
|
||||
|
||||
The Jenkins job in charge of building unstable packages is the
|
||||
[Centreon EPP/Centreon Plugins/master](<https://jenkins.centreon.com/view/Centreon%20EPP/job/centreon-plugins/job/master/>) job.
|
||||
|
||||
For each successful jobs, packages will be available on the unstable repositories:
|
||||
|
||||
* 2.8/CentOS 7: <http://yum.centreon.com/standard/3.4/el7/unstable/noarch/plugins/>,
|
||||
* 18.10/CentOS 7: <http://yum.centreon.com/standard/18.10/el7/unstable/noarch/plugins/>.
|
||||
|
||||
Each time stamped subdirectories represents a successful build.
|
||||
|
||||
To make a build goes from unstable to testing, the
|
||||
[centreon-plugins-testing](<https://jenkins.centreon.com/view/Centreon%20EPP/job/centreon-plugins-testing/>) job
|
||||
should be launched.
|
||||
This job needs a version and a release number:
|
||||
|
||||
* The version is the date of the unstable build considered as the most mature,
|
||||
* The release number is the time of the unstable build considered as the most mature.
|
||||
|
||||
For each successful jobs, packages will be available on the testing repositories:
|
||||
|
||||
* 2.8/CentOS 7: <http://yum.centreon.com/standard/3.4/el7/testing/noarch/plugins/>,
|
||||
* 18.10/CentOS 7: <http://yum.centreon.com/standard/18.10/el7/testing/noarch/plugins/>.
|
||||
|
||||
To make a build goes from testing to stable, the
|
||||
[centreon-plugins-stable](<https://jenkins.centreon.com/view/Centreon%20EPP/job/centreon-plugins-stable/>) job
|
||||
should be launched.
|
||||
It takes the same parameters as the testing job.
|
||||
|
||||
Packages are now available on standard stable repositories.
|
||||
When plugins are built, The version is the current date and the release is the current time
|
||||
|
||||
## How to create a new packaged plugin
|
||||
|
||||
### Clone Centreon Build project
|
||||
|
||||
Clone the master branch of the Centreon Build project
|
||||
|
||||
```bash
|
||||
# git clone https://github.com/centreon/centreon-build
|
||||
```
|
||||
|
||||
### Create configuration files
|
||||
|
||||
#### Create new directory
|
||||
|
||||
In the *centreon-build/packaging/plugins* directory, create a new directory.
|
||||
In the *centreon-build/packaging/* directory, create a new directory.
|
||||
|
||||
```bash
|
||||
# cd centreon-build/packaging/plugins
|
||||
# cd packaging
|
||||
# mkdir centreon-plugin-<name>
|
||||
```
|
||||
|
||||
|
@ -176,7 +137,7 @@ In the project directory, create a new branch:
|
|||
Add the new directory and files to be commited:
|
||||
|
||||
```bash
|
||||
# git add packaging/plugins/centreon-plugin-My-Plugin
|
||||
# git add packaging/centreon-plugin-My-Plugin
|
||||
```
|
||||
|
||||
Commit the changes, respecting project format:
|
||||
|
@ -188,34 +149,21 @@ Commit the changes, respecting project format:
|
|||
Push the commit to your own fork:
|
||||
|
||||
```bash
|
||||
# git push https://github.com/<username>/centreon-build add-my-new-plugin
|
||||
# git push https://github.com/<username>/centreon-plugins add-my-new-plugin
|
||||
```
|
||||
|
||||
Create a new pull request on the project and wait for the build team to accept it.
|
||||
Create a new pull request on the project
|
||||
|
||||
### Launch a Jenkins build
|
||||
|
||||
From the Jenkins *Centreon EPP* tab, launch the Centreon Plugins/master job
|
||||
(<https://jenkins.centreon.com/view/Centreon%20EPP/job/centreon-plugins/job/master/>)
|
||||
|
||||
If the build succeed, the new plugin will be available on unstable repositories.
|
||||
Check packaged plugins in workflow artifacts
|
||||
|
||||
## How to edit a packaged plugin
|
||||
|
||||
### Clone Centreon Build project
|
||||
|
||||
Clone the master branch of the Centreon Build project
|
||||
|
||||
```bash
|
||||
# git clone https://github.com/centreon/centreon-build
|
||||
```
|
||||
|
||||
### Edit configuration files
|
||||
|
||||
In the plugin configuration files directory, edit either *pkg.json*, *rpm.json* or *deb.json* files.
|
||||
|
||||
```bash
|
||||
# cd centreon-build/packaging/plugins/centreon-plugin-My-Plugin
|
||||
# cd packaging/centreon-plugin-My-Plugin
|
||||
# vi pkg.json
|
||||
```
|
||||
|
||||
|
@ -230,7 +178,7 @@ In the project directory, create a new branch:
|
|||
Add the modified files to be commited:
|
||||
|
||||
```bash
|
||||
# git add packaging/plugins/centreon-plugin-My-Plugin/pkg.json
|
||||
# git add packaging/centreon-plugin-My-Plugin/pkg.json
|
||||
```
|
||||
|
||||
Commit the changes, respecting project format:
|
||||
|
@ -242,14 +190,9 @@ Commit the changes, respecting project format:
|
|||
Push the commit to your own fork:
|
||||
|
||||
```bash
|
||||
# git push https://github.com/<username>/centreon-build fix-my-plugin
|
||||
# git push https://github.com/<username>/centreon-plugins fix-my-plugin
|
||||
```
|
||||
|
||||
Create a new pull request on the project and wait for the build team to accept it.
|
||||
Create a new pull request on the project
|
||||
|
||||
### Launch a Jenkins build
|
||||
|
||||
From the Jenkins *Centreon EPP* tab, launch the Centreon Plugins/master job
|
||||
(<https://jenkins.centreon.com/view/Centreon%20EPP/job/centreon-plugins/job/master/>)
|
||||
|
||||
If the build succeed, the new plugin will be available on unstable repositories.
|
||||
Check packaged plugins in workflow artifacts
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue