Skip to content

Commit

Permalink
Merge branch 'release/2.0.0-beta5'
Browse files Browse the repository at this point in the history
  • Loading branch information
TravisCarden committed Apr 3, 2024
2 parents 7df5ce8 + 0a028f4 commit e687ed9
Show file tree
Hide file tree
Showing 15 changed files with 117 additions and 73 deletions.
27 changes: 13 additions & 14 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: "Set up PHP"
uses: shivammathur/setup-php@v2 # https://github.com/marketplace/actions/setup-php-action
with:
php-version: "8.1"
php-version: "8.2"
coverage: none

- name: "Checkout code"
Expand All @@ -41,28 +41,28 @@ jobs:
run: "composer static"

tests:
name: "Test: ${{ matrix.os }} / deps-${{ matrix.dependencies }}"
runs-on: "${{ matrix.os }}"
name: "Test: ${{ matrix.os }} / ${{ matrix.php }} / ${{ matrix.dependencies }}"
runs-on: "${{ matrix.os }}-latest"
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
php: [ "8.1" ]
os: [ ubuntu, macos, windows ]
php: [ "8.1", "8.2" ]
dependencies: [ lowest, highest ]
steps:
- name: "Install rsync"
uses: GuillaumeFalourd/[email protected] # https://github.com/marketplace/actions/setup-rsync

- name: "Set up PHP w/ Coverage"
if: ${{ matrix.os == 'ubuntu-latest' && matrix.dependencies == 'highest' }}
if: ${{ matrix.os == 'ubuntu' && matrix.dependencies == 'highest' }}
uses: shivammathur/setup-php@v2 # https://github.com/marketplace/actions/setup-php-action
with:
php-version: "${{ matrix.php }}"
extensions: gd
ini-values: assert.active=1, assert.exception=1, zend.assertions=1

- name: "Set up PHP w/o Coverage"
if: ${{ !( matrix.os == 'ubuntu-latest' && matrix.dependencies == 'highest' ) }}
if: ${{ !( matrix.os == 'ubuntu' && matrix.dependencies == 'highest' ) }}
uses: shivammathur/setup-php@v2 # https://github.com/marketplace/actions/setup-php-action
with:
php-version: "${{ matrix.php }}"
Expand All @@ -85,33 +85,32 @@ jobs:

- name: "Run core tests with coverage"
run: "composer test"
if: ${{ matrix.os == 'ubuntu-latest' && matrix.dependencies == 'highest' }}
if: ${{ matrix.os == 'ubuntu' && matrix.dependencies == 'highest' }}

# There's no reason to generate coverage data on multiple jobs--the result should be the same.
- name: "Run core tests without coverage"
run: "./vendor/bin/phpunit --no-coverage --exclude-group=windows_only"
if: ${{ runner.os != 'Windows' && !( matrix.os == 'ubuntu-latest' && matrix.dependencies == 'highest' ) }}
if: ${{ runner.os != 'Windows' && !( matrix.os == 'ubuntu' && matrix.dependencies == 'highest' ) }}

- name: "Run Windows tests"
run: "./vendor/bin/phpunit --no-coverage --exclude-group=no_windows"
if: ${{ runner.os == 'Windows' }}

performance:
name: "Performance: ${{ matrix.os }}"
runs-on: "${{ matrix.os }}"
runs-on: "${{ matrix.os }}-latest"
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, windows-latest ]
php: [ "8.1" ]
os: [ ubuntu, windows ]
steps:
- name: "Install rsync"
uses: GuillaumeFalourd/[email protected] # https://github.com/marketplace/actions/setup-rsync

- name: "Set up PHP"
uses: shivammathur/setup-php@v2 # https://github.com/marketplace/actions/setup-php-action
with:
php-version: "8.1"
php-version: "8.2"
coverage: none

