From 0584c428d3f187e624dfd7ade9bdedbbe29b1f34 Mon Sep 17 00:00:00 2001 From: Michel Date: Mon, 26 May 2025 14:22:04 +0200 Subject: [PATCH 1/2] feat: add bc-checker --- .bc-exclude.php | 13 ++++ .github/workflows/php.yml | 25 +++++- composer.json | 8 +- phpstan.neon.dist | 1 - .../Rector/ClassCheckoutPackageRector.php | 76 ------------------- 5 files changed, 41 insertions(+), 82 deletions(-) create mode 100644 .bc-exclude.php delete mode 100644 src/DevOps/Rector/ClassCheckoutPackageRector.php diff --git a/.bc-exclude.php b/.bc-exclude.php new file mode 100644 index 000000000..5e15ac79a --- /dev/null +++ b/.bc-exclude.php @@ -0,0 +1,13 @@ + [ + '**/src/DevOps/**', + ], + 'errors' => [ + // vendor false positive + \preg_quote('An enum expression Monolog\Level::Debug is not supported in class Monolog\Handler\AbstractHandler'), + // Storefront package is not installed + \preg_quote('"Shopware\Storefront\Framework\Cookie\CookieProviderInterface" could not be found in the located source'), + ], +]; diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 00c5c1f7b..2b843e21e 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -14,6 +14,7 @@ on: - ecs.php - phpstan.neon.dist - phpstan-baseline.neon + - .bc-exclude.php workflow_dispatch: workflow_call: @@ -93,5 +94,25 @@ jobs: composer init:admin composer openapi:generate git update-index --refresh || printf '' - git diff "${{ github.sha }}" --exit-code -- src/Resources/app/administration/src/types/openapi.d.ts || (echo "Please run 'composer openapi:generate' to update openapi.d.ts" && exit 1) - git diff "${{ github.sha }}" --exit-code -- src/Resources/Schema || (echo "Please run 'composer openapi:generate' to update Resources/Schema files" && exit 1) + git diff --exit-code src/Resources/app/administration/src/types/openapi.d.ts || (echo "Please run 'composer openapi:generate' to update openapi.d.ts" && exit 1) + git diff --exit-code src/Resources/Schema || (echo "Please run 'composer openapi:generate' to update Resources/Schema files" && exit 1) + + bc-check: + runs-on: ubuntu-latest + steps: + - name: Checkout SwagPayPal + uses: actions/checkout@v4 + with: + path: custom/plugins/${{ github.event.repository.name }} + + - name: Setup SwagPayPal + uses: ./custom/plugins/SwagPayPal/.github/actions/setup-paypal + + - name: Fetch SwagPayPal + working-directory: custom/plugins/${{ github.event.repository.name }} + run: git fetch --unshallow origin + + - name: Run bc-check + working-directory: custom/plugins/${{ github.event.repository.name }} + if: github.event_name == 'pull_request' && !contains(github.base_ref, '/feature/') + run: composer bc-check -- --format=github-actions --from="origin/${{ github.base_ref }}" diff --git a/composer.json b/composer.json index 68f32f50c..b113ab114 100644 --- a/composer.json +++ b/composer.json @@ -12,9 +12,6 @@ "require": { "shopware/core": "~6.5.5@dev" }, - "require-dev": { - "rector/rector": "^0.18.3" - }, "extra": { "shopware-plugin-class": "Swag\\PayPal\\SwagPayPal", "copyright": "(c) by shopware AG", @@ -69,6 +66,11 @@ "openapi:generate": [ "../../../bin/console swag:paypal:openapi:generate", "npm run openapi-types --prefix src/Resources/app/administration" + ], + "bc-check": [ + "php ../../../vendor-bin/roave-backward-compatibility-check/bin/verify-version.php", + "@putenv TMPDIR=./..", + "../../../vendor/bin/roave-backward-compatibility-check" ] }, "autoload": { diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 352f3cd5f..2b72284c9 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -17,7 +17,6 @@ parameters: - tests excludePaths: - src/Resources - - src/DevOps/Rector symfony: constant_hassers: false diff --git a/src/DevOps/Rector/ClassCheckoutPackageRector.php b/src/DevOps/Rector/ClassCheckoutPackageRector.php deleted file mode 100644 index 2daa0ba4b..000000000 --- a/src/DevOps/Rector/ClassCheckoutPackageRector.php +++ /dev/null @@ -1,76 +0,0 @@ - - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Swag\PayPal\DevOps\Rector; - -use PhpParser\Node; -use PhpParser\Node\AttributeGroup; -use PhpParser\Node\Stmt\ClassLike; -use Rector\Core\Rector\AbstractRector; -use Rector\PhpAttribute\NodeFactory\PhpAttributeGroupFactory; -use Shopware\Core\Framework\Log\Package; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; - -#[Package('checkout')] -class ClassCheckoutPackageRector extends AbstractRector -{ - private const AREA_CHECKOUT = 'checkout'; - - public function __construct(private readonly PhpAttributeGroupFactory $phpAttributeGroupFactory) - { - } - - public function getNodeTypes(): array - { - return [ClassLike::class]; - } - - public function refactor(Node $node): ?Node - { - if (!$node instanceof ClassLike) { - return null; - } - - if ($this->hasPackageAnnotation($node)) { - return null; - } - - $node->attrGroups[] = $this->phpAttributeGroupFactory->createFromClassWithItems(Package::class, [self::AREA_CHECKOUT]); - - return $node; - } - - public function getRuleDefinition(): RuleDefinition - { - return new RuleDefinition( - 'Adds a #[Package(\'checkout\')] attribute to all php classes.', - [ - new CodeSample( - // code before - ' -class Foo{}', - - // code after - ' -#[Package(\'checkout\')] -class Foo{}' - ), - ] - ); - } - - private function hasPackageAnnotation(ClassLike $class): bool - { - $names = \array_map( - fn (AttributeGroup $group) => $group->attrs[0]->name->toString(), - $class->attrGroups - ); - - return \in_array(Package::class, $names, true) || \in_array('Package', $names, true); - } -} From 36842847ea4b4a00c49011fd8933c3bace8c9f3a Mon Sep 17 00:00:00 2001 From: Michel Bade Date: Mon, 15 Dec 2025 08:44:21 +0100 Subject: [PATCH 2/2] test: node setup --- .github/actions/setup-paypal/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/setup-paypal/action.yml b/.github/actions/setup-paypal/action.yml index 11386fed9..8dd8aec64 100644 --- a/.github/actions/setup-paypal/action.yml +++ b/.github/actions/setup-paypal/action.yml @@ -117,7 +117,7 @@ runs: fi echo "deps=$(echo $DEPS | jq -c .)" >> "$GITHUB_OUTPUT" echo "repos=$(echo $REPOS | jq -c .)" >> "$GITHUB_OUTPUT" - - uses: shopware/github-actions/setup-extension@main + - uses: shopware/github-actions/setup-extension@b1d0a9fddcf38cd550f328ea00e1beb7536fa494 with: extensionName: ${{ github.event.repository.name }} mysqlVersion: ${{ inputs.mysql-version }}