Skip to content

Set up GitHub Actions #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Feb 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text eol=lf
30 changes: 30 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: CI
on: push
jobs:
run:
runs-on: ${{ matrix.operating-system }}
strategy:
fail-fast: false
matrix:
operating-system: [ubuntu-latest, windows-latest, macos-latest]
php-versions: ['7.3', '7.4']
name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v1
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring
coverage: xdebug

- name: Composer dependencies
run: composer install --no-ansi --no-interaction --no-scripts --no-suggest --no-progress --prefer-dist

- name: Run phpunit
run: ./vendor/bin/phpunit

- name: Run phpcs
run: ./vendor/bin/phpcs
2 changes: 1 addition & 1 deletion phpcs.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<ruleset name="PSR12">
<description>PSR12</description>
<file>./src</file>
<file>src</file>
<rule ref="PSR12"/>
</ruleset>
14 changes: 10 additions & 4 deletions src/Printer.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,24 @@ protected function printDefectTrace(TestFailure $defect): void
$e = $defect->thrownException();

$errorLines = array_filter(
explode(PHP_EOL, (string)$e),
explode("\n", (string)$e),
function ($l) {
return $l;
}
);

list($path, $line) = explode(":", end($errorLines));
$error = end($errorLines);
$lineIndex = strrpos($error, ":");
$path = substr($error, 0, $lineIndex);
$line = substr($error, $lineIndex + 1);

if (!$path) {
list($path, $line) = $this->getReflectionFromTest(
$defect->getTestName()
);
}

$message = explode(PHP_EOL, $e->getMessage())[0];
$message = explode("\n", $e->getMessage())[0];

$type = $this->getCurrentType();
$file = "file={$this->relativePath($path)}";
Expand All @@ -73,7 +76,10 @@ protected function getCurrentType()

protected function relativePath(string $path)
{
return str_replace(getcwd() . '/', '', $path);
$relative = str_replace(getcwd() . DIRECTORY_SEPARATOR, '', $path);
// Translate \ in to / for Windows
$relative = str_replace('\\', '/', $relative);
return $relative;
}

protected function getReflectionFromTest(string $name)
Expand Down