Prepare for GLPI 11 #1359
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# GitHub Actions docs | |
# https://help.github.com/en/articles/about-github-actions | |
# https://help.github.com/en/articles/workflow-syntax-for-github-actions | |
name: CI | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- '*' | |
pull_request: | |
workflow_dispatch: | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
php-versions: ['7.4', '8.3'] | |
name: lint (${{ matrix.php-versions }}) | |
env: | |
extensions: zip | |
key: cache-v1 | |
steps: | |
- name: Change dir owner to working user | |
run: sudo chown -R $USER:$USER $GITHUB_WORKSPACE | |
- uses: actions/checkout@v4 | |
- name: Setup cache environment | |
id: extcache | |
uses: shivammathur/cache-extensions@v1 | |
with: | |
php-version: ${{ matrix.php-versions }} | |
extensions: ${{ env.extensions }} | |
key: ${{ env.key }} | |
- name: Cache extensions | |
uses: actions/cache@v4 | |
with: | |
path: ${{ steps.extcache.outputs.dir }} | |
key: ${{ steps.extcache.outputs.key }} | |
restore-keys: ${{ steps.extcache.outputs.key }} | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
env: | |
runner: ubuntu-latest | |
with: | |
php-version: ${{ matrix.php-versions }} | |
extensions: ${{ env.extensions }} | |
- name: Cache Composer dependencies | |
uses: actions/cache@v4 | |
with: | |
path: /tmp/composer-cache | |
key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }} | |
- name: Install dependencies | |
run: composer install | |
- name: Check for coding standards violations | |
run: | | |
vendor/bin/phpcs | |
phpunit: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
include: | |
- {php-versions: "7.4", db-image: "mysql:5.7"} | |
- {php-versions: "8.3", db-image: "mysql:5.7"} | |
- {php-versions: "8.3", db-image: "mysql:8.0"} | |
- {php-versions: "8.3", db-image: "mysql:8.1"} | |
- {php-versions: "8.3", db-image: "mariadb:10.6"} | |
- {php-versions: "8.3", db-image: "mariadb:11"} | |
name: Unit tests ${{ matrix.php-versions }} ${{ matrix.db-image }} | |
env: | |
extensions: zip, hash, fileinfo, mysqli, gd, bz2, xdebug | |
key: cache-v1 | |
DB: ${{ matrix.db-image }} | |
services: | |
# Label used to access the service container | |
db: | |
# Docker Hub image | |
image: ${{ matrix.db-image }} | |
# Provide env variables for both mysql and pgsql | |
env: | |
MYSQL_USER: glpiinventory | |
MYSQL_PASSWORD: glpi1iventory | |
MYSQL_ROOT_PASSWORD: glpi1iventory | |
MYSQL_DATABASE: glpi | |
# Open network ports | |
ports: | |
- 3306:3306 | |
# Set health checks to wait until postgres has started | |
options: >- | |
--health-cmd="bash -c 'if [[ -n $(command -v mysqladmin) ]]; then mysqladmin ping; else mariadb-admin ping; fi'" | |
--health-interval=10s | |
--health-timeout=5s | |
--health-retries=10 | |
steps: | |
- name: Install gettext and mysql-client | |
run: sudo apt-get install --assume-yes --no-install-recommends --quiet gettext | |
- name: Change dir owner to working user | |
run: sudo chown -R $USER:$USER $GITHUB_WORKSPACE | |
- uses: actions/checkout@v4 | |
- name: Setup cache environment | |
id: extcache | |
uses: shivammathur/cache-extensions@v1 | |
with: | |
php-version: ${{ matrix.php-versions }} | |
extensions: ${{ env.extensions }} | |
key: ${{ env.key }} | |
- name: Cache extensions | |
uses: actions/cache@v4 | |
with: | |
path: ${{ steps.extcache.outputs.dir }} | |
key: ${{ steps.extcache.outputs.key }} | |
restore-keys: ${{ steps.extcache.outputs.key }} | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
env: | |
runner: ubuntu-latest | |
with: | |
php-version: ${{ matrix.php-versions }} | |
extensions: ${{ env.extensions }} | |
- name: Cache Composer dependencies | |
uses: actions/cache@v4 | |
with: | |
path: /tmp/composer-cache | |
key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }} | |
- name: Install dependencies | |
run: composer install | |
- name: Checkout GLPI | |
uses: actions/checkout@v4 | |
with: | |
repository: glpi-project/glpi | |
path: glpi | |
fetch-depth: 1 | |
ref: 10.0/bugfixes | |
- name: Copy plugin | |
run: rsync -avr --exclude='glpi' ./* glpi/plugins/glpiinventory/ | |
- name: Install dependencies | |
run: | | |
cd glpi | |
composer install --ansi --no-interaction | |
php -r "file_put_contents('.package.hash', sha1_file('package-lock.json'));" | |
mkdir --parents public/lib | |
php bin/console locales:compile | |
- name: Init database | |
run: | | |
mysql -e 'create database IF NOT EXISTS glpi;' -u root --password=glpi1iventory -h 127.0.0.1 -P 3306 | |
- name: Install GLPI | |
run: cd glpi && php bin/console glpi:database:install -n --ansi --config-dir=tests/config --db-host=127.0.0.1 --db-name=glpi --db-user=root --db-password=glpi1iventory --db-port=3306 --strict-configuration | |
- name: Install plugin | |
run: cd glpi && php bin/console glpi:plugin:install -vvv -n --ansi --config-dir=tests/config --username=glpi glpiinventory | |
- name: Activate plugin | |
run: cd glpi && php bin/console glpi:plugin:activate -n --ansi --config-dir=tests/config glpiinventory | |
- name: run Unit tests | |
run: cd glpi/plugins/glpiinventory/ && php vendor/bin/phpunit --testdox --colors=always tests/Unit/ | |
- name: run Integration tests | |
run: cd glpi/plugins/glpiinventory/ && php vendor/bin/phpunit --testdox --colors=always tests/Integration/ | |
- name: run Install tests | |
run: cd glpi/plugins/glpiinventory/ && php vendor/bin/phpunit --testdox --colors=always tests/Installation/ | |
- name: PHPStan checks | |
run: cd glpi/plugins/glpiinventory && php vendor/bin/phpstan analyze --ansi --memory-limit=1G --no-interaction --no-progress |