Add php action workflow (#2309)

This commit is contained in:
Johannes Meyer 2023-08-31 10:32:34 +02:00 committed by GitHub
commit 079bf87a9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 245 additions and 227 deletions

173
.github/workflows/php.yml vendored Normal file
View File

@ -0,0 +1,173 @@
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: ['7.2', '7.3', '7.4', '8.0', '8.1']
os: ['ubuntu-latest']
steps:
- name: Checkout code base
uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: phpcs
- name: Setup dependencies
run: composer require -n --no-progress overtrue/phplint
- name: PHP Lint
if: ${{ ! cancelled() }}
run: ./vendor/bin/phplint -n --exclude={^vendor/.*} -- .
- name: PHP CodeSniffer
if: ${{ ! cancelled() }}
run: phpcs
test:
name: Unit tests with php ${{ matrix.php }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
env:
phpunit-version: 9.5
strategy:
fail-fast: false
matrix:
php: ['7.2', '7.3', '7.4', '8.0', '8.1']
os: ['ubuntu-latest']
include:
- php: '7.2'
phpunit-version: 8.5
services:
mysql:
image: mariadb
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: director_test
MYSQL_USER: director_test
MYSQL_PASSWORD: director_test
options: >-
--health-cmd "mariadb -s -uroot -proot -e'SHOW DATABASES;' 2> /dev/null | grep director_test > test"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 3306/tcp
pgsql:
image: postgres
env:
POSTGRES_USER: director_test
POSTGRES_PASSWORD: director_test
POSTGRES_DB: director_test
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@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: phpunit:${{ matrix.phpunit-version || env.phpunit-version }}
extensions: mysql, pgsql
- name: Setup Icinga Web
run: |
git clone --depth 1 https://github.com/Icinga/icingaweb2.git _icingaweb2
ln -s `pwd` _icingaweb2/modules/director
- name: Setup Libraries
run: |
mkdir _libraries
git clone --depth 1 -b snapshot/nightly https://github.com/Icinga/icinga-php-library.git _libraries/ipl
git clone --depth 1 -b snapshot/nightly https://github.com/Icinga/icinga-php-thirdparty.git _libraries/vendor
- name: Setup Incubator
run: |
git clone --depth 1 https://github.com/Icinga/icingaweb2-module-incubator _icingaweb2/modules/incubator
mkdir -p test/config/enabledModules
cd _icingaweb2/modules/incubator
ln -s `pwd` ../../../test/config/enabledModules/incubator
composer require --no-update \
"gipfl/calendar": "dev-master as 99.x-dev" \
"gipfl/cli": "dev-master as 99.x-dev" \
"gipfl/curl": "dev-master as 99.x-dev" \
"gipfl/data-type": "dev-master as 99.x-dev" \
"gipfl/db-migration": "dev-master as 99.x-dev" \
"gipfl/diff": "dev-master as 99.x-dev" \
"gipfl/format": "dev-master as 99.x-dev" \
"gipfl/icinga-bundles": "dev-master as 99.x-dev" \
"gipfl/icinga-cli-daemon": "dev-master as 99.x-dev" \
"gipfl/icingaweb2": "dev-master as 99.x-dev" \
"gipfl/influxdb": "dev-master as 99.x-dev" \
"gipfl/json": "dev-master as 99.x-dev" \
"gipfl/linux-health": "dev-master as 99.x-dev" \
"gipfl/log": "dev-master as 99.x-dev" \
"gipfl/process": "dev-master as 99.x-dev" \
"gipfl/protocol-jsonrpc": "dev-master as 99.x-dev" \
"gipfl/protocol-netstring": "dev-master as 99.x-dev" \
"gipfl/react-utils": "dev-master as 99.x-dev" \
"gipfl/simple-daemon": "dev-master as 99.x-dev" \
"gipfl/socket": "dev-master as 99.x-dev" \
"gipfl/stream": "dev-master as 99.x-dev" \
"gipfl/systemd": "dev-master as 99.x-dev" \
"gipfl/translation": "dev-master as 99.x-dev" \
"gipfl/web": "dev-master as 99.x-dev" \
"gipfl/zfdb": "dev-master as 99.x-dev" \
"gipfl/zfdbstore": "dev-master as 99.x-dev"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
bin/make-release.sh snapshot
- name: PHPUnit with MySQL
if: ${{ ! cancelled() }}
env:
ICINGAWEB_LIBDIR: _libraries
ICINGAWEB_CONFIGDIR: test/config
DIRECTOR_TESTDB_RES: Director MySQL TestDB
DIRECTOR_TESTDB: director_test
DIRECTOR_TESTDB_HOST: 127.0.0.1
DIRECTOR_TESTDB_PORT: ${{ job.services.mysql.ports['3306'] }}
DIRECTOR_TESTDB_USER: director_test
DIRECTOR_TESTDB_PASSWORD: director_test
run: phpunit --verbose --bootstrap _icingaweb2/test/php/bootstrap.php
- name: PHPUnit with PostgreSQL
if: ${{ ! cancelled() }}
env:
ICINGAWEB_LIBDIR: _libraries
ICINGAWEB_CONFIGDIR: test/config
DIRECTOR_TESTDB_RES: Director PostgreSQL TestDB
DIRECTOR_TESTDB: director_test
DIRECTOR_TESTDB_HOST: 127.0.0.1
DIRECTOR_TESTDB_PORT: ${{ job.services.pgsql.ports['5432'] }}
DIRECTOR_TESTDB_USER: director_test
DIRECTOR_TESTDB_PASSWORD: director_test
run: phpunit --verbose --bootstrap _icingaweb2/test/php/bootstrap.php

View File

@ -1,42 +0,0 @@
language: php
php:
- '5.6'
- '7.0'
- '7.1'
- '7.2'
- '7.3'
- '7.4snapshot'
- nightly
services:
- mysql
- postgresql
#cache:
# directories:
# - vendor
matrix:
fast_finish: true
include:
- env: CHECK=phpcs
php: nightly # Note: will be allowed failure
- env: CHECK=phpcs
php: '7.0'
- env: CHECK=phpcs
php: '5.6'
allow_failures:
- php: nightly
env:
- CHECK=phpunit DB=mysql DIRECTOR_TESTDB_RES="Director MySQL TestDB" DIRECTOR_TESTDB="director_test"
- CHECK=phpunit DB=pgsql DIRECTOR_TESTDB_RES="Director PostgreSQL TestDB" DIRECTOR_TESTDB="director_test"
DIRECTOR_TESTDB_USER="director_test"
before_script:
- ./test/setup_vendor.sh
- '[ "$CHECK" != phpunit ] || ./test/travis-prepare.sh'
script:
- '[ "$CHECK" != phpcs ] || php vendor/phpcs.phar'
- '[ "$CHECK" != phpunit ] || php vendor/phpunit.phar --testdox || php vendor/phpunit.phar --verbose'

View File

@ -12,16 +12,12 @@ there is probably already someone running them from time to time. So, just
lean back with full trust in our development toolchain and spend your time
elsewhere ;-) Cheers!
### Tests on Travis-CI
### Tests on GitHub
When pushing to [GitHub](https://github.com/Icinga/icingaweb2-module-director/)
or sending pull requests, Unit-Tests are automatically triggered on
[Travis-CI](https://travis-ci.org/Icinga/icingaweb2-module-director):
or sending pull requests, Unit-Tests are automatically triggered.
[![Build Status](https://travis-ci.org/Icinga/icingaweb2-module-director.svg?branch=master)](https://travis-ci.org/Icinga/icingaweb2-module-director)
We run our tests against MySQL and PostgreSQL, with PHP versions ranging from
5.3 to 7.1, including nightly builds.
![Build Status](https://github.com/Icinga/icingaweb2-module-director/workflows/PHP%20Tests/badge.svg?branch=master)
### Tests for supported Platforms

View File

@ -22,7 +22,6 @@ class CidrExpression extends FilterExpression
{
if ($parts = static::splitOptionalCidrString($expression)) {
list($this->networkAddress, $this->broadcastAddress) = $parts;
} else {
throw new InvalidArgumentException("'$expression' isn't valid CIDR notation");
}

View File

@ -10,16 +10,16 @@ use Icinga\Module\Director\Db;
use Icinga\Module\Director\Db\Migrations;
use Icinga\Module\Director\Objects\IcingaObject;
use Icinga\Module\Director\Objects\IcingaZone;
use PHPUnit_Framework_TestCase;
use PHPUnit\Framework\TestCase;
abstract class BaseTestCase extends PHPUnit_Framework_TestCase
abstract class BaseTestCase extends TestCase
{
private static $app;
/** @var Db */
private static $db;
public function setUp()
public function setUp(): void
{
$this->app();
}
@ -69,6 +69,9 @@ abstract class BaseTestCase extends PHPUnit_Framework_TestCase
if (array_key_exists('DIRECTOR_TESTDB_HOST', $_SERVER)) {
$dbConfig->host = $_SERVER['DIRECTOR_TESTDB_HOST'];
}
if (array_key_exists('DIRECTOR_TESTDB_PORT', $_SERVER)) {
$dbConfig->port = $_SERVER['DIRECTOR_TESTDB_PORT'];
}
if (array_key_exists('DIRECTOR_TESTDB_USER', $_SERVER)) {
$dbConfig->username = $_SERVER['DIRECTOR_TESTDB_USER'];
}

View File

@ -76,7 +76,7 @@ abstract class IcingaObjectTestCase extends BaseTestCase
/**
* @inheritdoc
*/
public function tearDown()
public function tearDown(): void
{
if ($this->hasDb()) {
/** @var IcingaObject $object */

View File

@ -29,7 +29,7 @@ abstract class SyncTest extends BaseTestCase
/** @var Sync */
protected $sync;
public function setUp()
public function setUp(): void
{
$this->source = ImportSource::create(array(
'source_name' => 'testimport',
@ -49,7 +49,7 @@ abstract class SyncTest extends BaseTestCase
$this->sync = new Sync($this->rule);
}
public function tearDown()
public function tearDown(): void
{
// properties should be deleted automatically
if ($this->rule !== null && $this->rule->hasBeenLoadedFromDb()) {

View File

@ -11,7 +11,7 @@ class AssignFilterHelperTest extends BaseTestCase
{
protected static $exampleHost;
public static function setUpBeforeClass()
public static function setUpBeforeClass(): void
{
self::$exampleHost = (object) [
'address' => '127.0.0.1',

View File

@ -7,11 +7,10 @@ use Icinga\Module\Director\Test\BaseTestCase;
class RecursiveUtf8ValidatorTest extends BaseTestCase
{
/**
* @expectedException \InvalidArgumentException
*/
public function testDetectInvalidUtf8Character()
{
$this->expectException(\InvalidArgumentException::class);
RecursiveUtf8Validator::validateRows([
(object) [
'name' => 'test 1',

View File

@ -18,11 +18,10 @@ class IcingaConfigHelperTest extends BaseTestCase
$this->assertEquals(c::parseInterval('1h 5m 60s'), 3960);
}
/**
* @expectedException \InvalidArgumentException
*/
public function testWhetherInvalidIntervalStringRaisesException()
{
$this->expectException(\InvalidArgumentException::class);
c::parseInterval('1h 5m 60x');
}

View File

@ -2,6 +2,8 @@
namespace Tests\Icinga\Module\Director\IcingaConfig;
use Icinga\Exception\InvalidPropertyException;
use Icinga\Exception\ProgrammingError;
use Icinga\Module\Director\IcingaConfig\StateFilterSet;
use Icinga\Module\Director\Objects\IcingaUser;
use Icinga\Module\Director\Test\BaseTestCase;
@ -23,19 +25,17 @@ class StateFilterSetTest extends BaseTestCase
);
}
/**
* @expectedException \Icinga\Exception\InvalidPropertyException
*/
public function testFailsForInvalidProperties()
{
$this->expectException(InvalidPropertyException::class);
$set = new StateFilterSet('bla');
}
/**
* @expectedException \Icinga\Exception\ProgrammingError
*/
public function testCannotBeStoredForAnUnstoredUser()
{
$this->expectException(ProgrammingError::class);
StateFilterSet::forIcingaObject(
$this->user1(),
'states'
@ -152,7 +152,7 @@ class StateFilterSetTest extends BaseTestCase
));
}
public function tearDown()
public function tearDown(): void
{
if ($this->hasDb()) {
$users = array(

View File

@ -242,7 +242,7 @@ class HostSyncTest extends SyncTest
}
}
public function tearDown()
public function tearDown(): void
{
$this->removeGroups(['SYNCTEST_groupa', 'SYNCTEST_groupb']);
parent::tearDown();

View File

@ -15,7 +15,7 @@ class HostGroupMembershipResolverTest extends BaseTestCase
const PREFIX = '__groupmembership';
const TYPE = 'host';
public function setUp()
public function setUp(): void
{
IcingaTemplateRepository::clear();
}
@ -32,12 +32,12 @@ class HostGroupMembershipResolverTest extends BaseTestCase
$db->delete('icinga_' . self::TYPE, $where);
}
public static function setUpBeforeClass()
public static function setUpBeforeClass(): void
{
static::cleanArtifacts();
}
public static function tearDownAfterClass()
public static function tearDownAfterClass(): void
{
static::cleanArtifacts();
}

View File

@ -206,7 +206,7 @@ class IcingaCommandTest extends BaseTestCase
return file_get_contents(__DIR__ . '/rendered/' . $name . '.out');
}
public function tearDown()
public function tearDown(): void
{
$db = $this->getDb();
if (IcingaCommand::exists($this->testCommandName, $db)) {

View File

@ -2,6 +2,7 @@
namespace Tests\Icinga\Module\Director\Objects;
use Icinga\Exception\NotFoundError;
use Icinga\Module\Director\Data\PropertiesFilter\ArrayCustomVariablesFilter;
use Icinga\Module\Director\Data\PropertiesFilter\CustomVariablesFilter;
use Icinga\Module\Director\IcingaConfig\IcingaConfig;
@ -255,14 +256,14 @@ class IcingaHostTest extends BaseTestCase
$zone->delete();
}
/**
* @expectedException \RuntimeException
*/
public function testFailsToStoreWithMissingLazyRelations()
{
if ($this->skipForMissingDb()) {
return;
}
$this->expectException(\RuntimeException::class);
$db = $this->getDb();
$host = $this->host();
$host->zone = '___TEST___zone';
@ -336,15 +337,14 @@ class IcingaHostTest extends BaseTestCase
);
}
/**
* @expectedException \RuntimeException
*/
public function testFailsToStoreWithInvalidUnresolvedDependencies()
{
if ($this->skipForMissingDb()) {
return;
}
$this->expectException(\RuntimeException::class);
$host = $this->host();
$host->zone = 'invalid';
$host->store($this->getDb());
@ -474,15 +474,14 @@ class IcingaHostTest extends BaseTestCase
$b->delete();
}
/**
* @expectedException \Icinga\Exception\NotFoundError
*/
public function testWhetherInvalidApiKeyThrows404()
{
if ($this->skipForMissingDb()) {
return;
}
$this->expectException(NotFoundError::class);
$db = $this->getDb();
IcingaHost::loadWithApiKey('No___such___key', $db);
}
@ -731,7 +730,7 @@ class IcingaHostTest extends BaseTestCase
return file_get_contents(__DIR__ . '/rendered/' . $name . '.out');
}
public function tearDown()
public function tearDown(): void
{
if ($this->hasDb()) {
$db = $this->getDb();

View File

@ -226,7 +226,7 @@ class IcingaNotificationTest extends BaseTestCase
return file_get_contents(__DIR__ . '/rendered/' . $name . '.out');
}
public function tearDown()
public function tearDown(): void
{
if ($this->hasDb()) {
$db = $this->getDb();

View File

@ -10,7 +10,7 @@ class IcingaServiceSetTest extends IcingaObjectTestCase
protected $table = 'icinga_service_set';
protected $testObjectName = '___TEST___set';
public function setUp()
public function setUp(): void
{
$this->assertNull($this->subject, 'subject must have been taken down before!');
@ -106,22 +106,20 @@ class IcingaServiceSetTest extends IcingaObjectTestCase
$this->checkForDanglingServices();
}
/**
* @expectedException \RuntimeException
*/
public function testCreatingSetWithoutType()
{
$this->expectException(\RuntimeException::class);
$set = IcingaServiceSet::create(array(
'object_name' => '___TEST__set_BAD',
));
$set->store($this->getDb());
}
/**
* @expectedException \InvalidArgumentException
*/
public function testCreatingServiceSetWithoutHost()
{
$this->expectException(\InvalidArgumentException::class);
$set = IcingaServiceSet::create(array(
'object_name' => '___TEST__set_BAD2',
'object_type' => 'object',

View File

@ -26,15 +26,14 @@ class IcingaServiceTest extends BaseTestCase
);
}
/**
* @expectedException \RuntimeException
*/
public function testFailsToStoreWithMissingLazyRelations()
{
if ($this->skipForMissingDb()) {
return;
}
$this->expectException(\RuntimeException::class);
$db = $this->getDb();
$service = $this->service();
$service->display_name = 'Something else';
@ -50,11 +49,10 @@ class IcingaServiceTest extends BaseTestCase
$service->assign_filter = 'host.address="127.*"';
}
/**
* @expectedException \LogicException
*/
public function testRefusesAssignRulesWhenNotBeingAnApply()
{
$this->expectException(\LogicException::class);
$service = $this->service();
$service->assign_filter = 'host.address=127.*';
}
@ -271,7 +269,7 @@ class IcingaServiceTest extends BaseTestCase
return file_get_contents(__DIR__ . '/rendered/' . $name . '.out');
}
public function tearDown()
public function tearDown(): void
{
if ($this->hasDb()) {
$db = $this->getDb();

View File

@ -144,7 +144,7 @@ class IcingaTemplateResolverTest extends BaseTestCase
return $host;
}
public function tearDown()
public function tearDown(): void
{
$db = $this->getDb();
$kill = array('t1', 't2', 't6', 't3', 't4', 't5');

View File

@ -171,7 +171,7 @@ class IcingaTimePeriodTest extends BaseTestCase
return IcingaTimePeriod::load($this->testPeriodName . $suffix, $this->getDb());
}
public function tearDown()
public function tearDown(): void
{
$db = $this->getDb();

View File

@ -31,11 +31,10 @@ class PropertyModifierArrayElementByPositionTest extends BaseTestCase
);
}
/**
* @expectedException \InvalidArgumentException
*/
public function testGettingFirstFailsForEmptyArray()
{
$this->expectException(\InvalidArgumentException::class);
$this->buildModifier('first')->transform([]);
}
@ -60,11 +59,10 @@ class PropertyModifierArrayElementByPositionTest extends BaseTestCase
);
}
/**
* @expectedException \InvalidArgumentException
*/
public function testGettingLastFailsForEmptyArray()
{
$this->expectException(\InvalidArgumentException::class);
$this->buildModifier('last')->transform([]);
}
@ -89,11 +87,10 @@ class PropertyModifierArrayElementByPositionTest extends BaseTestCase
);
}
/**
* @expectedException \InvalidArgumentException
*/
public function testGettingSpecificFailsForEmptyArray()
{
$this->expectException(\InvalidArgumentException::class);
$this->buildModifier('fixed', 1)->transform([]);
}
@ -102,11 +99,10 @@ class PropertyModifierArrayElementByPositionTest extends BaseTestCase
$this->assertNull($this->buildModifier('fixed', 1, 'null')->transform([]));
}
/**
* @expectedException \InvalidArgumentException
*/
public function testGettingSpecificFailsForMissingValue()
{
$this->expectException(\InvalidArgumentException::class);
$this->buildModifier('fixed', 3)->transform(['one', 'two', 'three']);
}
@ -115,11 +111,10 @@ class PropertyModifierArrayElementByPositionTest extends BaseTestCase
$this->assertNull($this->buildModifier('fixed', 3, 'null')->transform(['one', 'two', 'three']));
}
/**
* @expectedException \InvalidArgumentException
*/
public function testFailsForStrings()
{
$this->expectException(\InvalidArgumentException::class);
$this->buildModifier('first')->transform('string');
}

View File

@ -23,21 +23,19 @@ class PropertyModifierListToObjectTest extends BaseTestCase
);
}
/**
* @expectedException \InvalidArgumentException
*/
public function testFailsOnMissingKey()
{
$this->expectException(\InvalidArgumentException::class);
$input = $this->getInputArrays();
unset($input[0]['name']);
$this->getNewModifier()->transform($input);
}
/**
* @expectedException \InvalidArgumentException
*/
public function testFailsWithDuplicateRows()
{
$this->expectException(\InvalidArgumentException::class);
$input = $this->getInputArrays();
$input[1]['name'] = 'row1';
$this->getNewModifier()->transform($input);

View File

@ -2,6 +2,7 @@
namespace Tests\Icinga\Module\Director\PropertyModifier;
use Icinga\Exception\InvalidPropertyException;
use Icinga\Module\Director\PropertyModifier\PropertyModifierParseURL;
use Icinga\Module\Director\Test\BaseTestCase;
@ -50,11 +51,10 @@ class PropertyModifierParseURLTest extends BaseTestCase
$this->assertEquals('http://www.icinga.org/path/', $modifier->transform('http://www.icinga.org/path/'));
}
/**
* @expectedException \Icinga\Exception\InvalidPropertyException
*/
public function testMissingComponentThrowsExceptionOnfailureFail()
{
$this->expectException(InvalidPropertyException::class);
$modifier = new PropertyModifierParseURL();
$modifier->setSettings([
'url_component' => 'query',
@ -87,11 +87,10 @@ class PropertyModifierParseURLTest extends BaseTestCase
$this->assertEquals(self::$invalidurl, $modifier->transform(self::$invalidurl));
}
/**
* @expectedException \Icinga\Exception\InvalidPropertyException
*/
public function testInvalidUrlThrowsExceptionOnfailureFail()
{
$this->expectException(InvalidPropertyException::class);
$modifier = new PropertyModifierParseURL();
$modifier->setSettings([
'url_component' => 'host',

View File

@ -248,7 +248,7 @@ class TemplateTreeTest extends BaseTestCase
}
}
public function tearDown()
public function tearDown(): void
{
if ($this->hasDb()) {
$db = $this->getDb();

View File

@ -1,71 +0,0 @@
#!/bin/bash
set -ex
MODULE_HOME=${MODULE_HOME:="$(dirname "$(readlink -f "$(dirname "$0")")")"}
PHP_VERSION="$(php -r 'echo phpversion();')"
ICINGAWEB_VERSION=${ICINGAWEB_VERSION:=2.7.1}
ICINGAWEB_GITREF=${ICINGAWEB_GITREF:=}
if [ "$PHP_VERSION" '<' 7.1.0 ]; then
PHPCS_VERSION=${PHPCS_VERSION:=3.3.2}
else
PHPCS_VERSION=${PHPCS_VERSION:=3.5.2}
fi
if [ "$PHP_VERSION" '<' 5.6.0 ]; then
PHPUNIT_VERSION=${PHPUNIT_VERSION:=4.8}
else
PHPUNIT_VERSION=${PHPUNIT_VERSION:=5.7}
fi
cd "${MODULE_HOME}"
test -d vendor || mkdir vendor
cd vendor/
# icingaweb2
if [ -n "$ICINGAWEB_GITREF" ]; then
icingaweb_path="icingaweb2"
test ! -L "$icingaweb_path" || rm "$icingaweb_path"
if [ ! -d "$icingaweb_path" ]; then
git clone https://github.com/Icinga/icingaweb2.git "$icingaweb_path"
fi
(
set -e
cd "$icingaweb_path"
git fetch -p
git checkout -f "$ICINGAWEB_GITREF"
)
else
icingaweb_path="icingaweb2-${ICINGAWEB_VERSION}"
if [ ! -e "${icingaweb_path}".tar.gz ]; then
wget -O "${icingaweb_path}".tar.gz https://github.com/Icinga/icingaweb2/archive/v"${ICINGAWEB_VERSION}".tar.gz
fi
if [ ! -d "${icingaweb_path}" ]; then
tar xf "${icingaweb_path}".tar.gz
fi
rm -f icingaweb2
ln -svf "${icingaweb_path}" icingaweb2
fi
ln -svf "${icingaweb_path}"/library/Icinga Icinga
ln -svf "${icingaweb_path}"/library/vendor/Zend Zend
# phpunit
phpunit_path="phpunit-${PHPUNIT_VERSION}"
if [ ! -e "${phpunit_path}".phar ]; then
wget -O "${phpunit_path}".phar https://phar.phpunit.de/phpunit-${PHPUNIT_VERSION}.phar
fi
ln -svf "${phpunit_path}".phar phpunit.phar
# phpcs
phpcs_path="phpcs-${PHPCS_VERSION}"
if [ ! -e "${phpcs_path}".phar ]; then
wget -O "${phpcs_path}".phar \
https://github.com/squizlabs/PHP_CodeSniffer/releases/download/${PHPCS_VERSION}/phpcs.phar
fi
ln -svf "${phpcs_path}".phar phpcs.phar

View File

@ -1,25 +0,0 @@
#!/bin/bash
set -ex
: "${DIRECTOR_TESTDB:=director_test}"
psql_cmd() {
psql -U postgres ${DIRECTOR_TESTDB} -q -c "$@"
}
if [ "$DB" = mysql ]; then
mysql -u root -e "DROP DATABASE IF EXISTS ${DIRECTOR_TESTDB}; CREATE DATABASE ${DIRECTOR_TESTDB};"
elif [ "$DB" = pgsql ]; then
: "${DIRECTOR_TESTDB_USER:=director_test}"
psql -U postgres postgres -q -c "DROP DATABASE IF EXISTS ${DIRECTOR_TESTDB};"
psql -U postgres postgres -q -c "CREATE DATABASE ${DIRECTOR_TESTDB} WITH ENCODING 'UTF8';"
psql_cmd "CREATE USER ${DIRECTOR_TESTDB_USER} WITH PASSWORD 'testing';"
psql_cmd "GRANT ALL PRIVILEGES ON DATABASE ${DIRECTOR_TESTDB} TO ${DIRECTOR_TESTDB_USER};"
psql_cmd "CREATE EXTENSION pgcrypto;"
else
echo "Unknown database set in environment!" >&2
env
exit 1
fi