From 123e826b8a31b27dce8b808e05a66a5800210a86 Mon Sep 17 00:00:00 2001 From: Eirik Stanghelle Morland Date: Wed, 17 Aug 2022 19:39:57 +0200 Subject: [PATCH] Allow process 5.4 (#3) --- .github/workflows/test.yml | 15 +++++++++++---- .travis.yml | 12 ------------ composer.json | 3 ++- src/ProcessFactory.php | 7 ++++--- src/SecurityChecker.php | 8 ++++---- tests/Unit/UnitTest.php | 2 +- 6 files changed, 22 insertions(+), 25 deletions(-) delete mode 100644 .travis.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f333cd6..612a953 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,7 +10,7 @@ jobs: strategy: fail-fast: false matrix: - php-versions: + php-version: - "7.1" - "7.2" - "7.3" @@ -29,7 +29,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: ${{ matrix.php-versions }} + php-version: ${{ matrix.php-version }} - name: Dump composer verson run: composer --version @@ -41,12 +41,19 @@ jobs: run: composer --verbose install - name: Install phpstan if we have to - if: matrix.php-versions != 7.1 + if: matrix.php-version != 7.1 run: composer require --dev phpstan/phpstan - name: Run tests run: composer test - name: run phpstan - if: matrix.php-versions != 7.1 + if: matrix.php-version != 7.1 run: ./vendor/bin/phpstan analyze src tests + + - name: Coveralls + if: matrix.php-version == 7.4 + env: + COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + php vendor/bin/php-coveralls -v diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index be861e1..0000000 --- a/.travis.yml +++ /dev/null @@ -1,12 +0,0 @@ -language: php -php: - - '7.0' - - '7.1' - - '7.2' - - '7.3' -install: - - composer install --dev --no-interaction -script: - - composer test -after_success: - - travis_retry php vendor/bin/php-coveralls -v diff --git a/composer.json b/composer.json index ea24bb5..a4c78e9 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,8 @@ } }, "require": { - "symfony/process": "^2.7 || ^3.0 || ^4.0" + "symfony/process": "^4.0 || ^5.4", + "violinist-dev/process-factory": "^2" }, "scripts": { "test": [ diff --git a/src/ProcessFactory.php b/src/ProcessFactory.php index 1819ebb..7865f4b 100644 --- a/src/ProcessFactory.php +++ b/src/ProcessFactory.php @@ -3,11 +3,12 @@ namespace Violinist\SymfonyCloudSecurityChecker; use Symfony\Component\Process\Process; +use Violinist\ProcessFactory\ProcessFactoryInterface; -class ProcessFactory +class ProcessFactory implements ProcessFactoryInterface { - public function getProcess($command) + public function getProcess(array $commandline, $cwd = null, array $env = null, $input = null, $timeout = 60, array $options = null) { - return new Process($command); + return new Process($commandline, $cwd, $env, $input, $timeout); } } diff --git a/src/SecurityChecker.php b/src/SecurityChecker.php index 8f6d266..6cd6b0a 100644 --- a/src/SecurityChecker.php +++ b/src/SecurityChecker.php @@ -17,14 +17,14 @@ public function checkDirectory($dir) // complain about updating the symfony command. if (getenv('HOME')) { $sdir = sprintf('%s/.symfony/autoupdate', getenv('HOME')); - $command = sprintf('mkdir -p %s', $sdir); + $command = ['mkdir', '-p', $sdir]; $process = $this->getProcess($command); $process->run(); - $command = sprintf('touch %s/silence', $sdir); + $command = ['touch', sprintf('%s/silence', $sdir)]; $process = $this->getProcess($command); $process->run(); } - $command = sprintf('%s security:check --dir=%s --format=json', $this->symfonyCommand, $dir); + $command = [$this->symfonyCommand, 'security:check', sprintf('--dir=%s', $dir), '--format=json']; $process = $this->getProcess($command); $process->run(); $string = $process->getOutput(); @@ -38,7 +38,7 @@ public function checkDirectory($dir) return $json; } - protected function getProcess($command) + protected function getProcess(array $command) { return $this->getProcessFactory()->getProcess($command); } diff --git a/tests/Unit/UnitTest.php b/tests/Unit/UnitTest.php index 94c86d1..513526e 100644 --- a/tests/Unit/UnitTest.php +++ b/tests/Unit/UnitTest.php @@ -58,6 +58,6 @@ public function testGetProcess() $checker = new SecurityChecker(); $factory = $checker->getProcessFactory(); $this->assertTrue($factory instanceof ProcessFactory); - $this->assertTrue($factory->getProcess('true') instanceof Process); + $this->assertTrue($factory->getProcess(['true']) instanceof Process); } }