Skip to content

Commit 877a433

Browse files
authored
Move to Github Actions (#5)
1 parent 6cf4872 commit 877a433

File tree

12 files changed

+283
-57
lines changed

12 files changed

+283
-57
lines changed

.gitattributes

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1+
/.github export-ignore
12
/tests export-ignore
23
.gitattributes export-ignore
34
.gitignore export-ignore
45
.php_cs export-ignore
5-
.scrutinizer.yml export-ignore
6-
.travis.yml export-ignore
76
phpstan.neon export-ignore
87
phpunit.xml export-ignore

.github/workflows/integrate.yaml

Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
name: "Integrate"
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- "master"
8+
9+
jobs:
10+
composer-json-lint:
11+
name: "Lint composer.json"
12+
13+
runs-on: "ubuntu-latest"
14+
15+
strategy:
16+
matrix:
17+
php-version:
18+
- "7.4"
19+
20+
steps:
21+
- name: "Checkout"
22+
uses: "actions/checkout@v2"
23+
24+
- name: "Install PHP"
25+
uses: "shivammathur/setup-php@v2"
26+
with:
27+
coverage: "none"
28+
php-version: "${{ matrix.php-version }}"
29+
tools: composer:v1, composer-normalize, composer-require-checker, composer-unused
30+
31+
- name: "Get composer cache directory"
32+
id: composercache
33+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
34+
35+
- name: "Cache dependencies"
36+
uses: actions/cache@v2
37+
with:
38+
path: ${{ steps.composercache.outputs.dir }}
39+
key: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ matrix.dependencies }}-composer-${{ hashFiles('**/composer.json') }}
40+
restore-keys: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ matrix.dependencies }}-composer-
41+
42+
- name: "Install dependencies"
43+
run: "composer update --no-interaction --no-progress"
44+
45+
- name: "Validate composer.json"
46+
run: "composer validate --strict"
47+
48+
- name: "Normalize composer.json"
49+
run: "composer-normalize --dry-run"
50+
51+
tests:
52+
name: "Tests"
53+
54+
runs-on: "ubuntu-latest"
55+
56+
strategy:
57+
matrix:
58+
php-version:
59+
- "7.3"
60+
- "7.4"
61+
62+
steps:
63+
- name: "Checkout"
64+
uses: "actions/checkout@v2"
65+
66+
- name: "Install PHP"
67+
uses: "shivammathur/setup-php@v2"
68+
with:
69+
coverage: "pcov"
70+
php-version: "${{ matrix.php-version }}"
71+
ini-values: zend.assertions=1
72+
tools: composer:v1
73+
74+
- name: "Get composer cache directory"
75+
id: composercache
76+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
77+
78+
- name: "Cache dependencies"
79+
uses: actions/cache@v2
80+
with:
81+
path: ${{ steps.composercache.outputs.dir }}
82+
key: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ matrix.dependencies }}-composer-${{ hashFiles('**/composer.json') }}
83+
restore-keys: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ matrix.dependencies }}-composer-
84+
85+
- name: "Install dependencies"
86+
run: "composer update --no-interaction --no-progress"
87+
88+
- name: "Run tests"
89+
timeout-minutes: 3
90+
run: "vendor/bin/phpunit --no-coverage --no-logging"
91+
92+
code-coverage:
93+
name: "Code Coverage"
94+
95+
runs-on: "ubuntu-latest"
96+
97+
strategy:
98+
matrix:
99+
php-version:
100+
- "7.4"
101+
102+
steps:
103+
- name: "Checkout"
104+
uses: "actions/checkout@v2"
105+
106+
- name: "Install PHP"
107+
uses: "shivammathur/setup-php@v2"
108+
with:
109+
coverage: "pcov"
110+
php-version: "${{ matrix.php-version }}"
111+
ini-values: zend.assertions=1
112+
tools: composer:v1
113+
114+
- name: "Get composer cache directory"
115+
id: composercache
116+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
117+
118+
- name: "Cache dependencies"
119+
uses: actions/cache@v2
120+
with:
121+
path: ${{ steps.composercache.outputs.dir }}
122+
key: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ matrix.dependencies }}-composer-${{ hashFiles('**/composer.json') }}
123+
restore-keys: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ matrix.dependencies }}-composer-
124+
125+
- name: "Install dependencies"
126+
run: "composer update --no-interaction --no-progress"
127+
128+
- name: "Run tests"
129+
timeout-minutes: 3
130+
run: "vendor/bin/phpunit --coverage-clover=coverage.xml --coverage-xml=coverage/coverage-xml --log-junit=coverage/junit.xml"
131+
132+
- name: "Send code coverage report to Codecov.io"
133+
uses: codecov/codecov-action@v1
134+
with:
135+
token: ${{ secrets.CODECOV_TOKEN }}
136+
file: ./coverage.xml
137+
fail_ci_if_error: true
138+
139+
coding-standards:
140+
name: "Coding Standards"
141+
142+
runs-on: "ubuntu-latest"
143+
144+
strategy:
145+
matrix:
146+
php-version:
147+
- "7.3"
148+
149+
steps:
150+
- name: "Checkout"
151+
uses: "actions/checkout@v2"
152+
153+
- name: "Install PHP"
154+
uses: "shivammathur/setup-php@v2"
155+
with:
156+
coverage: "none"
157+
php-version: "${{ matrix.php-version }}"
158+
tools: composer:v1, cs2pr
159+
160+
- name: "Get composer cache directory"
161+
id: composercache
162+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
163+
164+
- name: "Cache dependencies"
165+
uses: actions/cache@v2
166+
with:
167+
path: ${{ steps.composercache.outputs.dir }}
168+
key: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ matrix.dependencies }}-composer-${{ hashFiles('**/composer.json') }}
169+
restore-keys: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ matrix.dependencies }}-composer-
170+
171+
- name: "Install dependencies"
172+
run: "composer update --no-interaction --no-progress"
173+
174+
- name: "Check coding standards"
175+
run: "vendor/bin/php-cs-fixer fix --verbose --dry-run --diff"
176+
177+
static-analysis:
178+
name: "Static Analysis"
179+
180+
runs-on: "ubuntu-latest"
181+
182+
strategy:
183+
matrix:
184+
php-version:
185+
- "7.4"
186+
187+
steps:
188+
- name: "Checkout"
189+
uses: "actions/checkout@v2"
190+
191+
- name: "Install PHP"
192+
uses: "shivammathur/setup-php@v2"
193+
with:
194+
coverage: "none"
195+
php-version: "${{ matrix.php-version }}"
196+
tools: composer:v1, cs2pr
197+
198+
- name: "Get composer cache directory"
199+
id: composercache
200+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
201+
202+
- name: "Cache dependencies"
203+
uses: actions/cache@v2
204+
with:
205+
path: ${{ steps.composercache.outputs.dir }}
206+
key: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ matrix.dependencies }}-composer-${{ hashFiles('**/composer.json') }}
207+
restore-keys: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ matrix.dependencies }}-composer-
208+
209+
- name: "Install dependencies"
210+
run: "composer update --no-interaction --no-progress"
211+
212+
- name: "Run static analysis"
213+
run: "vendor/bin/phpstan analyse --no-progress"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.idea/
2+
coverage/
23
vendor/
34
.php_cs.cache
45
.phpunit.result.cache

