Skip to content

Commit

Permalink
Php8.1 support (#67)
Browse files Browse the repository at this point in the history
* Fix Namespace

* Clean up ignores

* PHP8.1 support

Also adding in github action and removing travis

* Wrong command used

* Wrong command used

* Remove support for speeding up by filtering

* PHPCS issue..

* Fix the command

* Ignore function comments issue
  • Loading branch information
exussum12 authored Sep 26, 2021
1 parent 495c9cb commit 5a91d87
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 29 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: CI
on:
push:
pull_request:
jobs:
tests:
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: ['ubuntu-latest', 'windows-latest', 'macOS-latest']
php-version: ['7.1', '7.2', '7.3', '7.4', '8.0']
name: PHP ${{ matrix.php-version }} Test on ${{ matrix.operating-system }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Cache dependencies
uses: actions/cache@v1
with:
path: /tmp/composer-cache
key: dependencies-composer-${{ hashFiles('composer.json') }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
tools: composer:v2
- name: Install Composer dependencies
run: composer install --prefer-dist --no-interaction --no-suggest
- name: Install phpcs
run: composer global require squizlabs/php_codesniffer
- name: Install phpmd
run: composer global require phpmd/phpmd
- name: Run the build
run: ./build.sh
21 changes: 0 additions & 21 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ git log origin/master... | grep -q SKIP_BUILD && exit 0

[ -z "$UPDATE_COVERAGE" ] || composer require satooshi/php-coveralls:v1.1.0

composer install --dev
composer install
git diff $(git merge-base origin/master HEAD) > diff.txt
phpcs --standard=psr2 src
phpcs --standard=psr2 --ignore=bootstrap.php,fixtures/* tests
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "exussum12/coverage-checker",
"description": "Allows checking the code coverage of a single pull request",
"require-dev": {
"phpunit/phpunit": "^6.5 || ^7.0 || ^8.0"
"phpunit/phpunit": "^6.5 || ^7.0 || ^8.0 || ^9.0"
},
"license": "MIT",
"authors": [
Expand Down
12 changes: 7 additions & 5 deletions src/Loaders/Clover.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ public function parseLines(): array
/**
* {@inheritdoc}
*/
public function getErrorsOnLine(string $file, int $line)
public function getErrorsOnLine(string $file, int $lineNumber)
{
if (!isset($this->coveredLines[$file][$line])) {
if (!isset($this->coveredLines[$file][$lineNumber])) {
return null;
}
return $this->coveredLines[$file][$line] > 0 ?
return $this->coveredLines[$file][$lineNumber] > 0 ?
[]:
['No unit test covering this line']
;
Expand Down Expand Up @@ -92,11 +92,13 @@ protected function checkForNewFiles(XMLReader $reader, string $currentFile)
protected function addLine(XMLReader $reader, string $currentFile)
{
$covered = $reader->getAttribute('count') > 0;
$line = $this->coveredLines
[$currentFile]
[$reader->getAttribute('num')] ?? 0;

$this->coveredLines
[$currentFile]
[$reader->getAttribute('num')]
= $covered ?: "No test coverage";
[$reader->getAttribute('num')] = $line + $covered;
}

protected function handleStatement(XMLReader $reader, string $currentFile)
Expand Down
6 changes: 5 additions & 1 deletion src/Loaders/PhpCs.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ class PhpCs implements FileChecker
'Squiz.Commenting.FunctionComment',
];

protected $functionIgnoreComments = [
'Squiz.Commenting.FunctionComment.ParamCommentFullStop'
];

/**
* @var array
*/
Expand Down Expand Up @@ -123,7 +127,7 @@ protected function addInvalidLine(string $file, stdClass $message)

$error = $this->messageStartsWith($message->source, $this->lookupErrorPrefix);

if ($error) {
if ($error && !in_array($message->source, $this->functionIgnoreComments, true)) {
$this->handleLookupError($file, $message, $error);
return;
}
Expand Down
3 changes: 3 additions & 0 deletions tests/PhpunitFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ class PhpunitFilterTest extends TestCase
*/
public function setUpTest()
{
if (PHP_VERSION > 7.2) {
$this->markTestSkipped("Not currently supported");
}
$this->coverage = __DIR__ . '/fixtures/php-coverage.php';
$this->diff = new DiffFileLoader(__DIR__ . '/fixtures/change.txt');
$this->matcher = new FileMatchers\EndsWith();
Expand Down

0 comments on commit 5a91d87

Please sign in to comment.