Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: "Continuous integration"

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

concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true

jobs:
generate-ci-matrix:
name: "Generate CI matrix"
uses: "glpi-project/plugin-ci-workflows/.github/workflows/generate-ci-matrix.yml@v1"
with:
glpi-version: "10.0.x"
ci:
name: "GLPI ${{ matrix.glpi-version }} - php:${{ matrix.php-version }} - ${{ matrix.db-image }}"
needs: "generate-ci-matrix"
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.generate-ci-matrix.outputs.matrix) }}
uses: "glpi-project/plugin-ci-workflows/.github/workflows/continuous-integration.yml@v1"
with:
plugin-key: "empty"
glpi-version: "${{ matrix.glpi-version }}"
php-version: "${{ matrix.php-version }}"
db-image: "${{ matrix.db-image }}"
init-script: "./.github/workflows/create-plugin.sh"
35 changes: 35 additions & 0 deletions .github/workflows/continuous-integration.yml.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: "Continuous integration"

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

concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true

jobs:
generate-ci-matrix:
name: "Generate CI matrix"
uses: "glpi-project/plugin-ci-workflows/.github/workflows/generate-ci-matrix.yml@v1"
with:
glpi-version: "10.0.x"
ci:
name: "GLPI ${{ matrix.glpi-version }} - php:${{ matrix.php-version }} - ${{ matrix.db-image }}"
needs: "generate-ci-matrix"
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.generate-ci-matrix.outputs.matrix) }}
uses: "glpi-project/plugin-ci-workflows/.github/workflows/continuous-integration.yml@v1"
with:
plugin-key: "{LNAME}"
glpi-version: "${{ matrix.glpi-version }}"
php-version: "${{ matrix.php-version }}"
db-image: "${{ matrix.db-image }}"
38 changes: 38 additions & 0 deletions .github/workflows/create-plugin.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash
#
# -------------------------------------------------------------------------
# {NAME} plugin for GLPI
# Copyright (C) {YEAR} by the {NAME} Development Team.
# -------------------------------------------------------------------------
#
# MIT License
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
# --------------------------------------------------------------------------
#

set -e -u -o pipefail

# `rsync` is required by the `plugin.sh` script
sudo apt update
sudo apt install --assume-yes --no-install-recommends --quiet rsync

# move self to `template` then create an `empty` plugin`
(cd .. && mv empty template && cd template && ./plugin.sh empty "1.0.0")
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ vendor/
.gh_token
composer.lock
*.min.*

var
52 changes: 52 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

/**
* -------------------------------------------------------------------------
* {NAME} plugin for GLPI
* -------------------------------------------------------------------------
*
* MIT License
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
* -------------------------------------------------------------------------
* @copyright Copyright (C) {YEAR} by the {NAME} plugin team.
* @license MIT https://opensource.org/licenses/mit-license.php
* @link https://github.com/pluginsGLPI/{LNAME}
* -------------------------------------------------------------------------
*/

use PhpCsFixer\Config;
use PhpCsFixer\Finder;

$finder = Finder::create()
->in(__DIR__)
->ignoreVCSIgnored(true)
->name('*.php');

$config = new Config();

$rules = [
'@PER-CS' => true, // Latest PER rules.
];

