Skip to content
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
34 changes: 30 additions & 4 deletions .github/workflows/tests.yaml → .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Tests
name: CI

on:
pull_request: null
Expand All @@ -10,7 +10,7 @@ on:

jobs:
Tests:
name: PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}${{ matrix.dependencies }}
name: PHP ${{ matrix.php }} Symfony ${{ matrix.symfony }}${{ matrix.description }}
runs-on: ubuntu-latest
env:
SYMFONY_DEPRECATIONS_HELPER: 'max[self]=0'
Expand All @@ -26,8 +26,7 @@ jobs:
php: '8.3'
- symfony: '^6.4'
php: '8.2'
- description: 'Prefer lowest'
php: '8.2'
- php: '8.2'
dependencies: '--prefer-lowest'
env:
SYMFONY_DEPRECATIONS_HELPER: 'disabled'
Expand Down Expand Up @@ -57,3 +56,30 @@ jobs:
files: './coverage.xml'
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
SA:
strategy:
matrix:
include:
- description: Validate composer.json
script: composer validate
- description: Code style
script: vendor/bin/php-cs-fixer fix --ansi --verbose --dry-run
- description: Rector
script: vendor/bin/rector --ansi --dry-run
- description: PHPStan
script: vendor/bin/phpstan analyze
- description: Psalm
script: vendor/bin/psalm

name: ${{ matrix.description }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
- name: Install dependencies
uses: "ramsey/composer-install@v3"
- run: ${{ matrix.script }}
36 changes: 0 additions & 36 deletions .github/workflows/static-analysis.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ phpstan:
vendor/bin/phpstan analyse

tests:
vendor/bin/phpunit --verbose
vendor/bin/phpunit

.PHONY: tests
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@
"require-dev": {
"facile-it/facile-coding-standard": "^1.2",
"jangregor/phpstan-prophecy": "2.2.0",
"phpspec/prophecy-phpunit": "^2.0",
"phpstan/extension-installer": "^1.4",
"phpstan/phpstan": "2.1.17",
"phpstan/phpstan-phpunit": "2.0.6",
"phpunit/phpunit": "^9.6.6",
"phpspec/prophecy-phpunit": "^2.0",
"phpunit/phpunit": "^10 || ^11 || ^12",
"rector/rector": "2.0.17",
"symfony/phpunit-bridge": "^6.4 || ^7.0",
"vimeo/psalm": "^4.6 || ^5.0"
"vimeo/psalm": "^6"
}
}
22 changes: 11 additions & 11 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
bootstrap="vendor/autoload.php"
executionOrder="depends,defects"
cacheResult="false"
colors="true"
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
bootstrap="vendor/autoload.php"
executionOrder="depends,defects"
cacheResult="false"
colors="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
verbose="true">
displayDetailsOnPhpunitDeprecations="true"
displayDetailsOnTestsThatTriggerDeprecations="true"
cacheDirectory=".phpunit.cache">
<testsuites>
<testsuite name="default">
<directory suffix="Test.php">tests</directory>
</testsuite>
</testsuites>

<coverage processUncoveredFiles="true">
<source>
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
</source>
</phpunit>
8 changes: 8 additions & 0 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="6.12.0@cf420941d061a57050b6c468ef2c778faf40aee2">
<file src="src/AbstractTerminableCommand.php">
<UnusedClass>
<code><![CDATA[AbstractTerminableCommand]]></code>
</UnusedClass>
</file>
</files>
4 changes: 4 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
errorBaseline="psalm-baseline.xml"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
<issueHandlers>
<MissingOverrideAttribute errorLevel="suppress" />
</issueHandlers>
</psalm>
21 changes: 21 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;