.php_cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
$config = new SlamCsFixer\Config(SlamCsFixer\Config::LIB);
3+
$config = new SlamCsFixer\Config();
44
$config->getFinder()
55
->in(__DIR__ . '/lib')
66
->in(__DIR__ . '/tests')

.scrutinizer.yml

Lines changed: 0 additions & 2 deletions
This file was deleted.

.travis.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.

Makefile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
all: csfix static-analysis test
2+
@echo "Done."
3+
4+
vendor: composer.json composer.lock
5+
composer update
6+
touch vendor
7+
8+
.PHONY: csfix
9+
csfix: vendor
10+
vendor/bin/php-cs-fixer fix --verbose
11+
12+
.PHONY: static-analysis
13+
static-analysis: vendor
14+
vendor/bin/phpstan analyse
15+
16+
.PHONY: test
17+
test: vendor
18+
vendor/bin/phpunit --coverage-text

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# php-errorhandler-legacy
22

3-
[![Build Status](https://travis-ci.org/Slamdunk/php-errorhandler-legacy.svg?branch=master)](https://travis-ci.org/Slamdunk/php-errorhandler-legacy)
4-
[![Code Coverage](https://scrutinizer-ci.com/g/Slamdunk/php-errorhandler-legacy/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/Slamdunk/php-errorhandler-legacy/?branch=master)
5-
[![Packagist](https://img.shields.io/packagist/v/slam/php-errorhandler-legacy.svg)](https://packagist.org/packages/slam/php-errorhandler-legacy)
3+
[![Latest Stable Version](https://img.shields.io/packagist/v/slam/php-errorhandler-legacy.svg)](https://packagist.org/packages/slam/php-errorhandler-legacy)
4+
[![Integrate](https://github.com/Slamdunk/php-errorhandler-legacy/workflows/Integrate/badge.svg?branch=master)](https://github.com/Slamdunk/php-errorhandler-legacy/actions)
5+
[![Code Coverage](https://codecov.io/gh/Slamdunk/php-errorhandler-legacy/coverage.svg?branch=master)](https://codecov.io/gh/Slamdunk/php-errorhandler-legacy?branch=master)
66

77
Crappy class to manage errors and exceptions

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
"require-dev": {
1717
"phpstan/phpstan": "^0.12",
1818
"phpstan/phpstan-phpunit": "^0.12",
19-
"phpunit/phpunit": "^9.2",
20-
"slam/php-cs-fixer-extensions": "^1.19",
19+
"phpunit/phpunit": "^9.3",
20+
"slam/php-cs-fixer-extensions": "^2.0",
2121
"slam/php-debug-r": "^1.6",
22-
"slam/phpstan-extensions": "^4.0",
22+
"slam/phpstan-extensions": "^5.0",
2323
"symfony/console": "^5.1",
2424
"thecodingmachine/phpstan-strict-rules": "^0.12"
2525
},

lib/ErrorHandler.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public function getTerminalWidth(): int
135135
$width = \getenv('COLUMNS');
136136

137137
if (false === $width && 1 === \preg_match('{rows.(\d+);.columns.(\d+);}i', \exec('stty -a 2> /dev/null | grep columns'), $match)) {
138-
$width = $match[2];
138+
$width = $match[2]; // @codeCoverageIgnore
139139
}
140140

141141
$this->setTerminalWidth((int) $width ?: 80);
@@ -272,9 +272,9 @@ public function exceptionHandler(Throwable $exception): void
272272
$line = $lines[$i];
273273

274274
if (isset($line[$width])) {
275-
$lines[$i] = \mb_substr($line, 0, $width);
275+
$lines[$i] = \substr($line, 0, $width);
276276
if (isset($line[0]) && '#' !== $line[0]) {
277-
\array_splice($lines, $i + 1, 0, ' ' . \mb_substr($line, $width));
277+
\array_splice($lines, $i + 1, 0, ' ' . \substr($line, $width));
278278
}
279279
}
280280

@@ -284,7 +284,7 @@ public function exceptionHandler(Throwable $exception): void
284284
$this->outputError(\PHP_EOL);
285285
$this->outputError(\sprintf('<error> %s </error>', \str_repeat(' ', $width)));
286286
foreach ($lines as $line) {
287-
$this->outputError(\sprintf('<error> %s%s </error>', $line, \str_repeat(' ', \max(0, $width - \mb_strlen($line)))));
287+
$this->outputError(\sprintf('<error> %s%s </error>', $line, \str_repeat(' ', \max(0, $width - \strlen($line)))));
288288
}
289289
$this->outputError(\sprintf('<error> %s </error>', \str_repeat(' ', $width)));
290290
$this->outputError(\PHP_EOL);
@@ -314,7 +314,7 @@ public function exceptionHandler(Throwable $exception): void
314314

315315
public function renderHtmlException(Throwable $exception): string
316316
{
317-
$ajax = (isset($_SERVER) && isset($_SERVER['X_REQUESTED_WITH']) && 'XMLHttpRequest' === $_SERVER['X_REQUESTED_WITH']);
317+
$ajax = (isset($_SERVER['X_REQUESTED_WITH']) && 'XMLHttpRequest' === $_SERVER['X_REQUESTED_WITH']);
318318
$output = '';
319319
$errorType = '500: Internal Server Error';
320320
if (\in_array(\get_class($exception), $this->exceptionsTypesFor404, true)) {
@@ -427,7 +427,7 @@ public function emailException(Throwable $exception): void
427427
$username = null;
428428

429429
if ($this->logVariables()) {
430-
if (isset($_POST) && ! empty($_POST)) {
430+
if (! empty($_POST)) {
431431
$bodyText .= '$_POST = ' . \print_r($_POST, true) . \PHP_EOL;
432432
}
433433
if (isset($_SESSION) && ! empty($_SESSION)) {

0 commit comments

Comments
 (0)