From 73c505c2f5cb680bb65c4c2d2694eb1e2463a13a Mon Sep 17 00:00:00 2001 From: christopherhero Date: Thu, 8 Jul 2021 18:58:22 +0200 Subject: [PATCH] fos/oauth move to dev --- .github/workflows/build.yml | 59 ++++++++++++++----- composer.json | 11 ++-- ecs.php | 14 +++++ tests/Application/.env | 2 +- tests/Application/config/bundles.php | 1 - .../Application/config/sylius/1.8/bundles.php | 2 + .../config/sylius/1.8/packages/_sylius.yaml | 37 ------------ .../config/sylius/1.9/packages/_sylius.yaml | 37 ------------ .../config/sylius/1.9/packages/security.yaml | 13 +++- 9 files changed, 77 insertions(+), 99 deletions(-) create mode 100644 ecs.php diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 84facec..bb71d22 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,31 +1,38 @@ name: Build on: - push: ~ + push: + branches-ignore: + - 'dependabot/**' pull_request: ~ release: types: [created] schedule: - cron: "0 1 * * 6" # Run at 1am every Saturday + workflow_dispatch: ~ jobs: tests: - runs-on: ubuntu-latest + runs-on: ubuntu-18.04 - name: "PHP ${{ matrix.php }}, MySQL ${{ matrix.mysql }}" + name: "Sylius ${{ matrix.sylius }}, PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}, MySQL ${{ matrix.mysql }}" strategy: fail-fast: false matrix: - php: [7.3, 7.4] - node: [10.x] - mysql: [5.7, 8.0] + php: ["8.0", "7.4"] + symfony: ["^4.4", "^5.2"] + sylius: ["~1.9.0", "~1.10.0"] + node: ["10.x"] + mysql: ["8.0"] exclude: - - # PHP 7.3 does not support "caching_sha2_password" authentication plugin which is a default one in MySQL 8.0 - php: 7.3 - mysql: 8.0 + - sylius: ~1.9.0 + php: 8.0 + + - sylius: ~1.10.0 + symfony: 4.4 env: APP_ENV: test @@ -61,6 +68,14 @@ jobs: mysql version: "${{ matrix.mysql }}" mysql root password: "root" + - + name: Configure sysctl limits + run: | + sudo swapoff -a + sudo sysctl -w vm.swappiness=1 + sudo sysctl -w fs.file-max=262144 + sudo sysctl -w vm.max_map_count=262144 + - name: Output PHP version for Symfony CLI run: php -v | head -n 1 | awk '{ print $2 }' > .php-version @@ -90,9 +105,22 @@ jobs: key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json **/composer.lock') }} restore-keys: | ${{ runner.os }}-php-${{ matrix.php }}-composer- + + - + name: Restrict Symfony version + if: matrix.symfony != '' + run: | + composer global require --no-progress --no-scripts --no-plugins "symfony/flex:^1.10" + composer config extra.symfony.require "${{ matrix.symfony }}" + + - + name: Restrict Sylius version + if: matrix.sylius != '' + run: composer require "sylius/sylius:${{ matrix.sylius }}" --no-update --no-scripts --no-interaction + - name: Install PHP dependencies - run: composer install --no-interaction + run: composer install --no-interaction --no-scripts - name: Get Yarn cache directory @@ -107,6 +135,7 @@ jobs: key: ${{ runner.os }}-node-${{ matrix.node }}-yarn-${{ hashFiles('**/package.json **/yarn.lock') }} restore-keys: | ${{ runner.os }}-node-${{ matrix.node }}-yarn- + - name: Install JS dependencies run: (cd tests/Application && yarn install) @@ -116,15 +145,21 @@ jobs: run: | (cd tests/Application && bin/console doctrine:database:create -vvv) (cd tests/Application && bin/console doctrine:schema:create -vvv) + - name: Prepare test application assets run: | (cd tests/Application && bin/console assets:install public -vvv) (cd tests/Application && yarn build) + - name: Prepare test application cache run: (cd tests/Application && bin/console cache:warmup -vvv) + - + name: Load fixtures in test application + run: (cd tests/Application && bin/console sylius:fixtures:load -n) + - name: Validate composer.json run: composer validate --ansi --strict @@ -137,10 +172,6 @@ jobs: name: Run PHPSpec run: vendor/bin/phpspec run --ansi -f progress --no-interaction - - - name: Run PHPUnit - run: vendor/bin/phpunit --colors=always - - name: Run Behat run: vendor/bin/behat --colors --strict -vvv --no-interaction || vendor/bin/behat --colors --strict -vvv --no-interaction --rerun diff --git a/composer.json b/composer.json index e94cfed..1870347 100644 --- a/composer.json +++ b/composer.json @@ -5,9 +5,8 @@ "description": "Blacklist plugin for Sylius.", "license": "MIT", "require": { - "php": "^7.3 || ^8.0", - "sylius/sylius": "~1.8.0 || ~1.9.0 || ~1.10.0", - "friendsofsymfony/oauth-server-bundle": "^1.6 || >2.0.0-alpha.0 ^2.0@dev" + "php": "^7.3 || ^7.4 || ^8.0", + "sylius/sylius": "~1.8.0 || ~1.9.0 || ~1.10.0" }, "require-dev": { "behat/behat": "^3.7", @@ -24,7 +23,7 @@ "friends-of-behat/symfony-extension": "^2.1", "friends-of-behat/variadic-extension": "^1.3", "lchrusciel/api-test-case": "^4.1||^5.0", - "lakion/mink-debug-extension": "^2.0.0", + "friendsofsymfony/oauth-server-bundle": "^1.6 || >2.0.0-alpha.0 ^2.0@dev", "phpspec/phpspec": "^7.0", "phpstan/extension-installer": "^1.0", "phpstan/phpstan": "0.12.82", @@ -33,13 +32,13 @@ "phpstan/phpstan-webmozart-assert": "0.12.12", "phpunit/phpunit": "^9.5", "sensiolabs/security-checker": "^6.0", - "sylius-labs/coding-standard": "^3.1", + "sylius-labs/coding-standard": "^4.0", "symfony/browser-kit": "^4.4 || ^5.2", "symfony/debug-bundle": "^4.4 || ^5.2", "symfony/dotenv": "^4.4 || ^5.2", "symfony/intl": "^4.4 || ^5.2", "symfony/web-profiler-bundle": "^4.4 || ^5.2", - "vimeo/psalm": "4.6.4" + "vimeo/psalm": "4.7.1" }, "autoload": { "psr-4": { diff --git a/ecs.php b/ecs.php new file mode 100644 index 0000000..bf40cc9 --- /dev/null +++ b/ecs.php @@ -0,0 +1,14 @@ +import('vendor/sylius-labs/coding-standard/ecs.php'); + + $containerConfigurator->parameters()->set(Option::SKIP, [ + VisibilityRequiredFixer::class => ['*Spec.php'], + ]); +}; diff --git a/tests/Application/.env b/tests/Application/.env index 5581c2d..5c3b305 100644 --- a/tests/Application/.env +++ b/tests/Application/.env @@ -12,7 +12,7 @@ APP_SECRET=EDITME # Format described at http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url # For a sqlite database, use: "sqlite:///%kernel.project_dir%/var/data.db" # Set "serverVersion" to your server version to avoid edge-case exceptions and extra database calls -DATABASE_URL=mysql://root:password@127.0.0.1/sylius_test?serverVersion=8.0 +DATABASE_URL=mysql://root@127.0.0.1/bitbag_sylius_blacklist_plugin_%kernel.environment% ###< doctrine/doctrine-bundle ### ###> lexik/jwt-authentication-bundle ### diff --git a/tests/Application/config/bundles.php b/tests/Application/config/bundles.php index 523943d..dbd0514 100644 --- a/tests/Application/config/bundles.php +++ b/tests/Application/config/bundles.php @@ -54,7 +54,6 @@ Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle::class => ['all' => true], Sylius\Bundle\ApiBundle\SyliusApiBundle::class => ['all' => true], SyliusLabs\DoctrineMigrationsExtraBundle\SyliusLabsDoctrineMigrationsExtraBundle::class => ['all' => true], - Symplify\ConsoleColorDiff\ConsoleColorDiffBundle::class => ['dev' => true, 'test' => true], Nelmio\Alice\Bridge\Symfony\NelmioAliceBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true], Fidry\AliceDataFixtures\Bridge\Symfony\FidryAliceDataFixturesBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true], ]; diff --git a/tests/Application/config/sylius/1.8/bundles.php b/tests/Application/config/sylius/1.8/bundles.php index 74ee2bc..c3c8ea4 100644 --- a/tests/Application/config/sylius/1.8/bundles.php +++ b/tests/Application/config/sylius/1.8/bundles.php @@ -3,4 +3,6 @@ return [ Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle::class => ['all' => true], WhiteOctober\PagerfantaBundle\WhiteOctoberPagerfantaBundle::class => ['all' => true], + FOS\OAuthServerBundle\FOSOAuthServerBundle::class => ['all' => true], + Sylius\Bundle\AdminApiBundle\SyliusAdminApiBundle::class => ['all' => true], ]; diff --git a/tests/Application/config/sylius/1.8/packages/_sylius.yaml b/tests/Application/config/sylius/1.8/packages/_sylius.yaml index 0960a55..1674a97 100644 --- a/tests/Application/config/sylius/1.8/packages/_sylius.yaml +++ b/tests/Application/config/sylius/1.8/packages/_sylius.yaml @@ -1,39 +1,2 @@ imports: - - { resource: "@SyliusCoreBundle/Resources/config/app/config.yml" } - - - { resource: "@SyliusAdminBundle/Resources/config/app/config.yml" } - { resource: "@SyliusAdminApiBundle/Resources/config/app/config.yml" } - - - { resource: "@SyliusShopBundle/Resources/config/app/config.yml" } - - - { resource: "@SyliusApiBundle/Resources/config/app/config.yaml" } - - - { resource: "@BitBagSyliusBlacklistPlugin/Resources/config/config.yaml" } - - - { resource: "../../../../src/Resources/config/config.yaml" } - -parameters: - sylius_core.public_dir: '%kernel.project_dir%/public' - -sylius_shop: - product_grid: - include_all_descendants: true - -sylius_grid: - grids: - sylius_admin_customer: - fields: - fraudStatus: - type: twig - label: bitbag_sylius_blacklist_plugin.ui.fraud_status - options: - template: "@BitBagSyliusBlacklistPlugin/Customer/Grid/Field/fraudStatus.html.twig" - filters: - fraudStatus: - type: select - label: bitbag_sylius_blacklist_plugin.ui.fraud_status - form_options: - choices: - bitbag_sylius_blacklist_plugin.ui.neutral: Neutral - bitbag_sylius_blacklist_plugin.ui.blacklisted: Blacklisted - bitbag_sylius_blacklist_plugin.ui.whitelisted: Whitelisted diff --git a/tests/Application/config/sylius/1.9/packages/_sylius.yaml b/tests/Application/config/sylius/1.9/packages/_sylius.yaml index 0960a55..1674a97 100644 --- a/tests/Application/config/sylius/1.9/packages/_sylius.yaml +++ b/tests/Application/config/sylius/1.9/packages/_sylius.yaml @@ -1,39 +1,2 @@ imports: - - { resource: "@SyliusCoreBundle/Resources/config/app/config.yml" } - - - { resource: "@SyliusAdminBundle/Resources/config/app/config.yml" } - { resource: "@SyliusAdminApiBundle/Resources/config/app/config.yml" } - - - { resource: "@SyliusShopBundle/Resources/config/app/config.yml" } - - - { resource: "@SyliusApiBundle/Resources/config/app/config.yaml" } - - - { resource: "@BitBagSyliusBlacklistPlugin/Resources/config/config.yaml" } - - - { resource: "../../../../src/Resources/config/config.yaml" } - -parameters: - sylius_core.public_dir: '%kernel.project_dir%/public' - -sylius_shop: - product_grid: - include_all_descendants: true - -sylius_grid: - grids: - sylius_admin_customer: - fields: - fraudStatus: - type: twig - label: bitbag_sylius_blacklist_plugin.ui.fraud_status - options: - template: "@BitBagSyliusBlacklistPlugin/Customer/Grid/Field/fraudStatus.html.twig" - filters: - fraudStatus: - type: select - label: bitbag_sylius_blacklist_plugin.ui.fraud_status - form_options: - choices: - bitbag_sylius_blacklist_plugin.ui.neutral: Neutral - bitbag_sylius_blacklist_plugin.ui.blacklisted: Blacklisted - bitbag_sylius_blacklist_plugin.ui.whitelisted: Whitelisted diff --git a/tests/Application/config/sylius/1.9/packages/security.yaml b/tests/Application/config/sylius/1.9/packages/security.yaml index 12e842b..8161bda 100644 --- a/tests/Application/config/sylius/1.9/packages/security.yaml +++ b/tests/Application/config/sylius/1.9/packages/security.yaml @@ -1,9 +1,13 @@ parameters: - sylius.security.admin_regex: "^/admin" + sylius.security.admin_regex: "^/%sylius_admin.path_name%" sylius.security.api_regex: "^/api" - sylius.security.shop_regex: "^/(?!admin|new-api|api/.*|api$|media/.*)[^/]++" + sylius.security.shop_regex: "^/(?!%sylius_admin.path_name%|new-api|api/.*|api$|media/.*)[^/]++" sylius.security.new_api_route: "/new-api" sylius.security.new_api_regex: "^%sylius.security.new_api_route%" + sylius.security.new_api_admin_route: "%sylius.security.new_api_route%/admin" + sylius.security.new_api_admin_regex: "^%sylius.security.new_api_admin_route%" + sylius.security.new_api_shop_route: "%sylius.security.new_api_route%/shop" + sylius.security.new_api_shop_regex: "^%sylius.security.new_api_shop_route%" security: always_authenticate_before_granting: true @@ -41,7 +45,7 @@ security: csrf_token_id: admin_authenticate remember_me: secret: "%env(APP_SECRET)%" - path: /admin + path: "/%sylius_admin.path_name%" name: APP_ADMIN_REMEMBER_ME lifetime: 31536000 remember_me_parameter: _remember_me @@ -150,3 +154,6 @@ security: - { path: "%sylius.security.admin_regex%", role: ROLE_ADMINISTRATION_ACCESS } - { path: "%sylius.security.api_regex%/.*", role: ROLE_API_ACCESS } - { path: "%sylius.security.shop_regex%/account", role: ROLE_USER } + + - { path: "%sylius.security.new_api_admin_regex%/.*", role: ROLE_API_ACCESS } + - { path: "%sylius.security.new_api_shop_regex%/.*", role: IS_AUTHENTICATED_ANONYMOUSLY }