Integrate tests in workflow (#389)

This commit is contained in:
Johannes Meyer 2023-08-09 15:00:32 +02:00 committed by GitHub
commit 91720a5900
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 52 additions and 127 deletions

View file

@ -40,3 +40,46 @@ jobs:
- 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: 8.5
strategy:
fail-fast: false
matrix:
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
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: phpunit:${{ matrix.phpunit-version || env.phpunit-version }}
- name: Setup Icinga Web
run: |
git clone --depth 1 https://github.com/Icinga/icingaweb2.git _icingaweb2
ln -s `pwd` _icingaweb2/modules/businessprocess
- 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 dependencies
run: composer require -d _icingaweb2 -n --no-progress mockery/mockery
- name: PHPUnit
env:
ICINGAWEB_LIBDIR: _libraries
ICINGAWEB_CONFIGDIR: test/config
run: phpunit --verbose --bootstrap _icingaweb2/test/php/bootstrap.php

View file

@ -1,86 +0,0 @@
stages:
- Coding Standards
- Unit-Tests
- Build Packages
variables:
BASE_VERSION: "2.0.0"
VERSION_SUFFIX: "-b${CI_BUILD_ID}-${CI_BUILD_REF_SLUG}"
PSR2 CS Test:
stage: Coding Standards
tags:
- xenial
script:
- phpcs --report-width=auto --report-full --report-gitblame --report-summary -p --standard=PSR2 --extensions=php --encoding=utf-8 -w -s library/Businessprocess/ application/ configuration.php run.php test
Ubuntu Xenial:
stage: Unit-Tests
tags:
- xenial
- businessprocess
script:
- phpunit --testdox --coverage-html=coverage || phpunit --verbose
artifacts:
expire_in: 1 week
name: code-coverage
paths:
- coverage/*
Debian Jessie:
stage: Unit-Tests
tags:
- jessie
- businessprocess
script:
- phpunit --testdox || phpunit --verbose
CentOS 6:
stage: Unit-Tests
tags:
- centos6
- businessprocess
script:
- phpunit --testdox || phpunit --verbose
CentOS 7:
stage: Unit-Tests
tags:
- centos7
- businessprocess
script:
- phpunit --testdox || phpunit --verbose
Xenial Packages:
stage: Build Packages
tags:
- xenial
- businessprocess
script:
- cp -a packaging/debian debian
- dch --no-conf -U -M --empty -v "${BASE_VERSION}${VERSION_SUFFIX}-${CI_BUILD_REF:0:7}" "Automated build triggered by ${GITLAB_USER_ID} <${GITLAB_USER_EMAIL}>"
- cp LICENSE debian/copyright
- dpkg-buildpackage -us -uc
- mkdir build
- mv ../icingaweb2-module-businessprocess*.deb build/
artifacts:
expire_in: 1 week
paths:
- build/*
Jessie Packages:
stage: Build Packages
tags:
- jessie
- businessprocess
script:
- cp -a packaging/debian debian
- dch --no-conf -U -M --empty -v "${BASE_VERSION}${VERSION_SUFFIX}-${CI_BUILD_REF:0:7}" "Automated build triggered by ${GITLAB_USER_ID} <${GITLAB_USER_EMAIL}>"
- cp LICENSE debian/copyright
- dpkg-buildpackage -us -uc
- mkdir build
- mv ../icingaweb2-module-businessprocess*.deb build/
artifacts:
expire_in: 1 week
paths:
- build/*

View file

@ -1,31 +0,0 @@
language: php
php:
- '5.4'
- '5.5'
- '5.6'
- '7.0'
- '7.1'
- '7.2'
- nightly
matrix:
fast_finish: true
allow_failures:
- php: '5.4'
- php: '5.5'
- php: nightly
cache:
directories:
- vendor
env:
- ICINGAWEB_VERSION=2.6.2
- IPL_VERSION=0.1.1
before_script:
- ./test/setup_vendor.sh
script:
- php vendor/phpcs.phar
- php vendor/phpunit.phar --testdox || php vendor/phpunit.phar --verbose

View file

@ -7,21 +7,21 @@ use Icinga\Application\ApplicationBootstrap;
use Icinga\Application\Icinga;
use Icinga\Module\Businessprocess\BpConfig;
use Icinga\Module\Businessprocess\Storage\LegacyStorage;
use Icinga\Module\Businessprocess\Web\FakeRequest;
use PHPUnit_Framework_TestCase;
abstract class BaseTestCase extends PHPUnit_Framework_TestCase
abstract class BaseTestCase extends \Icinga\Test\BaseTestCase
{
/** @var ApplicationBootstrap */
private static $app;
/**
* @inheritdoc
*/
public function setUp()
public function setUp(): void
{
$this->app();
FakeRequest::setConfiguredBaseUrl('/icingaweb2/');
parent::setUp();
$this->getRequestMock()->shouldReceive('getBaseUrl')->andReturn('/icingaweb2/');
$this->app()
->getModuleManager()
->loadModule('businessprocess');
}
protected function emptyConfigSection()

View file

@ -7,7 +7,6 @@
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="test/bootstrap.php"
>
<testsuites>