From 58549723fb306112ca367861a6e03032edc3d285 Mon Sep 17 00:00:00 2001 From: Matt Glaman Date: Wed, 17 Mar 2021 16:31:35 -0500 Subject: [PATCH] Add test for config_update and fix missing dependency (#217) --- .github/workflows/php.yml | 63 ++++++++++++++++++++- composer.json | 2 +- composer.lock | 104 +++++++++++++++++------------------ src/Command/CheckCommand.php | 4 +- 4 files changed, 116 insertions(+), 57 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 6d29a52..b7f5351 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -45,6 +45,8 @@ jobs: run: "php vendor/bin/phpcs src" # - name: "PHPStan" # run: "php vendor/bin/phpstan analyze src" + - name: Remove vendor directory for integration testing + run: rm -rf vendor - name: Setup Drupal run: | COMPOSER_MEMORY_LIMIT=-1 composer create-project drupal/recommended-project:${{ matrix.drupal }} ~/drupal --no-interaction @@ -52,7 +54,7 @@ jobs: composer config minimum-stability dev composer config prefer-stable true composer config preferred-install dist - composer config repositories.0 path $GITHUB_WORKSPACE + composer config repositories.0 "{\"type\": \"path\", \"url\": \"$GITHUB_WORKSPACE\", \"options\": {\"symlink\": false}}" composer config repositories.1 composer https://packages.drupal.org/8 COMPOSER_MEMORY_LIMIT=-1 composer require drupal/core-dev:${{ matrix.drupal }} --with-all-dependencies - name: "Add phpspec/prophecy-phpunit" @@ -67,8 +69,63 @@ jobs: - name: "Analyze core/install.php" run: | cd ~/drupal - ./vendor/bin/drupal-check web/core/install.php + ./vendor/bin/drupal-check -vvv web/core/install.php - name: "Analyze dynamic_page_cache" run: | cd ~/drupal - ./vendor/bin/drupal-check web/core/modules/dynamic_page_cache || if (($? == 255)); then false; else true; fi + ./vendor/bin/drupal-check -vvv web/core/modules/dynamic_page_cache || if (($? == 255)); then false; else true; fi + + contrib: + runs-on: "ubuntu-latest" + name: "${{ matrix.project }} | PHP ${{ matrix.php-version }} | Drupal ${{ matrix.drupal }}" + strategy: + matrix: + include: + - php-version: "7.3" + drupal: "~8.9" + project: config_update + additional_projects: '' + type: module + - php-version: "7.3" + drupal: "~8.9" + project: blazy + additional_projects: 'drupal/token drupal/ctools' + type: module + steps: + - name: "Checkout" + uses: "actions/checkout@v2" + - name: "Install PHP" + uses: "shivammathur/setup-php@v2" + with: + coverage: "none" + php-version: "${{ matrix.php-version }}" + tools: composer:v2 + extensions: dom, curl, libxml, mbstring, zip, pdo, mysql, pdo_mysql, bcmath, gd, exif, iconv + - name: Setup Drupal + run: | + COMPOSER_MEMORY_LIMIT=-1 composer create-project drupal/recommended-project:${{ matrix.drupal }} ~/drupal --no-interaction + cd ~/drupal + composer config minimum-stability dev + composer config prefer-stable true + composer config preferred-install dist + composer config repositories.0 "{\"type\": \"path\", \"url\": \"$GITHUB_WORKSPACE\", \"options\": {\"symlink\": false}}" + composer config repositories.1 composer https://packages.drupal.org/8 + COMPOSER_MEMORY_LIMIT=-1 composer require drupal/core-dev:${{ matrix.drupal }} --with-all-dependencies + - name: "Add phpspec/prophecy-phpunit" + run: | + cd ~/drupal + COMPOSER_MEMORY_LIMIT=-1 composer require --dev phpspec/prophecy-phpunit:^2 + if: ${{ matrix.drupal == '^9.0' }} + - name: "require drupal-check" + run: | + cd ~/drupal + COMPOSER_MEMORY_LIMIT=-1 composer require mglaman/drupal-check *@dev + - name: "verify drupal-check version" + run: | + cd ~/drupal + ./vendor/bin/drupal-check --version + - name: 'Check ${{ matrix.project }}' + run: | + cd ~/drupal + COMPOSER_MEMORY_LIMIT=-1 composer require drupal/${{ matrix.project }} ${{ matrix.additional_projects }} + ./vendor/bin/drupal-check -vvv web/${{ matrix.type }}s/contrib/${{ matrix.project }} --no-progress || if (($? == 255 || $? == 127)); then false; else true; fi diff --git a/composer.json b/composer.json index 1f37630..50b8c0b 100644 --- a/composer.json +++ b/composer.json @@ -15,13 +15,13 @@ "jean85/pretty-package-versions": "^1.5.0 || ^2.0.1", "mglaman/phpstan-drupal": "^0.12.8", "nette/neon": "^3.1", + "phpstan/phpstan-deprecation-rules": "^0.12.6", "symfony/console": "~3.2 || ~4.0", "symfony/process": "~3.2 || ~4.0", "webflo/drupal-finder": "^1.1" }, "require-dev": { "phpstan/phpstan": "^0.12.81", - "phpstan/phpstan-deprecation-rules": "^0.12.6", "phpstan/phpstan-strict-rules": "^0.12.9", "squizlabs/php_codesniffer": "^3.4" }, diff --git a/composer.lock b/composer.lock index 4132cc8..1fa72f8 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "f4050c285b6019c923376b498c756243", + "content-hash": "57f0b2c8e882be236d754290fadd466c", "packages": [ { "name": "composer/xdebug-handler", @@ -506,6 +506,57 @@ ], "time": "2021-03-08T22:03:02+00:00" }, + { + "name": "phpstan/phpstan-deprecation-rules", + "version": "0.12.6", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan-deprecation-rules.git", + "reference": "46dbd43c2db973d2876d6653e53f5c2cc3a01fbb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan-deprecation-rules/zipball/46dbd43c2db973d2876d6653e53f5c2cc3a01fbb", + "reference": "46dbd43c2db973d2876d6653e53f5c2cc3a01fbb", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0", + "phpstan/phpstan": "^0.12.60" + }, + "require-dev": { + "phing/phing": "^2.16.3", + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpstan/phpstan-phpunit": "^0.12", + "phpunit/phpunit": "^7.5.20" + }, + "type": "phpstan-extension", + "extra": { + "branch-alias": { + "dev-master": "0.12-dev" + }, + "phpstan": { + "includes": [ + "rules.neon" + ] + } + }, + "autoload": { + "psr-4": { + "PHPStan\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan rules for detecting usage of deprecated classes, methods, properties, constants and traits.", + "support": { + "issues": "https://github.com/phpstan/phpstan-deprecation-rules/issues", + "source": "https://github.com/phpstan/phpstan-deprecation-rules/tree/0.12.6" + }, + "time": "2020-12-13T10:20:54+00:00" + }, { "name": "psr/container", "version": "1.1.1", @@ -1271,57 +1322,6 @@ } ], "packages-dev": [ - { - "name": "phpstan/phpstan-deprecation-rules", - "version": "0.12.6", - "source": { - "type": "git", - "url": "https://github.com/phpstan/phpstan-deprecation-rules.git", - "reference": "46dbd43c2db973d2876d6653e53f5c2cc3a01fbb" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan-deprecation-rules/zipball/46dbd43c2db973d2876d6653e53f5c2cc3a01fbb", - "reference": "46dbd43c2db973d2876d6653e53f5c2cc3a01fbb", - "shasum": "" - }, - "require": { - "php": "^7.1 || ^8.0", - "phpstan/phpstan": "^0.12.60" - }, - "require-dev": { - "phing/phing": "^2.16.3", - "php-parallel-lint/php-parallel-lint": "^1.2", - "phpstan/phpstan-phpunit": "^0.12", - "phpunit/phpunit": "^7.5.20" - }, - "type": "phpstan-extension", - "extra": { - "branch-alias": { - "dev-master": "0.12-dev" - }, - "phpstan": { - "includes": [ - "rules.neon" - ] - } - }, - "autoload": { - "psr-4": { - "PHPStan\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "PHPStan rules for detecting usage of deprecated classes, methods, properties, constants and traits.", - "support": { - "issues": "https://github.com/phpstan/phpstan-deprecation-rules/issues", - "source": "https://github.com/phpstan/phpstan-deprecation-rules/tree/0.12.6" - }, - "time": "2020-12-13T10:20:54+00:00" - }, { "name": "phpstan/phpstan-strict-rules", "version": "0.12.9", diff --git a/src/Command/CheckCommand.php b/src/Command/CheckCommand.php index 3f36ed5..0361791 100644 --- a/src/Command/CheckCommand.php +++ b/src/Command/CheckCommand.php @@ -2,7 +2,6 @@ namespace DrupalCheck\Command; -use DrupalCheck\Util\Tty; use DrupalFinder\DrupalFinder; use Nette\Neon\Neon; use PHPStan\ShouldNotHappenException; @@ -179,6 +178,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $pharPath = \Phar::running(); if ($pharPath !== '') { // Running in packaged Phar archive. + $output->writeln('Assumed running as Phar', OutputInterface::VERBOSITY_DEBUG); $phpstanBin = \realpath('vendor/phpstan/phpstan/phpstan.phar'); $configuration_data['parameters']['bootstrapFiles'] = [\realpath($pharPath . '/error-bootstrap.php')]; $configuration_data['includes'] = [ @@ -187,6 +187,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int ]; } elseif (file_exists(__DIR__ . '/../../vendor/autoload.php')) { // Running as a project dependency. + $output->writeln('Assumed running as local dependency', OutputInterface::VERBOSITY_DEBUG); $phpstanBin = \realpath(__DIR__ . '/../../vendor/phpstan/phpstan/phpstan.phar'); $configuration_data['parameters']['bootstrapFiles'] = [\realpath(__DIR__ . '/../../error-bootstrap.php')]; $configuration_data['includes'] = [ @@ -195,6 +196,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int ]; } elseif (file_exists(__DIR__ . '/../../../../autoload.php')) { // Running as a global dependency. + $output->writeln('Assumed running as global dependency', OutputInterface::VERBOSITY_DEBUG); $phpstanBin = \realpath(__DIR__ . '/../../../../phpstan/phpstan/phpstan.phar'); $configuration_data['parameters']['bootstrapFiles'] = [\realpath(__DIR__ . '/../../error-bootstrap.php')]; // The phpstan/extension-installer doesn't seem to register.