From d68c4679c99f7025f1f207a619c321abb28f5aa5 Mon Sep 17 00:00:00 2001 From: Jacob Dreesen Date: Fri, 9 Aug 2024 11:44:24 +0200 Subject: [PATCH] Check for composer dependency issues --- .github/workflows/qa.yaml | 9 ++++++--- composer-dependency-analyser.php | 16 ++++++++++++++++ composer.json | 15 +++++++++++---- 3 files changed, 33 insertions(+), 7 deletions(-) create mode 100644 composer-dependency-analyser.php diff --git a/.github/workflows/qa.yaml b/.github/workflows/qa.yaml index 53665d9..40f14b3 100644 --- a/.github/workflows/qa.yaml +++ b/.github/workflows/qa.yaml @@ -29,10 +29,13 @@ jobs: - name: Install dependencies uses: ramsey/composer-install@v2 - - name: Run ergebnis/composer-normalize - run: composer normalize --ansi --dry-run + - name: Normalize composer.json + run: composer normalize --ansi --dry-run --no-check-lock --no-update-lock - - name: Check CS-Fixer + - name: Check dependency issues + run: composer dependencies:check + + - name: Check CS run: composer cs:check - name: Check PHPStan diff --git a/composer-dependency-analyser.php b/composer-dependency-analyser.php new file mode 100644 index 0000000..f93b241 --- /dev/null +++ b/composer-dependency-analyser.php @@ -0,0 +1,16 @@ +addPathToExclude(__DIR__ . '/tests/app') + + // Ignore optional dependency + ->ignoreErrorsOnPackageAndPath('dama/doctrine-test-bundle', __DIR__ . '/src/Database/ResetDatabase.php', [ErrorType::DEV_DEPENDENCY_IN_PROD]) + ->ignoreErrorsOnPackageAndPath('dama/doctrine-test-bundle', __DIR__ . '/src/Database/DatabaseResetter.php', [ErrorType::DEV_DEPENDENCY_IN_PROD]) + + // Ignore a legacy class from Pimcore 10 + ->ignoreUnknownClasses([Pimcore\Bundle\AdminBundle\PimcoreAdminBundle::class]) +; diff --git a/composer.json b/composer.json index f119eda..2b1c006 100644 --- a/composer.json +++ b/composer.json @@ -24,9 +24,13 @@ "phpunit/phpunit": "^9.6.0", "pimcore/pimcore": "^10.5 || ~11.0.0 || ~11.1.0 || ~11.2.2", "psr/log": "^1.0 || ^2.0 || ^3.0", - "symfony/console": "^5.4 || ^6.2", - "symfony/filesystem": "^5.4 || ^6.2", - "symfony/framework-bundle": "^5.4 || ^6.2" + "symfony/config": "^5.4 || ^6.4", + "symfony/console": "^5.4 || ^6.4", + "symfony/dependency-injection": "^5.4 || ^6.4", + "symfony/event-dispatcher": "^5.4 || ^6.4", + "symfony/filesystem": "^5.4 || ^6.4", + "symfony/framework-bundle": "^5.4 || ^6.4", + "symfony/http-kernel": "^5.4 || ^6.4" }, "require-dev": { "dama/doctrine-test-bundle": "^6.0 || ^7.0", @@ -38,7 +42,8 @@ "phpstan/extension-installer": "^1.3.1", "phpstan/phpstan": "^1.10.60", "phpstan/phpstan-phpunit": "^1.3.16", - "phpstan/phpstan-symfony": "^1.3.8" + "phpstan/phpstan-symfony": "^1.3.8", + "shipmonk/composer-dependency-analyser": "^1.7" }, "suggest": { "dama/doctrine-test-bundle": "To isolate database tests in transactions and improve test performance", @@ -67,6 +72,7 @@ "cs:check": "@cs:fix --dry-run", "cs:check:gitlab-ci": "php-cs-fixer fix --dry-run --ansi --verbose --diff --format=gitlab > .reports/php-cs-fixer.json", "cs:fix": "php-cs-fixer fix --ansi --verbose --diff", + "dependencies:check": "composer-dependency-analyser", "phpstan": "phpstan analyse --ansi", "phpstan:gitlab-ci": "phpstan analyse --ansi --no-interaction --no-progress --error-format=gitlab > .reports/phpstan.json", "tests": "phpunit", @@ -76,6 +82,7 @@ "cs:check": "Checks code style (but doesn't fix anything)", "cs:check:gitlab-ci": "Checks code style and redirects the output into a GitLab readable file", "cs:fix": "Checks and fixes code style", + "dependencies:check": "Checks for composer dependency issues", "phpstan": "Checks for code smells", "phpstan:gitlab-ci": "Checks for code smells and redirects the output into a GitLab readable file", "tests": "Run all phpunit tests",