Skip to content

Commit

Permalink
switching to github actions (#8)
Browse files Browse the repository at this point in the history
* replace travis with github actions

Additionally:

* php 8.x compat - trigger_error

* php 8.x compat - JSON_ERROR_NONE

* php 8.x compat - unsupported phpunit-token-stream lib

Codeception/Codeception#6074
sebastianbergmann/php-token-stream@a853a0e

* github actions - enable coverage for php 7.4 only
  • Loading branch information
partikus committed Jul 1, 2022
1 parent 8f6d3a3 commit e6392c4
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 48 deletions.
84 changes: 84 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: "Tests"

on:
- pull_request
- push

jobs:
test:
name: PHP:${{ matrix.php }} PHP_INVOKER:${{ toJSON(matrix.php_invoker) }} ALLOW_FAILURES:${{ toJSON(matrix.experimental) }} COVERAGE:${{ toJSON(matrix.coverage) }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
experimental: [false]
coverage: [false]
php:
- "5.3"
- "5.4"
- "5.5"
- "5.6"
- "7.0"
- "7.1"
- "7.2"
- "7.3"
php_invoker:
- true
- false
include:
- php: "7.4"
php_invoker: true
coverage: true
- php: "7.4"
php_invoker: false
coverage: true
- php: "8.0"
php_invoker: true
experimental: false
coverage: false
- php: "8.0"
php_invoker: false
coverage: false
experimental: false
- php: "8.1"
php_invoker: true
experimental: true
coverage: false
- php: "8.1"
php_invoker: false
experimental: true
coverage: false

steps:
- name: Checkout Code
uses: actions/checkout@v2

- name: Setup PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
ini-values: display_errors=off, log_errors=on
extensions: xdebug, ctype, dom, json, pcre, reflection, spl
# Since "The PEAR repository has been removed from Composer 2.0" it makes "composer install" to fail on this repo
# revert to composer v1 (and run it outside the checkouted repo, because composer v2 is basically stuck on that error on any command)
tools: composer:v1
env:
# https://github.com/shivammathur/setup-php/issues/407#issuecomment-773675741
fail-fast: true

- name: Install dependencies
env:
INSTALL_PHP_INVOKER: "${{ matrix.php_invoker == true }}"
run: |
if [ $INSTALL_PHP_INVOKER == true ]; then composer require --dev --prefer-source phpunit/php-invoker:\>=1.1.0,\<1.2.0; else composer install --dev --prefer-source; fi
- name: "Run PHPUnit tests"
env:
FAILURE_ACTION: "${{ matrix.experimental == true }}"
WITH_COVERAGE: "${{ matrix.coverage == true }}"
run: |
export CONFIG_FILE="./build/ci-no-coverage.xml"
if [[ $WITH_COVERAGE == true ]]; then export CONFIG_FILE="./build/ci.xml"; fi
./phpunit.php --configuration "${CONFIG_FILE}" || $FAILURE_ACTION;
# vim:ft=yaml:et:ts=2:sw=2
44 changes: 0 additions & 44 deletions .travis.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static function determineJsonError($error, $prefix = '')
{
switch ($error) {
case JSON_ERROR_NONE:
return;
return '';
case JSON_ERROR_DEPTH:
return $prefix . 'Maximum stack depth exceeded';
case JSON_ERROR_STATE_MISMATCH:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public static function determineJsonErrorDataprovider()
{
return array(
'JSON_ERROR_NONE' => array(
NULL, 'json_error_none', ''
NULL, JSON_ERROR_NONE, ''
),
'JSON_ERROR_DEPTH' => array(
'Maximum stack depth exceeded', JSON_ERROR_DEPTH, ''
Expand Down
12 changes: 10 additions & 2 deletions Tests/Regression/578/Issue578Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,21 @@ class Issue578Test extends PHPUnit_Framework_TestCase
public function testNoticesDoublePrintStackTrace()
{
$this->iniSet('error_reporting', E_ALL | E_NOTICE);
trigger_error('Stack Trace Test Notice', E_NOTICE);
if (PHP_VERSION_ID < 80000) {
trigger_error('Stack Trace Test Notice', E_NOTICE);
} else {
trigger_error('Invalid error type specified', E_USER_NOTICE);
}
}

public function testWarningsDoublePrintStackTrace()
{
$this->iniSet('error_reporting', E_ALL | E_NOTICE);
trigger_error('Stack Trace Test Notice', E_WARNING);
if (PHP_VERSION_ID < 80000) {
trigger_error('Stack Trace Test Notice', E_WARNING);
} else {
trigger_error('Invalid error type specified', E_USER_WARNING);
}
}

public function testUnexpectedExceptionsPrintsCorrectly()
Expand Down
33 changes: 33 additions & 0 deletions build/ci-no-coverage.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://phpunit.de/phpunit.xsd"
bootstrap="../Tests/bootstrap.php"
backupGlobals="false"
colors="true"
verbose="true">
<testsuites>
<testsuite name="PHPUnit">
<directory suffix="Test.php">../Tests/Framework</directory>
<directory suffix=".phpt">../Tests/Framework/MockObject</directory>
<directory suffix="Test.php">../Tests/Extensions</directory>
<directory suffix=".phpt">../Tests/Regression</directory>
<directory suffix="Test.php">../Tests/Runner</directory>
<directory suffix=".phpt">../Tests/TextUI</directory>
<directory suffix="Test.php">../Tests/Util</directory>
</testsuite>
</testsuites>

<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">../PHPUnit</directory>
<exclude>
<file>../PHPUnit/Autoload.php</file>
<file>../PHPUnit/Framework/Assert/Functions.php</file>
</exclude>
</whitelist>
</filter>

<php>
<const name="PHPUNIT_TESTSUITE" value="true"/>
</php>
</phpunit>
File renamed without changes.

0 comments on commit e6392c4

Please sign in to comment.