- name: "Checkout code"
Expand All @@ -130,7 +129,7 @@ jobs:
- name: "Set up PHP"
uses: shivammathur/setup-php@v2 # https://github.com/marketplace/actions/setup-php-action
with:
php-version: "8.1"
php-version: "8.2"
extensions: gd
ini-values: assert.active=1, assert.exception=1, zend.assertions=1

Expand Down
2 changes: 1 addition & 1 deletion .idea/runConfigurations/PHPCS.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"require": {
"php": ">=8.1.0",
"ext-json": "*",
"symfony/filesystem": "^6.2",
"symfony/process": "^6.2",
"symfony/filesystem": "^6.2 || ^7.0",
"symfony/process": "^6.2 || ^7.0",
"symfony/translation-contracts": "^3.1"
},
"require-dev": {
Expand Down
30 changes: 15 additions & 15 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/API/Process/Service/ProcessInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function getOutput(): string;
*
* @see \PhpTuf\ComposerStager\API\Process\Service\ProcessInterface::run
*/
public function mustRun(?OutputCallbackInterface $callback = null): self;
public function mustRun(?OutputCallbackInterface $callback = null): void;

/**
* Runs the process.
Expand Down Expand Up @@ -89,7 +89,7 @@ public function run(?OutputCallbackInterface $callback = null): int;
*
* @see \PhpTuf\ComposerStager\API\Process\Service\ProcessInterface::getEnv
*/
public function setEnv(array $env): self;
public function setEnv(array $env): void;

/**
* Sets the process timeout (max. runtime) in seconds.
Expand All @@ -101,5 +101,5 @@ public function setEnv(array $env): self;
* @throws \PhpTuf\ComposerStager\API\Exception\InvalidArgumentException
* If the given timeout is negative.
*/
public function setTimeout(int $timeout = self::DEFAULT_TIMEOUT): self;
public function setTimeout(int $timeout = self::DEFAULT_TIMEOUT): void;
}
12 changes: 3 additions & 9 deletions src/Internal/Process/Service/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function getOutput(): string
}
}

public function mustRun(?OutputCallbackInterface $callback = null): self
public function mustRun(?OutputCallbackInterface $callback = null): void
{
try {
$callbackAdapter = new OutputCallbackAdapter($callback);
Expand All @@ -110,8 +110,6 @@ public function mustRun(?OutputCallbackInterface $callback = null): self
$this->d()->exceptions(),
), 0, $e);
}

return $this;
}

public function run(?OutputCallbackInterface $callback = null): int
Expand All @@ -129,15 +127,13 @@ public function run(?OutputCallbackInterface $callback = null): int
}
}

public function setEnv(array $env): ProcessInterface
public function setEnv(array $env): void
{
$this->assertValidEnv($env);
$this->symfonyProcess->setEnv($env);

return $this;
}

public function setTimeout(int $timeout = self::DEFAULT_TIMEOUT): self
public function setTimeout(int $timeout = self::DEFAULT_TIMEOUT): void
{
try {
$this->symfonyProcess->setTimeout($timeout);
Expand All @@ -148,8 +144,6 @@ public function setTimeout(int $timeout = self::DEFAULT_TIMEOUT): self
$this->d()->exceptions(),
), 0, $e);
}

return $this;
}

