Unverified Commit b7b5de89 authored by sc979's avatar sc979 Committed by GitHub
Browse files

enh(chore): add CI requirements for github violation (#26)

parent 5fc6bc3c
/vendor
/build
\ No newline at end of file
......@@ -41,6 +41,53 @@ stage('Source') {
}
try {
stage('Unit tests') {
parallel 'centos7': {
node {
sh 'setup_centreon_build.sh'
sh "./centreon-build/jobs/widgets/${serie}/widget-unittest.sh centos7"
if (currentBuild.result == 'UNSTABLE')
currentBuild.result = 'FAILURE'
if (env.CHANGE_ID) { // pull request to comment with coding style issues
ViolationsToGitHub([
repositoryName: 'centreon-widget-tactical-overview',
pullRequestId: env.CHANGE_ID,
createSingleFileComments: true,
commentOnlyChangedContent: true,
commentOnlyChangedFiles: true,
keepOldComments: false,
commentTemplate: "**{{violation.severity}}**: {{violation.message}}",
violationConfigs: [
[parser: 'CHECKSTYLE', pattern: '.*/codestyle-be.xml$', reporter: 'Checkstyle']
]
])
}
recordIssues(
enabledForFailure: true,
failOnError: true,
qualityGates: [[threshold: 1, type: 'DELTA', unstable: false]],
tool: phpCodeSniffer(id: 'phpcs', name: 'phpcs', pattern: 'codestyle-be.xml'),
trendChartType: 'NONE',
referenceJobName: 'centreon-widget-tactical-overview/master'
)
if ((env.BUILD == 'RELEASE') || (env.BUILD == 'REFERENCE')) {
withSonarQubeEnv('SonarQube') {
sh "./centreon-build/jobs/widgets/${serie}/widget-analysis.sh"
}
}
}
}
if ((currentBuild.result ?: 'SUCCESS') != 'SUCCESS') {
error('Unit tests stage failure.');
}
}
stage('Package') {
parallel 'centos7': {
node {
......
{
"name": "centreon/centreon-widget-tactical-overview",
"description": "Widget to display Host and service status Summary",
"version": "21.04.0",
"type": "project",
"license": "GPL-2.0-only",
"scripts": {
"codestyle": "phpcs --extensions=php --standard=./ruleset.xml ./",
"codestyle:ci": "@codestyle --report=checkstyle --report-file=./build/checkstyle.xml --no-cache"
},
"require-dev": {
"phpunit/phpunit": "^8.5",
"squizlabs/php_codesniffer": "^3.5"
},
"config": {
"secure-http": false,
"platform": {
"php": "7.2"
}
}
}
This diff is collapsed.
<?xml version="1.0"?>
<ruleset name="Centreon Widget Tactical Overview">
<description>Custom rules defined by Centreon</description>
<exclude-pattern>vendor</exclude-pattern>
<rule ref="PSR12"/>
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
<properties>
<property name="ignoreBlankLines" value="false"/>
</properties>
</rule>
<rule ref="PSR1.Files.SideEffects.FoundWithSymbols">
<exclude-pattern>tactical-overview/src</exclude-pattern>
</rule>
<rule ref="PSR1.Classes.ClassDeclaration.MissingNamespace">
<exclude-pattern>tactical-overview/src</exclude-pattern>
</rule>
</ruleset>
\ No newline at end of file
sonar.projectKey=centreon-widget-tactical-overview-21.04
sonar.projectName=Centreon Widget Tactical Overview 21.04
sonar.sources=./tactical-overview
<?php
/*
* Copyright 2005-2020 Centreon
* Centreon is developed by : Julien Mathis and Romain Le Merlus under
......@@ -19,11 +20,11 @@
* combined work based on this program. Thus, the terms and conditions of the GNU
* General Public License cover the whole combination.
*
* As a special exception, the copyright holders of this program give CENTREON
* As a special exception, the copyright holders of this program give Centreon
* permission to link this program with independent modules to produce an executable,
* regardless of the license terms of these independent modules, and to copy and
* distribute the resulting executable under terms of CENTREON choice, provided that
* CENTREON also meet, for each linked independent module, the terms and conditions
* distribute the resulting executable under terms of Centreon choice, provided that
* Centreon also meet, for each linked independent module, the terms and conditions
* of the license of that module. An independent module is a module which is not
* derived from this program. If you modify this program, you may extend this
* exception to your version of the program, but you are not obliged to do so. If you
......@@ -80,14 +81,15 @@ $resourceController = $kernel->getContainer()->get(
\Centreon\Application\Controller\MonitoringResourceController::class
);
$buildParameter = function(string $id, string $name) {
$buildParameter = function (string $id, string $name) {
return [
'id' => $id,
'name' => $name,
];
};
if (isset($preferences['object_type'])
if (
isset($preferences['object_type'])
&& ($preferences['object_type'] === "hosts" || $preferences['object_type'] == "")
) {
require_once 'src/hosts_status.php';
......
<?php
/*
* Copyright 2005-2020 Centreon
* Centreon is developed by : Julien Mathis and Romain Le Merlus under
......@@ -19,11 +20,11 @@
* combined work based on this program. Thus, the terms and conditions of the GNU
* General Public License cover the whole combination.
*
* As a special exception, the copyright holders of this program give CENTREON
* As a special exception, the copyright holders of this program give Centreon
* permission to link this program with independent modules to produce an executable,
* regardless of the license terms of these independent modules, and to copy and
* distribute the resulting executable under terms of CENTREON choice, provided that
* CENTREON also meet, for each linked independent module, the terms and conditions
* distribute the resulting executable under terms of Centreon choice, provided that
* Centreon also meet, for each linked independent module, the terms and conditions
* of the license of that module. An independent module is a module which is not
* derived from this program. If you modify this program, you may extend this
* exception to your version of the program, but you are not obliged to do so. If you
......@@ -40,16 +41,20 @@ $dataPEND = array();
$dataList = array();
$db = new CentreonDB("centstorage");
$buildHostUri = function(array $states, array $statuses) use ($resourceController, $buildParameter) {
return $resourceController->buildListingUri([
'filter' => json_encode([
'criterias' => [
'resourceTypes' => [$buildParameter('host', 'Host')],
'states' => $states,
'statuses' => $statuses,
],
]),
]);
$buildHostUri = function (array $states, array $statuses) use ($resourceController, $buildParameter) {
return $resourceController->buildListingUri(
[
'filter' => json_encode(
[
'criterias' => [
'resourceTypes' => [$buildParameter('host', 'Host')],
'states' => $states,
'statuses' => $statuses,
]
]
)
]
);
};
$pendingStatus = $buildParameter('PENDING', 'Pending');
......
<?php
/*
* Copyright 2005-2020 Centreon
* Centreon is developed by : Julien Mathis and Romain Le Merlus under
......@@ -19,11 +20,11 @@
* combined work based on this program. Thus, the terms and conditions of the GNU
* General Public License cover the whole combination.
*
* As a special exception, the copyright holders of this program give CENTREON
* As a special exception, the copyright holders of this program give Centreon
* permission to link this program with independent modules to produce an executable,
* regardless of the license terms of these independent modules, and to copy and
* distribute the resulting executable under terms of CENTREON choice, provided that
* CENTREON also meet, for each linked independent module, the terms and conditions
* distribute the resulting executable under terms of Centreon choice, provided that
* Centreon also meet, for each linked independent module, the terms and conditions
* of the license of that module. An independent module is a module which is not
* derived from this program. If you modify this program, you may extend this
* exception to your version of the program, but you are not obliged to do so. If you
......@@ -40,16 +41,20 @@ $dataUNK = array();
$dataPEND = array();
$db = new CentreonDB("centstorage");
$buildServiceUri = function(array $states, array $statuses) use ($resourceController, $buildParameter) {
return $resourceController->buildListingUri([
'filter' => json_encode([
'criterias' => [
'resourceTypes' => [$buildParameter('service', 'Service')],
'states' => $states,
'statuses' => $statuses,
],
]),
]);
$buildServiceUri = function (array $states, array $statuses) use ($resourceController, $buildParameter) {
return $resourceController->buildListingUri(
[
'filter' => json_encode(
[
'criterias' => [
'resourceTypes' => [$buildParameter('service', 'Service')],
'states' => $states,
'statuses' => $statuses,
],
]
)
]
);
};
$pendingStatus = $buildParameter('PENDING', 'Pending');
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment