Replace Appveyor and Travis with Github actions

Travis has recently introduced built limits which makes using them very
slow sometimes and I never really liked the setup for appveyor for our
Windows testing.

This makes use of github actions instead. Some notes:

* since we only support PHP 7.2+ anymore, nothing below is tested
* MySQL and Postgres auth backends are only tested on Linux (as before)
* I am not actually sure the problem matchers are working as intended
* There is currently no good way to run tests that are allowed to fail
  so no PHP 8 tests are run yet
* I haven't reestablished the no-gzip test runs again, I'm not sure they
  are still relevant on modern PHP systems
* PHP 7.4 currently fails because of https://github.com/MarcusSchwarz/lesserphp/pull/18
* I'm currently using @v2 tags for the used action. We had a discussion
  before if we should actually pin the action to a fixed commit. For
  sake of easier maintainance, I would argue to trust the setup-php
  action.
This commit is contained in:
Andreas Gohr 2020-11-19 16:11:58 +01:00
parent 6b6d27d965
commit 2cf7c325f8
8 changed files with 103 additions and 93 deletions

View File

@ -7,16 +7,13 @@ jobs:
name: PHP CodeSniffer
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@7b8bf7af6a42e028cbcccf623bb8499b4d6edf02
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
coverage: none
- name: Download PHPCS
run: wget https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar
tools: cs2pr, phpcs
- name: run PHP codesniffer
run: php phpcs.phar -v --standard=_test/phpcs_MigrationAdjustments.xml
run: phpcs -q --standard=_test/phpcs_MigrationAdjustments.xml --report=checkstyle | cs2pr

53
.github/workflows/testLinux.yml vendored Normal file
View File

@ -0,0 +1,53 @@
name: Linux Unit Tests
on: [push, pull_request]
jobs:
run:
name: PHP ${{ matrix.php-versions }}
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['7.2', '7.3', '7.4']
fail-fast: false
services:
mysql:
image: mysql:5.7
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
ports:
- 3306:3306
postgres:
image: postgres:latest
env:
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, intl, PDO, pdo_sqlite, pdo_mysql, pdo_pgsql, bz2
- name: Setup problem matchers
run: |
echo ::add-matcher::${{ runner.tool_cache }}/php.json
echo ::add-matcher::${{ runner.tool_cache }}/phpunit.json
- name: Setup PHPUnit
run: |
php _test/fetchphpunit.php
cd _test
cp mysql.conf.php.dist mysql.conf.php
cp pgsql.conf.php.dist pgsql.conf.php
- name: Run PHPUnit
run: |
cd _test
php phpunit.phar --verbose --stderr

37
.github/workflows/testWindows.yml vendored Normal file
View File

@ -0,0 +1,37 @@
name: Windows Unit Tests
on: [push, pull_request]
jobs:
run:
name: PHP ${{ matrix.php-versions }}
runs-on: windows-latest
strategy:
matrix:
php-versions: ['7.2', '7.3', '7.4']
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, intl, bz2
- name: Setup problem matchers
run: |
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Setup PHPUnit
run: |
php _test/fetchphpunit.php
- name: Run PHPUnit
run: |
cd _test
php phpunit.phar --verbose --stderr

View File

@ -1,31 +0,0 @@
language: php
sudo: false
php:
- "nightly"
- "7.3"
- "7.2"
env:
- DISABLE_FUNCTIONS=
- DISABLE_FUNCTIONS="gzopen"
matrix:
fast_finish: true
allow_failures:
- php: "nightly"
services:
- mysql
- postgresql
notifications:
irc:
channels:
- "chat.freenode.net#dokuwiki"
on_success: change
on_failure: change
install:
- php _test/fetchphpunit.php
before_script:
- test -z "$DISABLE_FUNCTIONS" || echo "disable_functions=$DISABLE_FUNCTIONS" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
- cp _test/mysql.conf.php.dist _test/mysql.conf.php
- cp _test/pgsql.conf.php.dist _test/pgsql.conf.php
- ./_test/phpunit.phar --version
script:
- cd _test && ./phpunit.phar --verbose --stderr

