diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..8c11ff5 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,30 @@ +on: [push, pull_request, release] +name: Test +jobs: + test: + runs-on: ubuntu-latest + container: + image: pluswerk/php-dev:nginx-${{ matrix.php }} + options: -t + strategy: + fail-fast: false + matrix: + php: ['7.4', '8.0', '8.1', '8.2'] + name: 'PHP ${{ matrix.php }}' + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Cache dependenciess + uses: actions/cache@v2 + with: + path: ~/.composer/cache/files + key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} + - run: composer install + - run: vendor/bin/grumphp run + - run: git config --global --add safe.directory /__w/phpsu/ShellCommandBuilder + - run: script -q -e -c "composer test" + - run: script -q -e -c "composer infection" + - run: composer psalm -- --output-format=github --shepherd + - uses: codecov/codecov-action@v1 + with: + file: ./tests/test-results/coverage.xml diff --git a/.github/workflows/shepherd.yml b/.github/workflows/shepherd.yml deleted file mode 100644 index 9a0e125..0000000 --- a/.github/workflows/shepherd.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: Run Shepherd - -on: [push, pull_request] - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - - name: Install dependencies - run: composer install --prefer-dist --no-progress --no-suggest - - - name: Run Psalm - run: composer psalm -- --output-format=github --shepherd diff --git a/composer.json b/composer.json index 323af8e..9495796 100644 --- a/composer.json +++ b/composer.json @@ -4,15 +4,19 @@ "type": "library", "config": { "optimize-autoloader": true, - "process-timeout": 0 + "process-timeout": 0, + "allow-plugins": { + "infection/extension-installer": true, + "phpro/grumphp": true, + "pluswerk/grumphp-config": true + } }, "require-dev": { "phpunit/phpunit": "^8.5 || ^9.4", "vimeo/psalm": "^4.1", - "infection/infection": "^0.15.3 || ^0.18.2 || ^0.20.1", + "infection/infection": "^0.26.0", "spatie/phpunit-watcher": "^1.24 || dev-master#071fbbf", - "phpunit/php-invoker": "^2.0 || ^3.1", - "pluswerk/grumphp-config": "^4.0.1" + "pluswerk/grumphp-config": "^5.0.2" }, "license": "MIT", "authors": [ @@ -39,8 +43,9 @@ }, "minimum-stability": "stable", "require": { - "php": ">=7.2", - "ext-json": "*" + "php": "~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0", + "ext-json": "*", + "composer-runtime-api": "^2.0.0" }, "extra": { "pluswerk/grumphp-config": { diff --git a/src/Exception/ShellBuilderException.php b/src/Exception/ShellBuilderException.php index 48206c9..5523a2e 100644 --- a/src/Exception/ShellBuilderException.php +++ b/src/Exception/ShellBuilderException.php @@ -6,5 +6,4 @@ final class ShellBuilderException extends \Exception { - } diff --git a/src/ShellConditional.php b/src/ShellConditional.php index 64e580c..286ee47 100644 --- a/src/ShellConditional.php +++ b/src/ShellConditional.php @@ -14,9 +14,7 @@ public function if(bool $condition, callable $callback, callable $alternativeCal return $result; } if ($alternativeCallback) { - $alternativeResult = $alternativeCallback($this); - assert($alternativeResult instanceof self); - return $alternativeResult; + return $alternativeCallback($this); } return $this; } diff --git a/tests/ShellBuilderTest.php b/tests/ShellBuilderTest.php index 26a9fe6..6d5e8ef 100644 --- a/tests/ShellBuilderTest.php +++ b/tests/ShellBuilderTest.php @@ -756,7 +756,7 @@ static function (ShellBuilder $builder) { public function testComplexCondiditionalArgumentsWithWrongArguments(): void { - self::expectException(\AssertionError::class); + self::expectException(\TypeError::class); ShellBuilder::new() ->ifThis(static function (ShellBuilder $builder) { return 'world'; @@ -769,7 +769,7 @@ public function testComplexCondiditionalArgumentsWithWrongArguments(): void public function testCondiditionalArgumentsWithWrongArguments(): void { - self::expectException(\AssertionError::class); + self::expectException(\TypeError::class); ShellBuilder::new() ->if( true, diff --git a/tests/ShellCommandTest.php b/tests/ShellCommandTest.php index 06287e7..a854b10 100644 --- a/tests/ShellCommandTest.php +++ b/tests/ShellCommandTest.php @@ -14,14 +14,14 @@ class ShellCommandTest extends TestCase { public function testShellCommand(): void { - $command = new ShellCommand('mysql'); + $command = new ShellCommand('mariadb-dump'); $command->addShortOption('u', 'username') ->addShortOption('p', 'password') ->addShortOption('h', '127.0.0.1') ->addArgument('database') ->addOption('skip-comments') ; - $this->assertEquals("mysql -u 'username' -p 'password' -h '127.0.0.1' 'database' --skip-comments", (string)$command); + $this->assertEquals("mariadb-dump -u 'username' -p 'password' -h '127.0.0.1' 'database' --skip-comments", (string)$command); } public function testShellCommandWithEnvironmentVariables(): void