return RectorConfig::configure()
->withPaths([
__DIR__ . '/src',
__DIR__ . '/tests',
])
// uncomment to reach your current PHP version
// ->withPhpSets()
->withTypeCoverageLevel(0)
->withDeadCodeLevel(0)
->withCodeQualityLevel(0)
->withAttributesSets(phpunit: true)
->withSets([
\Rector\PHPUnit\Set\PHPUnitSetList::PHPUNIT_100,
])
;
15 changes: 5 additions & 10 deletions tests/E2E/TerminateCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ class TerminateCommandTest extends TestCase
private const STUB_COMMAND = 'stub:terminable:sleep';

/**
* @dataProvider commandLineProvider
*
* @param string[] $commandLine
*/
#[\PHPUnit\Framework\Attributes\DataProvider('commandLineProvider')]
public function testStubCommand(array $commandLine): void
{
$process = new Process($commandLine);
Expand All @@ -37,7 +36,7 @@ public function testStubCommand(array $commandLine): void
/**
* @return string[][][]
*/
public function commandLineProvider(): array
public static function commandLineProvider(): array
{
return [
[
Expand All @@ -58,9 +57,7 @@ public function commandLineProvider(): array
];
}

/**
* @dataProvider provideSignals
*/
#[\PHPUnit\Framework\Attributes\DataProvider('provideSignals')]
public function testSignalsDuringCommandBody(int $signal, int $exitCode): void
{
$process = new Process([
Expand All @@ -87,9 +84,7 @@ public function testSignalsDuringCommandBody(int $signal, int $exitCode): void
$this->assertSame($exitCode, $process->getExitCode());
}

/**
* @dataProvider provideSignals
*/
#[\PHPUnit\Framework\Attributes\DataProvider('provideSignals')]
public function testSigTermDuringSleep(int $signal, int $exitCode): void
{
$process = new Process([
Expand Down Expand Up @@ -119,7 +114,7 @@ public function testSigTermDuringSleep(int $signal, int $exitCode): void
/**
* @return array<array{int,int}>
*/
public function provideSignals(): array
public static function provideSignals(): array
{
return [
[SIGTERM, 143],
Expand Down
16 changes: 5 additions & 11 deletions tests/Unit/AbstractTerminableCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ protected function commandBody(InputInterface $input, OutputInterface $output):
$stubCommand->run(new ArrayInput([]), $output->reveal());
}

/**
* @dataProvider signalProvider
*/
#[\PHPUnit\Framework\Attributes\DataProvider('signalProvider')]
public function testReceiveSignalDuringCommandBody(int $signal): void
{
$stubCommand = new class ($signal) extends AbstractTerminableCommand {
Expand Down Expand Up @@ -112,17 +110,15 @@ protected function commandBody(InputInterface $input, OutputInterface $output):
$this->assertSame(143, $exitCode);
}

/**
* @dataProvider signalProvider
*/
#[\PHPUnit\Framework\Attributes\DataProvider('signalProvider')]
public function testReceiveSignalBeforeCommandBody(int $signal): void
{
$stubCommand = $this->createStubTerminableCommand();

$output = $this->prophesize(OutputInterface::class);
$output->writeln(Argument::containingString('Starting'), OutputInterface::VERBOSITY_VERBOSE)
->shouldBeCalledTimes(1)
->will(function () use ($stubCommand, $signal) {
->will(function () use ($stubCommand, $signal): void {
$stubCommand->handleSignal($signal);
});
$output->writeln('Signal received, skipping execution', OutputInterface::VERBOSITY_NORMAL)
Expand All @@ -133,9 +129,7 @@ public function testReceiveSignalBeforeCommandBody(int $signal): void
$this->assertSame(143, $exitCode);
}

/**
* @dataProvider signalProvider
*/
#[\PHPUnit\Framework\Attributes\DataProvider('signalProvider')]
public function testGetSubscribedSignals(int $signal): void
{
$stubCommand = $this->createStubTerminableCommand();
Expand All @@ -146,7 +140,7 @@ public function testGetSubscribedSignals(int $signal): void
/**
* @return array{0: int}[]
*/
public function signalProvider(): array
public static function signalProvider(): array
{
return [
[SIGINT],
Expand Down