From cd9c198e67da8246595af87283e89c6dffbe700c Mon Sep 17 00:00:00 2001 From: Fabien Villepinte Date: Thu, 3 Feb 2022 14:38:40 +0100 Subject: [PATCH] Check PHP requirement without Box --- .github/workflows/continuous-integration.yml | 44 ++++++++++++++++++-- .github/workflows/release.yml | 2 +- Makefile | 2 +- bin/app.php | 23 ++++++++++ bin/churn | 44 +++++++++++++------- box.json.dist | 1 + 6 files changed, 95 insertions(+), 21 deletions(-) create mode 100644 bin/app.php diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 74c06233..91488182 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -220,7 +220,7 @@ jobs: with: coverage: "none" ini-values: "error_reporting=-1, display_errors=On, display_startup_errors=On, zend.assertions=1" - php-version: "7.2" + php-version: "8.0" tools: composer:v2 - name: Get composer cache directory @@ -257,7 +257,7 @@ jobs: path: ./churn.phar if-no-files-found: error - tests-oldphp: + tests-phar-oldphp: name: "Test Phar error message with PHP ${{ matrix.php-version }}" runs-on: ubuntu-latest # We need the phar file @@ -291,5 +291,43 @@ jobs: - name: Test churn.phar error message run: | - php -r "passthru('./churn.phar', \$code); if (\$code !== 1) exit('Invalid error code. Expected 1, got ' . \$code);" > error + php -r "passthru('./churn.phar', \$code); if (\$code !== 1) exit('Invalid error code. Expected 1, got ' . \$code);" &> error + echo "Error code is OK. Now testing error message..." grep 'The application requires the version ">=7.1.3" or greater' error + echo "Everything is OK." + + + tests-phar: + name: "Test Phar with PHP ${{ matrix.php-version }}" + runs-on: ubuntu-latest + # We need the phar file + needs: [build] + + strategy: + matrix: + php-version: + - "7.1" + - "8.1" + + steps: + - name: "Checkout" + uses: "actions/checkout@v2" + + - name: "Install PHP" + uses: "shivammathur/setup-php@v2" + with: + coverage: "none" + ini-values: "error_reporting=-1, display_errors=On, display_startup_errors=On, zend.assertions=1" + php-version: ${{ matrix.php-version }} + tools: none + + - name: Download churn.phar + uses: actions/download-artifact@v2 + with: + name: churn.phar + + - name: Make churn.phar executable + run: chmod +x churn.phar + + - name: "Run Phar" + run: ./churn.phar diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f9c62f42..7cde844b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -28,7 +28,7 @@ jobs: uses: "shivammathur/setup-php@v2" with: coverage: "none" - php-version: "7.4" + php-version: "8.0" tools: composer:v2 - name: "Print tag message" diff --git a/Makefile b/Makefile index 54261c5c..4f5cfbbc 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ help: .PHONY: box box: ## Download box.phar box: - test -e build/box.phar || curl -sL https://github.com/box-project/box/releases/download/3.9.1/box.phar -o build/box.phar + test -e build/box.phar || curl -sL https://github.com/box-project/box/releases/download/3.14.0/box.phar -o build/box.phar chmod +x build/box.phar .PHONY: build diff --git a/bin/app.php b/bin/app.php new file mode 100644 index 00000000..5fd72619 --- /dev/null +++ b/bin/app.php @@ -0,0 +1,23 @@ +add(new AssessComplexityCommand()); +$application->add($run = RunCommand::newInstance()); +$application->setDefaultCommand($run->getName()); + +return $application; diff --git a/bin/churn b/bin/churn index 408ab36b..21fba1a6 100755 --- a/bin/churn +++ b/bin/churn @@ -1,23 +1,35 @@ #!/usr/bin/env php =')) { + fwrite( + STDERR, + sprintf( + 'The application requires the version ">=7.1.3" or greater.' . PHP_EOL . + 'You are using PHP %s (%s).' . PHP_EOL, + PHP_VERSION, + PHP_BINARY + ) + ); -$application = new Application('churn-php', (function (string $package): string { - $version = InstalledVersions::getPrettyVersion($package); - $ref = InstalledVersions::getReference($package); - if ($ref) { - $version .= '@' . \substr($ref, 0, 7); - } + die(1); +} + +require_once __DIR__ . '/bootstrap.php'; - return $version; -})('bmitch/churn-php')); -$application->add(new AssessComplexityCommand()); -$application->add($run = RunCommand::newInstance()); -$application->setDefaultCommand($run->getName()); +$application = require_once __DIR__ . '/app.php'; $application->run(); diff --git a/box.json.dist b/box.json.dist index 1ce0db16..14ebec6c 100644 --- a/box.json.dist +++ b/box.json.dist @@ -1,4 +1,5 @@ { + "check-requirements": false, "compactors": [ "KevinGH\\Box\\Compactor\\Php" ],