return $config
->setRules($rules)
->setFinder($finder)
->setCacheFile(__DIR__ . '/var/php-cs-fixer/.php-cs-fixer.cache')
;
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../../PluginsMakefile.mk
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"php": ">=7.4"
},
"require-dev": {
"glpi-project/tools": "^0.4"
"glpi-project/tools": "^0.7"
},
"config": {
"optimize-autoloader": true,
Expand Down
16 changes: 7 additions & 9 deletions hook.php.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
/**
* -------------------------------------------------------------------------
* {NAME} plugin for GLPI
* Copyright (C) {YEAR} by the {NAME} Development Team.
* -------------------------------------------------------------------------
*
* MIT License
Expand All @@ -25,26 +24,25 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* --------------------------------------------------------------------------
* -------------------------------------------------------------------------
* @copyright Copyright (C) {YEAR} by the {NAME} plugin team.
* @license MIT https://opensource.org/licenses/mit-license.php
* @link https://github.com/pluginsGLPI/{LNAME}
* -------------------------------------------------------------------------
*/

/**
* Plugin install process
*
* @return boolean
*/
function plugin_{LNAME}_install()
function plugin_{LNAME}_install(): bool
{
return true;
}

/**
* Plugin uninstall process
*
* @return boolean
*/
function plugin_{LNAME}_uninstall()
function plugin_{LNAME}_uninstall(): bool
{
return true;
}
16 changes: 16 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
includes:
- ../../vendor/phpstan/phpstan-deprecation-rules/rules.neon

parameters:
level: max
paths:
- src
- hook.php
- setup.php
scanDirectories:
- ../../src
bootstrapFiles:
- ../../inc/based_config.php
stubFiles:
- ../../stubs/glpi_constants.php
treatPhpDocTypesAsCertain: false
7 changes: 7 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<phpunit bootstrap="tests/bootstrap.php" colors="true" testdox="true">
<testsuites>
<testsuite name="Tests">
<directory suffix="Test.php">tests</directory>
</testsuite>
</testsuites>
</phpunit>
28 changes: 17 additions & 11 deletions plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
# --------------------------------------------------------------------------
#

set -e -u -o pipefail

if [[ $# -ne 2 && $# -ne 3 ]]; then
echo $0: usage: plugin.sh name version [destination/path]
exit 1
Expand Down Expand Up @@ -61,29 +63,33 @@ mkdir "$DEST"

rsync \
--exclude '.git' \
--exclude '.github/workflows/continuous-integration.yml' \
--exclude '.github/workflows/create-plugin.sh' \
--exclude 'plugin.sh' \
--exclude 'dist' \
--exclude 'README.md' \
-a . "$DEST"

pushd "$DEST" > /dev/null

#rename .tpl...
for f in `ls *.tpl`
do
mv $f ${f%.*}
done
# Remove .tpl suffix (current folder and subdirectories)
# Note: the .tpl suffix is used to prevent some files from being detected by
# GLPI (like the setup.php) or github (the ci configuration).
find . -type f -name "*.tpl" -exec bash -c 'mv "$0" "${0%.*}"' {} \;

# move xml file
mv plugin.xml $LNAME.xml

#do replacements
sed \
-e "s/{NAME}/$NAME/" \
-e "s/{LNAME}/$LNAME/" \
-e "s/{UNAME}/$UNAME/" \
-e "s/{VERSION}/$VERSION/" \
-e "s/{YEAR}/$YEAR/" \
-i setup.php hook.php $LNAME.xml tools/HEADER README.md
-e "s/{NAME}/$NAME/g" \
-e "s/{LNAME}/$LNAME/g" \
-e "s/{UNAME}/$UNAME/g" \
-e "s/{VERSION}/$VERSION/g" \
-e "s/{YEAR}/$YEAR/g" \
-i setup.php hook.php $LNAME.xml tools/HEADER README.md Makefile .github/workflows/continuous-integration.yml tests/bootstrap.php composer.json

# Unignore composer lock
sed -i '/^[[:space:]]*composer\.lock[[:space:]]*$/d' .gitignore

popd > /dev/null
14 changes: 7 additions & 7 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@
<key>{LNAME}</key>
<!-- stable, beta, development, alpha, ... -->
<state>stable</state>
<logo>https://raw.githubusercontent.com/pluginsGLPI/{LNAME}/master/{LNAME}.png</logo>
<logo>https://raw.githubusercontent.com/pluginsGLPI/{LNAME}/main/{LNAME}.png</logo>
<description>
<short>
<!-- Add as many lang tag you want -->
<en>{NAME} GLPI plugin.</en>
<en>{NAME} GLPI plugin</en>
<fr>Plugin GLPI {NAME}</fr>
</short>
<long>
<!-- Add as many lang tag you want -->
<en>A long description for {NAME} GLPI plugin.</en>
<fr>Un description longue pour le plugin GLPI {NAME}</fr>
<fr>Une description longue pour le plugin GLPI {NAME}.</fr>
</long>
</description>
<homepage>https://github.com/pluginsGLPI/{LNAME}</homepage>
<download>https://github.com/pluginsGLPI/{LNAME}/releases</download>
<issues>https://github.com/pluginsGLPI/{LNAME}/issues</issues>
<readme>https://github.com/pluginsGLPI/{LNAME}/blob/master/README.md</readme>
<readme>https://github.com/pluginsGLPI/{LNAME}/blob/main/README.md</readme>
<authors>
<!-- Add as many author tag you want -->
<author>Teclib'</author>
Expand All @@ -39,7 +39,7 @@
<lang>en_GB</lang>
<lang>fr_FR</lang>
</langs>
<license>GPL V3+</license>
<license>MIT</license>
<!--tags>
<en>
<tag>One tag</tag>
Expand All @@ -51,7 +51,7 @@
</fr>
</tags-->
<!--screenshots>
<screenshot>https://github.com/pluginsGLPI/fields/raw/master/screenshot.png</screenshot>
<screenshot>https://github.com/pluginsGLPI/fields/raw/master/screenshot2.png</screenshot>
<screenshot>https://github.com/pluginsGLPI/{LNAME}/raw/main/screenshot.png</screenshot>
<screenshot>https://github.com/pluginsGLPI/{LNAME}/raw/main/screenshot2.png</screenshot>
</screenshots-->
</root>
Loading