Skip to content

Commit

Permalink
v1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
sirn-se committed Mar 5, 2024
1 parent d66a0cd commit 1d37592
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 156 deletions.
172 changes: 61 additions & 111 deletions .github/workflows/acceptance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,141 +3,91 @@ name: Acceptance
on: [push, pull_request]

jobs:
test-7-2:
runs-on: ubuntu-latest
name: Test PHP 7.2
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up PHP 7.2
uses: shivammathur/setup-php@v2
with:
php-version: '7.2'
- name: Composer
run: make deps-install
- name: Test
run: make test

test-7-3:
test:
strategy:
matrix:
php-versions: ["7.4", "8.0", "8.1", "8.2", "8.3", "8.4"]
runs-on: ubuntu-latest
name: Test PHP 7.3
name: Unit test
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up PHP 7.3
uses: actions/checkout@v4
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.3'
- name: Composer
run: make deps-install
- name: Test
run: make test

test-7-4:
runs-on: ubuntu-latest
name: Test PHP 7.4
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up PHP 7.4
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
- name: Composer
run: make deps-install
- name: Test
run: make test

test-8-0:
runs-on: ubuntu-latest
name: Test PHP 8.0
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up PHP 8.0
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
- name: Composer
run: make deps-install
- name: Test
run: make test

test-8-1:
runs-on: ubuntu-latest
name: Test PHP 8.1
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up PHP 8.1
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
extensions: pdo, pdo-sqlite
- name: Composer
run: make deps-install
- name: Test
run: make test

test-8-2:
runs-on: ubuntu-latest
name: Test PHP 8.2
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up PHP 8.2
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
- name: Composer
run: make deps-install
- name: Test
run: make test

test-8-3:
runs-on: ubuntu-latest
name: Test PHP 8.3
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up PHP 8.3
uses: shivammathur/setup-php@v2
php-version: ${{ matrix.php-versions }}
coverage: none
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache dependencies
uses: actions/cache@v4
with:
php-version: '8.3'
- name: Composer
run: make deps-install
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies
run: composer install --prefer-dist
- name: Test
run: make test
run: vendor/bin/phpunit

cs-check:
runs-on: ubuntu-latest
name: Code standard
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up PHP 8.2
uses: actions/checkout@v4
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
- name: Composer
run: make deps-install
php-version: "8.3"
coverage: none
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies
run: composer install --prefer-dist
- name: Code standard
run: make cs-check
run: vendor/bin/phpcs --standard=PSR1,PSR12 --encoding=UTF-8 --report=full --colors src tests

coverage:
runs-on: ubuntu-latest
name: Code coverage
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up PHP 8.0
uses: actions/checkout@v4
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
extensions: xdebug
- name: Composer
run: make deps-install
- name: Code coverage
php-version: "8.3"
coverage: xdebug
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies
run: composer install --prefer-dist
- name: Code coverage build
run: XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-clover build/logs/clover.xml
- name: Code coverage upload
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: make coverage
run: vendor/bin/php-coveralls -v
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,5 @@ Phrity\Util\ErrorHandler {

| Version | PHP | |
| --- | --- | --- |
| `1.1` | `^7.4\|^8.0` | Some improvements |
| `1.0` | `^7.2\|^8.0` | Initial version |
60 changes: 30 additions & 30 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
{
"name": "phrity/util-errorhandler",
"type": "library",
"description": "Inline error handler; catch and resolve errors for code block.",
"homepage": "https://phrity.sirn.se/util-errorhandler",
"keywords": ["error", "warning"],
"license": "MIT",
"authors": [
{
"name": "Sören Jensen",
"email": "[email protected]",
"homepage": "https://phrity.sirn.se"
"name": "phrity/util-errorhandler",
"type": "library",
"description": "Inline error handler; catch and resolve errors for code block.",
"homepage": "https://phrity.sirn.se/util-errorhandler",
"keywords": ["error", "warning"],
"license": "MIT",
"authors": [
{
"name": "Sören Jensen",
"email": "[email protected]",
"homepage": "https://phrity.sirn.se"
}
],
"autoload": {
"psr-4": {
"": "src/"
}
},
"autoload-dev": {
"psr-4": {
"": "tests/"
}
},
"require": {
"php": "^7.4 | ^8.0"
},
"require-dev": {
"phpunit/phpunit": "^9.0 | ^10.0 | ^11.0",
"php-coveralls/php-coveralls": "^2.0",
"squizlabs/php_codesniffer": "^3.5"
}
],
"autoload": {
"psr-4": {
"": "src/"
}
},
"autoload-dev": {
"psr-4": {
"": "tests/"
}
},
"require": {
"php": "^7.2|^8.0"
},
"require-dev": {
"phpunit/phpunit": "^8.0|^9.0|^10.0",
"php-coveralls/php-coveralls": "^2.0",
"squizlabs/php_codesniffer": "^3.5"
}
}
26 changes: 12 additions & 14 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit colors="true" bootstrap="vendor/autoload.php">
<testsuites>
<testsuite name="Phrity Util/ErrorHandler tests">
<directory>./tests/</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory suffix=".php">./src/</directory>
</whitelist>
</filter>
</phpunit>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" bootstrap="vendor/autoload.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">./src/</directory>
</include>
</coverage>
<testsuites>
<testsuite name="Phrity Util/Accessor tests">
<directory>./tests/</directory>
</testsuite>
</testsuites>
</phpunit>
3 changes: 2 additions & 1 deletion src/Phrity/Util/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ public function with(callable $callback, $handling = null, int $levels = E_ALL)
$result = $callback();
} catch (ErrorException $e) {
$error = $this->handle($handling, $e);
} finally {
$this->restore();
}
$this->restore();
return $error ?: $result;
}

Expand Down

0 comments on commit 1d37592

Please sign in to comment.