icingaweb2/.github/workflows/php.yml

123 lines
3.7 KiB
YAML
Raw Normal View History

2020-01-21 14:15:40 +01:00
name: PHP Tests
on:
push:
branches:
- master
- release/*
pull_request:
branches:
- master
jobs:
lint:
name: Static analysis for php ${{ matrix.php }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
2023-07-04 09:48:04 +02:00
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
2020-01-21 14:15:40 +01:00
os: ['ubuntu-latest']
steps:
- name: Checkout code base
2023-01-09 13:05:18 +01:00
uses: actions/checkout@v3
2020-01-21 14:15:40 +01:00
- name: Setup PHP
2020-11-17 16:41:01 +01:00
uses: shivammathur/setup-php@v2
2020-01-21 14:15:40 +01:00
with:
php-version: ${{ matrix.php }}
tools: phpcs
extensions: ldap
2020-01-21 14:15:40 +01:00
- name: Setup dependencies
run: |
composer require -n --no-progress overtrue/phplint
git clone --depth 1 -b snapshot/nightly https://github.com/Icinga/icinga-php-library.git vendor/icinga-php-library
git clone --depth 1 -b snapshot/nightly https://github.com/Icinga/icinga-php-thirdparty.git vendor/icinga-php-thirdparty
git clone --depth 1 https://github.com/Icinga/icingaweb2-module-x509.git vendor/modules/x509-web
git clone --depth 1 https://github.com/Icinga/icingadb-web.git vendor/modules/icingadb-web
git clone --depth 1 https://github.com/Icinga/icingaweb2-module-pdfexport.git vendor/modules/pdfexport-web
2020-01-21 14:15:40 +01:00
- name: PHP Lint
if: ${{ ! cancelled() }}
2021-04-09 11:17:37 +02:00
run: ./vendor/bin/phplint -n --exclude={^vendor/.*} --exclude=library/Icinga/Util/String.php ${{ matrix.phplint_options }} -- .
2020-01-21 14:15:40 +01:00
- name: PHP CodeSniffer
if: ${{ ! cancelled() }}
2020-01-21 14:15:40 +01:00
run: phpcs
- name: PHPStan
if: ${{ ! cancelled() }}
uses: php-actions/phpstan@v3
2020-01-21 14:15:40 +01:00
test:
name: Unit tests with php ${{ matrix.php }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
env:
2022-01-18 16:29:11 +01:00
phpunit-version: 9.5
2020-01-21 14:15:40 +01:00
strategy:
fail-fast: false
matrix:
2023-07-04 09:48:04 +02:00
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
2020-01-21 14:15:40 +01:00
os: ['ubuntu-latest']
2021-04-08 16:49:17 +02:00
include:
- php: '7.2'
2022-01-18 14:59:30 +01:00
phpunit-version: 8.5
2020-01-21 14:15:40 +01:00
services:
mysql:
image: mariadb
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: icinga_unittest
MYSQL_USER: icinga_unittest
MYSQL_PASSWORD: icinga_unittest
options: >-
2023-06-19 09:58:08 +02:00
--health-cmd "mariadb -s -uroot -proot -e'SHOW DATABASES;' 2> /dev/null | grep icinga_unittest > test"
2020-01-21 14:15:40 +01:00
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 3306/tcp
pgsql:
image: postgres
env:
POSTGRES_USER: icinga_unittest
POSTGRES_PASSWORD: icinga_unittest
POSTGRES_DB: icinga_unittest
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432/tcp
steps:
- name: Checkout code base
2023-01-09 13:05:18 +01:00
uses: actions/checkout@v3
2020-01-21 14:15:40 +01:00
- name: Setup PHP
2020-11-17 16:41:01 +01:00
uses: shivammathur/setup-php@v2
2020-01-21 14:15:40 +01:00
with:
php-version: ${{ matrix.php }}
2021-04-08 16:49:17 +02:00
tools: phpunit:${{ matrix.phpunit-version || env.phpunit-version }}
2020-01-21 14:15:40 +01:00
extensions: mysql, pgsql, ldap
- name: Setup dependencies
run: |
composer require -n --no-progress mockery/mockery ipl/i18n:@dev ipl/web:@dev
git clone --depth 1 --branch snapshot/nightly https://github.com/Icinga/icinga-php-thirdparty.git vendor/icinga-php-thirdparty
2020-01-21 14:15:40 +01:00
- name: PHPUnit
env:
ICINGAWEB_TEST_MYSQL_PORT: ${{ job.services.mysql.ports['3306'] }}
ICINGAWEB_TEST_PGSQL_PORT: ${{ job.services.pgsql.ports['5432'] }}
ICINGAWEB_LIBDIR: vendor/
2020-01-21 14:15:40 +01:00
run: phpunit -c modules/test/phpunit.xml --verbose