From e626d72cff261fd6fb4cccda6d807b6941715bb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joachim=20L=C3=B8vgaard?= Date: Mon, 7 Aug 2023 11:08:56 +0200 Subject: [PATCH] Better, more robust build --- .github/workflows/build.yaml | 58 +++++++++++++++++------ composer-require-checker.json | 36 -------------- composer-unused.php | 12 ----- composer.json | 16 ++++--- psalm.xml | 12 ++--- src/DependencyInjection/Configuration.php | 4 +- tests/Application/config/bundles.php | 1 - 7 files changed, 63 insertions(+), 76 deletions(-) delete mode 100644 composer-require-checker.json delete mode 100644 composer-unused.php diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 88cf17a..cd6b1b3 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -54,6 +54,9 @@ jobs: - name: "Check style" run: "composer check-style" + - name: "Rector" + run: "vendor/bin/rector process --dry-run" + - name: "Lint yaml files" run: "(cd tests/Application && bin/console lint:yaml ../../src/Resources)" @@ -74,8 +77,17 @@ jobs: - "8.2" dependencies: + - "lowest" - "highest" - + + symfony: + - "^5.4" + - "^6.0" + + exclude: + - php-version: "7.4" + symfony: "^6.0" + steps: - name: "Checkout" uses: "actions/checkout@v3" @@ -88,6 +100,9 @@ jobs: php-version: "${{ matrix.php-version }}" tools: "composer-require-checker, composer-unused, flex" + - name: "Remove require-dev section in composer.json" + run: "composer config --unset require-dev" + - name: "Install composer dependencies" uses: "ramsey/composer-install@v2" env: @@ -96,11 +111,11 @@ jobs: dependency-versions: "${{ matrix.dependencies }}" - name: "Run maglnet/composer-require-checker" - run: "composer-require-checker check --config-file=$(pwd)/composer-require-checker.json" + run: "composer-require-checker check" - name: "Run composer-unused/composer-unused" run: "composer-unused" - + static-code-analysis: name: "Static Code Analysis (PHP${{ matrix.php-version }} | Deps: ${{ matrix.dependencies }} | SF${{ matrix.symfony }})" @@ -109,14 +124,21 @@ jobs: strategy: matrix: php-version: - - "7.4" - - "8.0" - "8.1" - "8.2" dependencies: + - "lowest" - "highest" + symfony: + - "^5.4" + - "^6.0" + + exclude: + - php-version: "7.4" + symfony: "^6.0" + steps: - name: "Checkout" uses: "actions/checkout@v3" @@ -128,6 +150,9 @@ jobs: extensions: "${{ env.PHP_EXTENSIONS }}" php-version: "${{ matrix.php-version }}" tools: "flex" + + - name: "Remove sylius/sylius from composer.json" + run: "composer remove --dev sylius/sylius --no-update --no-install" - name: "Install composer dependencies" uses: "ramsey/composer-install@v2" @@ -136,9 +161,6 @@ jobs: with: dependency-versions: "${{ matrix.dependencies }}" - - name: "Cache warmup" - run: "(cd tests/Application && bin/console cache:warmup)" - - name: "Static analysis" run: "vendor/bin/psalm --php-version=${{ matrix.php-version }}" @@ -154,10 +176,18 @@ jobs: - "8.0" - "8.1" - "8.2" - + dependencies: - "highest" + symfony: + - "^5.4" + - "^6.0" + + exclude: + - php-version: "7.4" + symfony: "^6.0" + steps: - name: "Checkout" uses: "actions/checkout@v3" @@ -169,6 +199,9 @@ jobs: extensions: "${{ env.PHP_EXTENSIONS }}" php-version: "${{ matrix.php-version }}" tools: "flex" + + - name: "Remove sylius/sylius from composer.json" + run: "composer remove --dev sylius/sylius --no-update --no-install" - name: "Install composer dependencies" uses: "ramsey/composer-install@v2" @@ -188,14 +221,11 @@ jobs: strategy: matrix: php-version: - - "7.4" - - "8.0" - - "8.1" - - "8.2" + - "7.4" # We only do the integration tests on the lowest PHP requirement because the maintenance burden for doing this for all PHP versions requires a lot of Sylius application changes dependencies: - "highest" - + steps: - name: "Start MySQL" run: "sudo /etc/init.d/mysql start" diff --git a/composer-require-checker.json b/composer-require-checker.json deleted file mode 100644 index 1e1d6be..0000000 --- a/composer-require-checker.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "symbol-whitelist": [ - "array", - "bool", - "callable", - "false", - "float", - "int", - "iterable", - "null", - "object", - "parent", - "self", - "static", - "string", - "true", - "void", - "Sylius\\Bundle\\ChannelBundle\\Form\\Type\\ChannelChoiceType", - "Sylius\\Bundle\\UiBundle\\Menu\\Event\\MenuBuilderEvent", - "Sylius\\Component\\Channel\\Context\\ChannelContextInterface", - "Sylius\\Component\\Channel\\Model\\ChannelInterface", - "Sylius\\Component\\Channel\\Model\\ChannelsAwareInterface", - "Sylius\\Component\\Core\\Calculator\\ProductVariantPricesCalculatorInterface", - "Sylius\\Component\\Core\\Model\\ChannelInterface", - "Sylius\\Component\\Core\\Model\\OrderInterface", - "Sylius\\Component\\Core\\Model\\OrderItemInterface", - "Sylius\\Component\\Core\\Model\\ProductInterface", - "Sylius\\Component\\Core\\Model\\ProductVariantInterface", - "Sylius\\Component\\Locale\\Context\\LocaleContextInterface", - "Sylius\\Component\\Order\\Context\\CartContextInterface", - "Sylius\\Component\\Order\\Repository\\OrderRepositoryInterface", - "Sylius\\Component\\Product\\Resolver\\ProductVariantResolverInterface", - "Sylius\\Component\\Taxonomy\\Model\\TaxonInterface", - "Sylius\\Component\\Taxonomy\\Repository\\TaxonRepositoryInterface" - ] -} diff --git a/composer-unused.php b/composer-unused.php deleted file mode 100644 index d6b268f..0000000 --- a/composer-unused.php +++ /dev/null @@ -1,12 +0,0 @@ -addNamedFilter(NamedFilter::fromString('sylius/grid-bundle')) // We use this for creating the grids in the backend - ; -}; diff --git a/composer.json b/composer.json index 7835077..8b111c2 100644 --- a/composer.json +++ b/composer.json @@ -22,8 +22,16 @@ "setono/composite-compiler-pass": "^1.1", "setono/google-analytics-bundle": "^1.0.0-alpha.5", "setono/google-analytics-measurement-protocol": "^1.0@alpha", + "sylius/channel": "^1.0", + "sylius/channel-bundle": "^1.0", + "sylius/core": "^1.8", "sylius/grid-bundle": "^1.10", + "sylius/locale": "^1.0", + "sylius/order": "^1.0", + "sylius/product": "^1.0", "sylius/resource-bundle": "^1.8", + "sylius/taxonomy": "^1.0", + "sylius/ui-bundle": "^1.0", "symfony/config": "^5.4 || ^6.0", "symfony/dependency-injection": "^5.4 || ^6.0", "symfony/event-dispatcher": "^5.4 || ^6.0", @@ -36,13 +44,13 @@ "api-platform/core": "^2.7.13", "behat/behat": "^3.13", "icanhazstring/composer-unused": "^0.8.10", + "league/flysystem-bundle": "^2.4", "matthiasnoback/symfony-config-test": "^4.3", "matthiasnoback/symfony-dependency-injection-test": "^4.3", "php-http/message-factory": "^1.1", "phpspec/prophecy-phpunit": "^2.0.2", "phpunit/phpunit": "^9.6.10", "psalm/plugin-phpunit": "^0.18", - "psalm/plugin-symfony": "^5.0", "setono/code-quality-pack": "^2.4", "sylius/sylius": "~1.10.14", "symfony/debug-bundle": "^5.4 || ^6.0", @@ -77,12 +85,8 @@ "sort-packages": true }, "scripts": { - "analyse": [ - "@ensure-test-container-exists", - "psalm" - ], + "analyse": "psalm", "check-style": "ecs check", - "ensure-test-container-exists": "[[ -f tests/Application/var/cache/test/Tests_Setono_SyliusAnalyticsPlugin_Application_KernelTestDebugContainer.xml ]] || tests/Application/bin/console cache:warmup --env=test", "fix-style": "ecs check --fix", "phpunit": "phpunit" } diff --git a/psalm.xml b/psalm.xml index ffd75de..9e37cfb 100644 --- a/psalm.xml +++ b/psalm.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://getpsalm.org/schema/config" xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" - findUnusedPsalmSuppress="true" + findUnusedPsalmSuppress="false" findUnusedCode="false" findUnusedBaselineEntry="true" phpVersion="7.4" @@ -15,12 +15,12 @@ - - - tests/Application/var/cache/test/Tests_Setono_SyliusAnalyticsPlugin_Application_KernelTestDebugContainer.xml - - + + + + + diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 40683c0..7fc12a7 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -35,6 +35,8 @@ final class Configuration implements ConfigurationInterface public function getConfigTreeBuilder(): TreeBuilder { $treeBuilder = new TreeBuilder('setono_sylius_analytics'); + + /** @var ArrayNodeDefinition $rootNode */ $rootNode = $treeBuilder->getRootNode(); $this->addEventsSection($rootNode); @@ -54,7 +56,7 @@ private function addEventsSection(ArrayNodeDefinition $node): void private function addResourcesSection(ArrayNodeDefinition $node): void { - /** @psalm-suppress MixedMethodCall,PossiblyNullReference,UndefinedInterfaceMethod */ + /** @psalm-suppress MixedMethodCall,PossiblyNullReference,PossiblyUndefinedMethod,UndefinedInterfaceMethod */ $node ->children() ->arrayNode('resources') diff --git a/tests/Application/config/bundles.php b/tests/Application/config/bundles.php index f3d972c..b2f54b4 100644 --- a/tests/Application/config/bundles.php +++ b/tests/Application/config/bundles.php @@ -7,7 +7,6 @@ Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true], Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true], Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true], - Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle::class => ['all' => true], Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true], Sylius\Bundle\OrderBundle\SyliusOrderBundle::class => ['all' => true], Sylius\Bundle\MoneyBundle\SyliusMoneyBundle::class => ['all' => true],