/**
Expand Down
3 changes: 2 additions & 1 deletion tests/Compatability/CompatabilityFunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ final class CompatabilityFunctionalTest extends TestCase
'10.1.0',
'10.1.2',
// Next minor dev.
'11.x-dev',
// @todo Drupal 11.x now require PHP 8.3. Update the test setup for support.
//'11.x-dev',
];

public static function setUpBeforeClass(): void
Expand Down
6 changes: 2 additions & 4 deletions tests/Finder/Service/ExecutableFinderUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ public function testFind(): void
$command = 'command_name';
$this->symfonyExecutableFinder
->addSuffix('.phar')
->shouldBeCalled()
->willReturn(null);
->shouldBeCalled();
$this->symfonyExecutableFinder
->find($command)
->shouldBeCalledOnce()
Expand All @@ -60,8 +59,7 @@ public function testFindNotFound(): void
$command = 'command_name';
$this->symfonyExecutableFinder
->addSuffix('.phar')
->shouldBeCalledOnce()
->willReturn(null);
->shouldBeCalledOnce();
$this->symfonyExecutableFinder
->find($command)
->shouldBeCalledOnce()
Expand Down
3 changes: 1 addition & 2 deletions tests/Precondition/Service/ComposerIsAvailableUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ protected function setUp(): void
$this->processFactory = $this->prophesize(ProcessFactoryInterface::class);
$this->process = $this->prophesize(ProcessInterface::class);
$this->process
->mustRun()
->willReturn($this->process);
->mustRun();
$this->process
->getOutput()
->willReturn(json_encode([
Expand Down
3 changes: 1 addition & 2 deletions tests/Precondition/Service/RsyncIsAvailableUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ protected function setUp(): void
$this->processFactory = $this->prophesize(ProcessFactoryInterface::class);
$this->process = $this->prophesize(ProcessInterface::class);
$this->process
->mustRun()
->willReturn($this->process);
->mustRun();
$this->process
->getOutput()
->willReturn('');
Expand Down
12 changes: 4 additions & 8 deletions tests/Process/Service/AbstractProcessRunnerUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,9 @@ protected function setUp(): void
$this->processFactory = $this->prophesize(ProcessFactoryInterface::class);
$this->process = $this->prophesize(ProcessInterface::class);
$this->process
->mustRun(Argument::any())
->willReturn($this->process);
->mustRun(Argument::any());
$this->process
->setTimeout(Argument::any())
->willReturn($this->process);
->setTimeout(Argument::any());
}

private function createSut($executableName = null): AbstractProcessRunner
Expand Down Expand Up @@ -100,12 +98,10 @@ public function testBasicFunctionality(
->shouldBeCalledOnce();
$this->process
->setTimeout($timeout)
->shouldBeCalledOnce()
->willReturn($this->process);
->shouldBeCalledOnce();
$this->process
->mustRun($callback)
->shouldBeCalledOnce()
->willReturn($this->process);
->shouldBeCalledOnce();
$this->processFactory
->create(...$expectedFactoryArguments)
->shouldBeCalledOnce()
Expand Down
9 changes: 3 additions & 6 deletions tests/Process/Service/ProcessUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,21 +124,18 @@ public function testBasicFunctionality(
->shouldBeCalledOnce();
$sut = $this->createSut($givenConstructorArguments);

$actualSetEnvReturn = $sut->setEnv($envVars);
$sut->setEnv($envVars);
$actualEnv = $sut->getEnv();
$actualOutput = $sut->getOutput();
$actualErrorOutput = $sut->getErrorOutput();
$actualMustRunReturn = $sut->mustRun(...$givenRunArguments);
$sut->mustRun(...$givenRunArguments);
$actualRunReturn = $sut->run(...$givenRunArguments);
$actualSetTimeoutReturn = $sut->setTimeout(...$givenSetTimeoutArguments);
$sut->setTimeout(...$givenSetTimeoutArguments);

self::assertSame($actualEnv, $envVars, 'Returned correct output.');
self::assertSame($output, $actualOutput, 'Returned correct output.');
self::assertSame($errorOutput, $actualErrorOutput, 'Returned correct error output.');
self::assertSame($sut, $actualMustRunReturn, 'Returned "self" from ::mustRun().');
self::assertSame($expectedRunReturn, $actualRunReturn, 'Returned correct status code from ::run().');
self::assertSame($sut, $actualSetEnvReturn, 'Returned "self" from ::setEnv().');
self::assertSame($sut, $actualSetTimeoutReturn, 'Returned "self" from ::setTimeout().');
}

public function providerBasicFunctionality(): array
Expand Down
Loading

0 comments on commit e687ed9

Please sign in to comment.