View File

@ -32,8 +32,12 @@ $url = "https://phar.phpunit.de/$phpunit";
$out = __DIR__ . '/phpunit.phar';
$return = 0;
system("wget '$url' -O '$out'", $return);
if ($return !== 0) exit($return);
try {
file_put_contents($out, file_get_contents($url));
} catch (Throwable $e) {
fwrite(STDERR, $e->getMessage());
exit(1);
}
chmod($out, 0755);
print "Downloaded $phpunit\n";

View File

@ -3,7 +3,7 @@
* This configures the access to a mysql database. The user needs to have permissions
* to create and drop databases.
*/
$conf['host'] = 'localhost';
$conf['host'] = '127.0.0.1';
$conf['port'] = 3306;
$conf['user'] = 'root';
$conf['pass'] = '';

View File

@ -3,7 +3,7 @@
* This configures the access to a postgres database. The user needs to have permissions
* to create and drop databases.
*/
$conf['host'] = 'localhost';
$conf['host'] = '127.0.0.1';
$conf['port'] = 5432;
$conf['user'] = 'postgres';
$conf['pass'] = '';
$conf['pass'] = 'postgres';

View File

@ -1,50 +0,0 @@
build: false
clone_folder: c:\dokuwiki
max_jobs: 3
platform: x86
pull_requests:
do_not_increment_build_number: true
version: '{build}.{branch}'
environment:
matrix:
- PHP_VERSION: '7.2.4'
VC: 'VC15'
PHPUNIT: '7'
- PHP_VERSION: '7.0.29'
VC: 'VC14'
PHPUNIT: '6'
- PHP_VERSION: '5.6.35'
VC: 'VC11'
PHPUNIT: '5'
cache:
- c:\php -> appveyor.yml
init:
- SET PATH=c:\php\%PHP_VERSION%;%PATH%
install:
- echo %PHP_VERSION%
- IF NOT EXIST c:\php mkdir c:\php
- IF NOT EXIST c:\php\%PHP_VERSION% mkdir c:\php\%PHP_VERSION%
- cd c:\php\%PHP_VERSION%
- IF NOT EXIST php-installed.txt curl -fsSL -o php-%PHP_VERSION%-Win32-%VC%-x86.zip https://windows.php.net/downloads/releases/archives/php-%PHP_VERSION%-Win32-%VC%-x86.zip
- IF NOT EXIST php-installed.txt 7z x php-%PHP_VERSION%-Win32-%VC%-x86.zip -y >nul
- IF NOT EXIST php-installed.txt del /Q *.zip
- IF NOT EXIST php-installed.txt copy /Y php.ini-development php.ini
- IF NOT EXIST php-installed.txt echo max_execution_time=1200 >> php.ini
- IF NOT EXIST php-installed.txt echo date.timezone="UTC" >> php.ini
- IF NOT EXIST php-installed.txt echo extension_dir=ext >> php.ini
- IF NOT EXIST php-installed.txt echo extension=php_openssl.dll >> php.ini
- IF NOT EXIST php-installed.txt echo extension=php_mbstring.dll >> php.ini
- IF NOT EXIST php-installed.txt echo extension=php_gd2.dll >> php.ini
- IF NOT EXIST php-installed.txt echo extension=php_bz2.dll >> php.ini
- IF NOT EXIST php-installed.txt echo extension=php_pdo_sqlite.dll >> php.ini
- IF NOT EXIST php-installed.txt curl -fsSL -o phpunit.phar https://phar.phpunit.de/phpunit-%PHPUNIT%.phar
- IF NOT EXIST php-installed.txt type nul >> php-installed.txt
test_script:
- php -v
- cd c:\dokuwiki\_test
- php c:\php\%PHP_VERSION%\phpunit.phar