Skip to content

Commit

Permalink
Feature/ci (#130)
Browse files Browse the repository at this point in the history
* Add CI

Fix headers

* phpcbf

* visibility, exceptions

* phpstan level 5
  • Loading branch information
trasher authored Nov 15, 2023
1 parent 8542954 commit c9ed6fb
Show file tree
Hide file tree
Showing 23 changed files with 1,426 additions and 1,044 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: "Continuous integration"

on:
push:
branches:
- "master"
tags:
- "*"
pull_request:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:

jobs:
ci:
name: "GLPI ${{ matrix.glpi-version }} - php:${{ matrix.php-version }} - ${{ matrix.db-image }}"
strategy:
fail-fast: false
matrix:
include:
- {glpi-version: "10.0.x", php-version: "7.4", db-image: "mysql:5.7"}
- {glpi-version: "10.0.x", php-version: "8.0", db-image: "mysql:8.0"}
- {glpi-version: "10.0.x", php-version: "8.1", db-image: "mariadb:10.2"}
- {glpi-version: "10.0.x", php-version: "8.2", db-image: "mariadb:11.0"}
- {glpi-version: "10.0.x", php-version: "8.3-rc", db-image: "mysql:8.0"}
uses: "glpi-project/plugin-ci-workflows/.github/workflows/continuous-integration.yml@v1"
with:
plugin-key: "news"
glpi-version: "${{ matrix.glpi-version }}"
php-version: "${{ matrix.php-version }}"
db-image: "${{ matrix.db-image }}"
17 changes: 17 additions & 0 deletions .phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<ruleset>
<file>.</file>
<exclude-pattern>/.git/</exclude-pattern>
<exclude-pattern type="relative">^vendor/</exclude-pattern>

<arg name="colors" />
<arg name="extensions" value="php" />
<arg value="p" />
<arg name="warning-severity" value="0" />

<rule ref="PSR12">
<exclude name="Generic.Files.LineLength" />
<exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace" />
</rule>
<rule ref="Generic.Arrays.ArrayIndent"></rule>
</ruleset>
2 changes: 1 addition & 1 deletion ajax/alert_preview.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* You should have received a copy of the GNU General Public License
* along with News. If not, see <http://www.gnu.org/licenses/>.
* -------------------------------------------------------------------------
* @copyright Copyright (C) 2015-2022 by News plugin team.
* @copyright Copyright (C) 2015-2023 by News plugin team.
* @license GPLv2 https://www.gnu.org/licenses/gpl-2.0.html
* @link https://github.com/pluginsGLPI/news
* -------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion ajax/display_alerts.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*/

$AJAX_INCLUDE = 1;
include ("../../../inc/includes.php");
include("../../../inc/includes.php");
header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();
Session::checkLoginUser();
Expand Down
4 changes: 2 additions & 2 deletions ajax/hide_alert.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
*/

$AJAX_INCLUDE = 1;
include ("../../../inc/includes.php");
include("../../../inc/includes.php");
header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();
Session::checkLoginUser();

PluginNewsAlert_User::hideAlert($_POST);
PluginNewsAlert_User::hideAlert($_POST);
50 changes: 26 additions & 24 deletions ajax/targets.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,36 +29,38 @@
*/

$AJAX_INCLUDE = 1;
include ("../../../inc/includes.php");
include("../../../inc/includes.php");
header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();

Session::checkLoginUser();

if (isset($_POST['type']) && !empty($_POST['type'])) {
echo "<table class='tab_format'>";
echo "<tr>";
echo "<td>";
switch ($_POST['type']) {
case 'User' :
User::dropdown(['name' => 'items_id',
'right' => 'all',
'entity' => $_POST['entities_id'],
'entity_sons' => $_POST['is_recursive'],]);
break;
echo "<table class='tab_format'>";
echo "<tr>";
echo "<td>";
switch ($_POST['type']) {
case 'User':
User::dropdown(['name' => 'items_id',
'right' => 'all',
'entity' => $_POST['entities_id'],
'entity_sons' => $_POST['is_recursive'],
]);
break;

case 'Group' :
Group::dropdown(['name' => 'items_id']);
break;
case 'Group':
Group::dropdown(['name' => 'items_id']);
break;

case 'Profile' :
Profile::dropdown(['name' => 'items_id',
'toadd' => [-1 => __('All', 'news')]]);
break;
}
echo "</td>";
echo "<td><input type='submit' name='addvisibility' value=\""._sx('button', 'Add', 'news')."\"
case 'Profile':
Profile::dropdown(['name' => 'items_id',
'toadd' => [-1 => __('All', 'news')]
]);
break;
}
echo "</td>";
echo "<td><input type='submit' name='addvisibility' value=\"" . _sx('button', 'Add', 'news') . "\"
class='submit'></td>";
echo "</tr>";
echo "</table>";
}
echo "</tr>";
echo "</table>";
}
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
"php": ">=7.4"
},
"require-dev": {
"glpi-project/tools": "^0.6"
"glpi-project/tools": "^0.7.1",
"php-parallel-lint/php-parallel-lint": "^1.3",
"phpstan/phpstan": "^1.10",
"squizlabs/php_codesniffer": "^3.7"
},
"config": {
"optimize-autoloader": true,
Expand Down
Loading

0 comments on commit c9ed6fb

Please sign in to comment.