mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-27 07:44:04 +02:00
commit
c4bfbdb720
113
.github/workflows/php.yml
vendored
Normal file
113
.github/workflows/php.yml
vendored
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
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:
|
||||||
|
php: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4']
|
||||||
|
os: ['ubuntu-latest']
|
||||||
|
include:
|
||||||
|
- php: '5.6'
|
||||||
|
allow_failure: true
|
||||||
|
- php: '7.0'
|
||||||
|
allow_failure: true
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code base
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Setup PHP
|
||||||
|
uses: shivammathur/setup-php@v1
|
||||||
|
with:
|
||||||
|
php-version: ${{ matrix.php }}
|
||||||
|
tools: phpcs
|
||||||
|
|
||||||
|
- name: Setup dependencies
|
||||||
|
run: composer require -n --no-progress overtrue/phplint
|
||||||
|
|
||||||
|
- name: PHP Lint
|
||||||
|
if: success() || matrix.allow_failure
|
||||||
|
run: ./vendor/bin/phplint -n --exclude={^vendor/.*} --exclude=library/Icinga/Util/String.php -- .
|
||||||
|
|
||||||
|
- name: PHP CodeSniffer
|
||||||
|
if: success() || matrix.allow_failure
|
||||||
|
run: phpcs
|
||||||
|
|
||||||
|
test:
|
||||||
|
name: Unit tests with php ${{ matrix.php }} on ${{ matrix.os }}
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
||||||
|
env:
|
||||||
|
phpunit-version: 5.7.27
|
||||||
|
mockery-version: 0.9.9 # *Any* other version is not compatible with PHP 5.6 and anything above phpunit 6
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
php: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4']
|
||||||
|
os: ['ubuntu-latest']
|
||||||
|
|
||||||
|
services:
|
||||||
|
mysql:
|
||||||
|
image: mariadb
|
||||||
|
env:
|
||||||
|
MYSQL_ROOT_PASSWORD: root
|
||||||
|
MYSQL_DATABASE: icinga_unittest
|
||||||
|
MYSQL_USER: icinga_unittest
|
||||||
|
MYSQL_PASSWORD: icinga_unittest
|
||||||
|
options: >-
|
||||||
|
--health-cmd "mysql -s -uroot -proot -e'SHOW DATABASES;' 2> /dev/null | grep icinga_unittest > test"
|
||||||
|
--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
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Setup PHP
|
||||||
|
uses: shivammathur/setup-php@v1
|
||||||
|
with:
|
||||||
|
php-version: ${{ matrix.php }}
|
||||||
|
tools: phpunit:${{ env.phpunit-version }}
|
||||||
|
extensions: mysql, pgsql, ldap
|
||||||
|
|
||||||
|
- name: Setup dependencies
|
||||||
|
run: |
|
||||||
|
sudo locale-gen en_US.UTF-8 de_DE.UTF-8 fr_FR.UTF-8
|
||||||
|
composer require -n --no-progress mockery/mockery:${{ env.mockery-version }}
|
||||||
|
|
||||||
|
- name: PHPUnit
|
||||||
|
env:
|
||||||
|
ICINGAWEB_TEST_MYSQL_PORT: ${{ job.services.mysql.ports['3306'] }}
|
||||||
|
ICINGAWEB_TEST_PGSQL_PORT: ${{ job.services.pgsql.ports['5432'] }}
|
||||||
|
run: phpunit -c modules/test/phpunit.xml --verbose
|
71
.travis.yml
71
.travis.yml
@ -1,71 +0,0 @@
|
|||||||
language: php
|
|
||||||
dist: xenial
|
|
||||||
sudo: false
|
|
||||||
|
|
||||||
php:
|
|
||||||
- '5.6'
|
|
||||||
- '7.1'
|
|
||||||
- '7.2'
|
|
||||||
- '7.3'
|
|
||||||
- '7.4'
|
|
||||||
- nightly
|
|
||||||
|
|
||||||
env:
|
|
||||||
- CHECK=phpunit
|
|
||||||
|
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
- env: CHECK=phpcs
|
|
||||||
php: '7.4'
|
|
||||||
- env: CHECK=phpcs
|
|
||||||
php: '7.3'
|
|
||||||
- env: CHECK=phpcs
|
|
||||||
php: '7.2'
|
|
||||||
- env: CHECK=phpcs
|
|
||||||
php: '7.1'
|
|
||||||
- env: CHECK=phpcs
|
|
||||||
php: '5.6'
|
|
||||||
- env: CHECK=syntax
|
|
||||||
php: 'nightly'
|
|
||||||
- env: CHECK=syntax
|
|
||||||
php: '7.4'
|
|
||||||
- env: CHECK=syntax
|
|
||||||
php: '7.3'
|
|
||||||
- env: CHECK=syntax
|
|
||||||
php: '7.2'
|
|
||||||
- env: CHECK=syntax
|
|
||||||
php: '7.1'
|
|
||||||
- env: CHECK=syntax
|
|
||||||
php: '5.6'
|
|
||||||
allow_failures:
|
|
||||||
- php: nightly
|
|
||||||
|
|
||||||
services:
|
|
||||||
- mysql
|
|
||||||
- postgresql
|
|
||||||
|
|
||||||
cache:
|
|
||||||
directories:
|
|
||||||
- vendor
|
|
||||||
|
|
||||||
branches:
|
|
||||||
only:
|
|
||||||
- master
|
|
||||||
- /^v\d/
|
|
||||||
|
|
||||||
notifications:
|
|
||||||
email: false
|
|
||||||
|
|
||||||
# also see: test/setup_vendor.sh
|
|
||||||
before_script:
|
|
||||||
- php -m
|
|
||||||
- '[ -z $LOCALE_GEN ] || sudo locale-gen en_US.UTF-8 de_DE.UTF-8 fr_FR.UTF-8'
|
|
||||||
- '[ -z $ENABLE_LDAP ] || phpenv config-add test/travis-ldap.ini'
|
|
||||||
- test/setup_vendor.sh
|
|
||||||
- 'if [ "$CHECK" = phpunit ]; then test/travis_database.sh; fi'
|
|
||||||
|
|
||||||
script:
|
|
||||||
# also see: modules/test/application/clicommands/PhpCommand.php
|
|
||||||
- 'if [ "$CHECK" = phpcs ]; then php vendor/phpcs.phar; fi'
|
|
||||||
- 'if [ "$CHECK" = phpunit ]; then php vendor/phpunit.phar -c modules/test/phpunit.xml --verbose; fi'
|
|
||||||
- 'if [ "$CHECK" = syntax ]; then php test/check-syntax.php -e "^(\./)?vendor/" -e Icinga/Util/String.php; fi'
|
|
@ -1,6 +1,7 @@
|
|||||||
# Icinga Web 2
|
# Icinga Web 2
|
||||||
|
|
||||||
[](https://travis-ci.org/Icinga/icingaweb2)
|
[](https://php.net/)
|
||||||
|

|
||||||
[](https://github.com/Icinga/icingaweb2)
|
[](https://github.com/Icinga/icingaweb2)
|
||||||
|
|
||||||

|

|
||||||
|
@ -210,7 +210,19 @@ namespace Icinga\Test {
|
|||||||
protected function createDbConfigFor($name)
|
protected function createDbConfigFor($name)
|
||||||
{
|
{
|
||||||
if (array_key_exists($name, self::$dbConfiguration)) {
|
if (array_key_exists($name, self::$dbConfiguration)) {
|
||||||
return new ConfigObject(self::$dbConfiguration[$name]);
|
$config = new ConfigObject(self::$dbConfiguration[$name]);
|
||||||
|
|
||||||
|
$host = getenv(sprintf('ICINGAWEB_TEST_%s_HOST', strtoupper($name)));
|
||||||
|
if ($host) {
|
||||||
|
$config['host'] = $host;
|
||||||
|
}
|
||||||
|
|
||||||
|
$port = getenv(sprintf('ICINGAWEB_TEST_%s_PORT', strtoupper($name)));
|
||||||
|
if ($port) {
|
||||||
|
$config['port'] = $port;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $config;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new RuntimeException('Configuration for database type not available: ' . $name);
|
throw new RuntimeException('Configuration for database type not available: ' . $name);
|
||||||
|
@ -24,9 +24,15 @@ set_include_path(implode(PATH_SEPARATOR, [
|
|||||||
get_include_path()
|
get_include_path()
|
||||||
]));
|
]));
|
||||||
|
|
||||||
|
$vendorAutoload = $basePath . '/vendor/autoload.php';
|
||||||
|
if (file_exists($vendorAutoload)) {
|
||||||
|
require_once $vendorAutoload;
|
||||||
|
} else {
|
||||||
require_once 'Mockery/Loader.php';
|
require_once 'Mockery/Loader.php';
|
||||||
|
|
||||||
$mockeryLoader = new \Mockery\Loader;
|
$mockeryLoader = new \Mockery\Loader;
|
||||||
$mockeryLoader->register();
|
$mockeryLoader->register();
|
||||||
|
}
|
||||||
|
|
||||||
require_once($icingaLibPath . '/Test/ClassLoader.php');
|
require_once($icingaLibPath . '/Test/ClassLoader.php');
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user