From 638a98a780576874508626d94fae8bf37c5a2864 Mon Sep 17 00:00:00 2001 From: Hugo Nicolas Date: Fri, 2 Dec 2022 10:51:48 +0100 Subject: [PATCH 1/3] chore(deps): sylius 1.12 compatibility --- .github/workflows/recipe.yaml | 10 ++++-- .github/workflows/tests.yaml | 2 +- .php-version.dist | 2 +- Makefile | 2 +- composer.json | 4 +-- src/Controller/Admin/ReportsController.php | 32 ++++++------------- ...MonsieurBizSyliusSalesReportsExtension.php | 2 +- src/Resources/config/routing/admin.yaml | 4 +-- 8 files changed, 25 insertions(+), 33 deletions(-) diff --git a/.github/workflows/recipe.yaml b/.github/workflows/recipe.yaml index ad6eebd..00cc808 100644 --- a/.github/workflows/recipe.yaml +++ b/.github/workflows/recipe.yaml @@ -19,15 +19,21 @@ jobs: strategy: fail-fast: false matrix: - php: ['7.4' ,'8.0'] - sylius: ["~1.8.0", "~1.9.0", "~1.10.0", "~1.11.0"] + php: ['7.4' ,'8.0', '8.1'] + sylius: ["~1.8.0", "~1.9.0", "~1.10.0", "~1.11.0", "~1.12.0"] exclude: + - php: 8.1 + sylius: "~1.8.0" + - php: 8.1 + sylius: "~1.9.0" - php: 8.0 sylius: "~1.8.0" - php: 8.0 sylius: "~1.9.0" - php: 7.4 sylius: "~1.11.0" + - php: 7.4 + sylius: "~1.12.0" steps: - name: Setup PHP diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index d66dc77..fe74980 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -16,7 +16,7 @@ jobs: strategy: fail-fast: false matrix: - php: ['8.0'] + php: ['8.0', '8.1'] env: SYMFONY_ARGS: --no-tls diff --git a/.php-version.dist b/.php-version.dist index cc40bca..b8eb026 100644 --- a/.php-version.dist +++ b/.php-version.dist @@ -1 +1 @@ -8.0 +8.1 diff --git a/Makefile b/Makefile index 1e4dc91..1897fa8 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ .DEFAULT_GOAL := help SHELL=/bin/bash APP_DIR=tests/Application -SYLIUS_VERSION=1.11.0 +SYLIUS_VERSION=1.12.0 SYMFONY=cd ${APP_DIR} && symfony COMPOSER=symfony composer CONSOLE=${SYMFONY} console diff --git a/composer.json b/composer.json index 2884f4f..dd4c642 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,7 @@ "license": "MIT", "require": { "php": "~7.4|~8.0", - "sylius/sylius": ">=1.8 <1.12" + "sylius/sylius": ">=1.8 <1.13" }, "require-dev": { "behat/behat": "^3.6.1", @@ -28,7 +28,7 @@ "mikey179/vfsstream": "^1.6", "mockery/mockery": "^1.4", "pamil/prophecy-common": "^0.1", - "phpspec/phpspec": "^6.1", + "phpspec/phpspec": "^7.0", "phpstan/phpstan": "^0.12.57", "phpstan/phpstan-doctrine": "^0.12.19", "phpstan/phpstan-webmozart-assert": "^0.12.7", diff --git a/src/Controller/Admin/ReportsController.php b/src/Controller/Admin/ReportsController.php index 7ece312..29df6f5 100644 --- a/src/Controller/Admin/ReportsController.php +++ b/src/Controller/Admin/ReportsController.php @@ -59,34 +59,20 @@ public function indexAction(Request $request): Response $form = $this->createForm(DateType::class); $formPeriod = $this->createForm(PeriodType::class); - // Form not submitted yet - if (null === $request->request->get($form->getName()) && null === $request->request->get($formPeriod->getName())) { + $form->handleRequest($request); + $formPeriod->handleRequest($request); + + if (!$form->isSubmitted() && !$formPeriod->isSubmitted()) { return $this->render('@MonsieurBizSyliusSalesReportsPlugin/Admin/index.html.twig', [ 'form' => $form->createView(), 'form_period' => $formPeriod->createView(), ]); } - - // Submit request data and return form if form is not valid - if ($request->request->get($form->getName())) { - $form->submit($request->request->get($form->getName())); - if (!$form->isSubmitted() || !$form->isValid()) { - return $this->render('@MonsieurBizSyliusSalesReportsPlugin/Admin/index.html.twig', [ - 'form' => $form->createView(), - 'form_period' => $formPeriod->createView(), - ]); - } - } - - // Submit request data and return form period if form period is not valid - if ($request->request->get($formPeriod->getName())) { - $formPeriod->submit($request->request->get($formPeriod->getName())); - if (!$formPeriod->isSubmitted() || !$formPeriod->isValid()) { - return $this->render('@MonsieurBizSyliusSalesReportsPlugin/Admin/index.html.twig', [ - 'form' => $form->createView(), - 'form_period' => $formPeriod->createView(), - ]); - } + if (($form->isSubmitted() && !$form->isValid()) || ($formPeriod->isSubmitted() && !$formPeriod->isValid())) { + return $this->render('@MonsieurBizSyliusSalesReportsPlugin/Admin/index.html.twig', [ + 'form' => $form->createView(), + 'form_period' => $formPeriod->createView(), + ]); } // Assert retrieved data diff --git a/src/DependencyInjection/MonsieurBizSyliusSalesReportsExtension.php b/src/DependencyInjection/MonsieurBizSyliusSalesReportsExtension.php index ad90086..271a57d 100644 --- a/src/DependencyInjection/MonsieurBizSyliusSalesReportsExtension.php +++ b/src/DependencyInjection/MonsieurBizSyliusSalesReportsExtension.php @@ -37,7 +37,7 @@ public function load(array $configs, ContainerBuilder $container): void $loader->load('services.yaml'); } - public function getAlias() + public function getAlias(): string { return str_replace('monsieur_biz', 'monsieurbiz', parent::getAlias()); } diff --git a/src/Resources/config/routing/admin.yaml b/src/Resources/config/routing/admin.yaml index f317fae..bd51bf4 100644 --- a/src/Resources/config/routing/admin.yaml +++ b/src/Resources/config/routing/admin.yaml @@ -2,11 +2,11 @@ monsieurbiz_sylius_sales_reports_admin_index: path: /sales_reports/ methods: [GET] defaults: - _controller: MonsieurBiz\SyliusSalesReportsPlugin\Controller\Admin\ReportsController:indexAction + _controller: MonsieurBiz\SyliusSalesReportsPlugin\Controller\Admin\ReportsController::indexAction monsieurbiz_sylius_sales_reports_admin_view: path: /sales_reports/ methods: [POST] defaults: - _controller: MonsieurBiz\SyliusSalesReportsPlugin\Controller\Admin\ReportsController:indexAction + _controller: MonsieurBiz\SyliusSalesReportsPlugin\Controller\Admin\ReportsController::indexAction From 010d5d077f091910b6735e333ad131ff5ec41eab Mon Sep 17 00:00:00 2001 From: Hugo Nicolas Date: Tue, 6 Dec 2022 10:36:48 +0100 Subject: [PATCH 2/3] fix(ci): new php setup --- .github/workflows/security.yaml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/security.yaml b/.github/workflows/security.yaml index a124d50..ca32a47 100644 --- a/.github/workflows/security.yaml +++ b/.github/workflows/security.yaml @@ -15,14 +15,18 @@ jobs: strategy: fail-fast: false matrix: - php: ['7.4', '8.0'] + php: ['7.4', '8.0', '8.1'] steps: - uses: actions/checkout@v2 - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + + - name: Setup PHP part two run: | - sudo update-alternatives --set php /usr/bin/php${{ matrix.php }} echo "date.timezone=UTC" | sudo tee /etc/php/${{ matrix.php }}/cli/conf.d/timezone.ini echo "${{ matrix.php }}" > .php-version From f6d07eae24932f655c2939eff4ab6088494d433b Mon Sep 17 00:00:00 2001 From: Maxime Huran Date: Mon, 3 Jul 2023 15:19:58 +0200 Subject: [PATCH 3/3] Update infra for Sylius 1.12 --- .github/workflows/recipe.yaml | 73 +++++++++++++++------------------ .github/workflows/security.yaml | 32 ++++++++------- .github/workflows/tests.yaml | 33 ++++++++++----- .php-version.dist | 2 +- Makefile | 6 ++- composer.json | 14 ++++--- 6 files changed, 87 insertions(+), 73 deletions(-) diff --git a/.github/workflows/recipe.yaml b/.github/workflows/recipe.yaml index 00cc808..6db3fa6 100644 --- a/.github/workflows/recipe.yaml +++ b/.github/workflows/recipe.yaml @@ -4,30 +4,23 @@ on: push: branches: [ master ] pull_request: - schedule: - - cron: '0 0 * * 1' jobs: recipe: - runs-on: ubuntu-latest + name: Flex recipe (PHP ${{ matrix.php }}, Sylius ${{ matrix.sylius }}) - env: - SYMFONY_ENDPOINT: http://127.0.0.1/ + runs-on: ubuntu-latest strategy: fail-fast: false matrix: php: ['7.4' ,'8.0', '8.1'] - sylius: ["~1.8.0", "~1.9.0", "~1.10.0", "~1.11.0", "~1.12.0"] + sylius: [ "~1.9.0", "~1.10.0", "~1.11.0", "~1.12.0"] exclude: - - php: 8.1 - sylius: "~1.8.0" - php: 8.1 sylius: "~1.9.0" - - php: 8.0 - sylius: "~1.8.0" - php: 8.0 sylius: "~1.9.0" - php: 7.4 @@ -37,32 +30,36 @@ jobs: steps: - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: gd, intl, json + ini-values: date.timezone=UTC + + - name: Set project php-version run: | - sudo update-alternatives --set php /usr/bin/php${{ matrix.php }} - echo "date.timezone=UTC" >> /tmp/timezone.ini - sudo mv /tmp/timezone.ini /etc/php/${{ matrix.php }}/cli/conf.d/timezone.ini echo ${{ matrix.php }} > .php-version - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: path: plugin - # Run the server at the start so it can download the recipes! - - name: Run standalone symfony flex server - run: | - echo ${{ github.token }} | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin - docker run --rm --name flex -d -v $PWD/plugin/recipes:/var/www/flex/var/repo/private/monsieurbiz/sylius-sales-reports-plugin -p 80:80 docker.pkg.github.com/monsieurbiz/docker/symfony-flex-server:latest contrib official - docker ps - - - run: mkdir -p /home/runner/{.composer/cache,.config/composer} + - name: Determine composer cache directory + id: composer-cache-directory + working-directory: plugin + run: echo "directory=$(composer config cache-dir)" >> $GITHUB_OUTPUT - - uses: actions/cache@v1 + - name: Cache dependencies installed with composer + uses: actions/cache@v3 id: cache-composer with: - path: /home/runner/.composer/cache - key: composer2-php:${{ matrix.php }}-sylius:${{ matrix.sylius }}-${{ github.sha }} + path: ${{ steps.composer-cache-directory.outputs.directory }} + key: composer2-php:${{ matrix.php }}-sylius:${{ matrix.sylius }}-${{ hashFiles('**/composer.json') }} restore-keys: composer2-php:${{ matrix.php }}-sylius:${{ matrix.sylius }}- + - name: Ensure that composer cache directory exists + run: mkdir -p ${{ steps.composer-cache-directory.outputs.directory }} + - name: Composer Github Auth run: composer config -g github-oauth.github.com ${{ github.token }} @@ -79,21 +76,15 @@ jobs: - name: Setup some requirements working-directory: ./sylius run: | - composer config --no-plugins allow-plugins true - composer config repositories.plugin '{"type": "path", "url": "../plugin/"}' - composer config extra.symfony.allow-contrib true - composer config secure-http false - composer config --unset platform.php - - - name: Require plugin without install + composer config --no-plugins allow-plugins true + composer config --no-plugins extra.symfony.allow-contrib true + composer config --no-plugins secure-http false + composer config --no-plugins --unset platform.php + composer config --no-plugins extra.symfony.docker false + composer config --no-plugins --json extra.symfony.endpoint '["https://api.github.com/repos/monsieurbiz/symfony-recipes/contents/index.json?ref=flex/master","flex://defaults"]' + composer config repositories.plugin '{"type": "path", "url": "../plugin/"}' + + - name: Require plugin & install all dependencies working-directory: ./sylius run: | - composer require --no-install --no-update monsieurbiz/sylius-sales-reports-plugin="*@dev" - - - name: Composer install - working-directory: ./sylius - run: | - composer install - - - name: Show flex server logs - run: docker logs --tail 100 flex + composer require monsieurbiz/sylius-sales-reports-plugin="*@dev" diff --git a/.github/workflows/security.yaml b/.github/workflows/security.yaml index ca32a47..4e12805 100644 --- a/.github/workflows/security.yaml +++ b/.github/workflows/security.yaml @@ -3,13 +3,13 @@ name: Security on: push: pull_request: - schedule: - - cron: '0 0 * * 1' jobs: security: + name: Security check (PHP ${{ matrix.php }}) + runs-on: ubuntu-latest strategy: @@ -18,33 +18,37 @@ jobs: php: ['7.4', '8.0', '8.1'] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Setup PHP uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} - - - name: Setup PHP part two + ini-values: date.timezone=UTC + + - name: Set project php-version run: | - echo "date.timezone=UTC" | sudo tee /etc/php/${{ matrix.php }}/cli/conf.d/timezone.ini - echo "${{ matrix.php }}" > .php-version + echo ${{ matrix.php }} > .php-version - - uses: actions/cache@v1 + - name: Determine composer cache directory + id: composer-cache-directory + run: echo "directory=$(composer config cache-dir)" >> $GITHUB_OUTPUT + + - name: Cache dependencies installed with composer + uses: actions/cache@v3 id: cache-composer with: - path: /home/runner/.composer/cache - key: composer2-php:${{ matrix.php }}-${{ github.sha }} + path: ${{ steps.composer-cache-directory.outputs.directory }} + key: composer2-php:${{ matrix.php }}-${{ hashFiles('**/composer.json') }} restore-keys: composer2-php:${{ matrix.php }}- - - run: mkdir -p /home/runner/{.composer/cache,.config/composer} + - name: Ensure that composer cache directory exists + run: mkdir -p ${{ steps.composer-cache-directory.outputs.directory }} - name: Composer Github Auth run: composer config -g github-oauth.github.com ${{ github.token }} - - uses: actions/checkout@v2 - - name: Install PHP dependencies run: composer update --prefer-dist - - uses: symfonycorp/security-checker-action@v3 + - uses: symfonycorp/security-checker-action@v4 diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index fe74980..4bf7505 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -4,13 +4,13 @@ on: push: branches: [ master ] pull_request: - schedule: - - cron: '0 0 * * 1' jobs: php: + name: Quality tests (PHP ${{ matrix.php }}) + runs-on: ubuntu-latest strategy: @@ -24,30 +24,41 @@ jobs: DOCKER_INTERACTIVE_ARGS: -t steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 + - uses: actions/checkout@v3 + + - uses: actions/setup-node@v3 with: node-version: '14' - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + ini-values: date.timezone=UTC + + - name: Set project php-version run: | - sudo update-alternatives --set php /usr/bin/php${{ matrix.php }} - echo "date.timezone=UTC" | sudo tee /etc/php/${{ matrix.php }}/cli/conf.d/timezone.ini - echo "${{ matrix.php }}" > .php-version + echo ${{ matrix.php }} > .php-version - name: Install symfony CLI run: | curl -1sLf 'https://dl.cloudsmith.io/public/symfony/stable/setup.deb.sh' | sudo -E bash sudo apt install symfony-cli - - uses: actions/cache@v1 + - name: Determine composer cache directory + id: composer-cache-directory + run: echo "directory=$(composer config cache-dir)" >> $GITHUB_OUTPUT + + - name: Cache dependencies installed with composer + uses: actions/cache@v3 id: cache-composer with: - path: /home/runner/.composer/cache - key: composer2-php:${{ matrix.php }}-${{ github.sha }} + path: ${{ steps.composer-cache-directory.outputs.directory }} + key: composer2-php:${{ matrix.php }}-${{ hashFiles('**/composer.json') }} restore-keys: composer2-php:${{ matrix.php }}- - - run: mkdir -p /home/runner/{.composer/cache,.config/composer} + - name: Ensure that composer cache directory exists + run: mkdir -p ${{ steps.composer-cache-directory.outputs.directory }} - name: Composer Github Auth run: composer config -g github-oauth.github.com ${{ github.token }} diff --git a/.php-version.dist b/.php-version.dist index b8eb026..2983cad 100644 --- a/.php-version.dist +++ b/.php-version.dist @@ -1 +1 @@ -8.1 +8.2 diff --git a/Makefile b/Makefile index 1897fa8..4004253 100644 --- a/Makefile +++ b/Makefile @@ -70,6 +70,7 @@ setup_application: (cd ${APP_DIR} && ${COMPOSER} config extra.symfony.allow-contrib true) (cd ${APP_DIR} && ${COMPOSER} config minimum-stability dev) (cd ${APP_DIR} && ${COMPOSER} config --no-plugins allow-plugins true) + (cd ${APP_DIR} && ${COMPOSER} config --no-plugins --json extra.symfony.endpoint '["https://api.github.com/repos/monsieurbiz/symfony-recipes/contents/index.json?ref=flex/master","flex://defaults"]') (cd ${APP_DIR} && ${COMPOSER} require --no-install --no-scripts --no-progress sylius/sylius="~${SYLIUS_VERSION}") # Make sure to install the required version of sylius because the sylius-standard has a soft constraint $(MAKE) ${APP_DIR}/.php-version $(MAKE) ${APP_DIR}/php.ini @@ -145,7 +146,7 @@ test.twig: ## Validate Twig templates ### SYLIUS ### ¯¯¯¯¯¯ -sylius: dependencies sylius.database sylius.fixtures sylius.assets ## Install Sylius +sylius: dependencies sylius.database sylius.fixtures sylius.assets messenger.setup ## Install Sylius .PHONY: sylius sylius.database: ## Setup the database @@ -161,6 +162,9 @@ sylius.assets: ## Install all assets with symlinks ${CONSOLE} sylius:install:assets ${CONSOLE} sylius:theme:assets:install --symlink +messenger.setup: ## Setup Messenger transports + ${CONSOLE} messenger:setup-transports + ### ### PLATFORM ### ¯¯¯¯¯¯¯¯ diff --git a/composer.json b/composer.json index dd4c642..8e5cca6 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ "mikey179/vfsstream": "^1.6", "mockery/mockery": "^1.4", "pamil/prophecy-common": "^0.1", - "phpspec/phpspec": "^7.0", + "phpspec/phpspec": "^6.1 || ^7.2", "phpstan/phpstan": "^0.12.57", "phpstan/phpstan-doctrine": "^0.12.19", "phpstan/phpstan-webmozart-assert": "^0.12.7", @@ -54,7 +54,7 @@ "cache:clear": "symfony-cmd", "assets:install %PUBLIC_DIR%": "symfony-cmd" }, - "phpcs": "php-cs-fixer fix --using-cache=false", + "phpcs": "PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer fix --using-cache=no", "phpstan": "phpstan analyse -c phpstan.neon src/", "phpmd": "phpmd --exclude Migrations/* src/ ansi phpmd.xml", "phpunit": "phpunit", @@ -62,7 +62,11 @@ }, "extra": { "symfony": { - "require": "^4.4" + "docker": false, + "endpoint": [ + "https://api.github.com/repos/monsieurbiz/symfony-recipes/contents/index.json?ref=flex/master", + "flex://defaults" + ] }, "branch-alias": { "dev-master": "1.0-dev" @@ -72,9 +76,9 @@ "allow-plugins": { "dealerdirect/phpcodesniffer-composer-installer": true, "symfony/thanks": true, - "phpstan/extension-installer": true, "ergebnis/composer-normalize": true, - "symfony/flex": true + "symfony/flex": true, + "php-http/discovery": true } } }