From 1753f82651f6a63501409c2824fef3d87f59788b Mon Sep 17 00:00:00 2001 From: Maxime Huran Date: Thu, 29 Jun 2023 17:32:00 +0200 Subject: [PATCH 1/3] Update to Sylius 1.12 --- .github/workflows/recipe.yaml | 77 ++++++++++++++++----------------- .github/workflows/security.yaml | 38 +++++++++------- .github/workflows/tests.yaml | 41 +++++++++++------- .php-version.dist | 2 +- Makefile | 9 +++- composer.json | 21 +++++++-- 6 files changed, 110 insertions(+), 78 deletions(-) diff --git a/.github/workflows/recipe.yaml b/.github/workflows/recipe.yaml index 604442a..db44b1e 100644 --- a/.github/workflows/recipe.yaml +++ b/.github/workflows/recipe.yaml @@ -9,52 +9,56 @@ 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'] - sylius: ["~1.8.0", "~1.9.0", "~1.10.0"] + php: ['7.4' ,'8.0', '8.1'] + sylius: [ "~1.9.0", "~1.10.0", "~1.11.0", "~1.12.0"] exclude: - - php: 8.0 - sylius: "~1.8.0" + - php: 8.1 + sylius: "~1.9.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 + 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-alert-message-plugin -p 80:80 docker.pkg.github.com/monsieurbiz/docker/symfony-flex-server:latest contrib official - docker ps + - name: Determine composer cache directory + id: composer-cache-directory + working-directory: plugin + run: echo "directory=$(composer config cache-dir)" >> $GITHUB_OUTPUT - - run: mkdir -p /home/runner/{.composer/cache,.config/composer} - - - 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: Composer v2 - run: sudo composer self-update --2 + - 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 }} @@ -72,20 +76,15 @@ jobs: - name: Setup some requirements working-directory: ./sylius run: | - 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 - working-directory: ./sylius - run: | - composer require --no-install --no-update monsieurbiz/sylius-alert-message-plugin="*@dev" - - - name: Composer 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 install - - - name: Show flex server logs - run: docker logs --tail 100 flex + composer require monsieurbiz/sylius-alert-message-plugin="*@dev" diff --git a/.github/workflows/security.yaml b/.github/workflows/security.yaml index 1cf94aa..4e12805 100644 --- a/.github/workflows/security.yaml +++ b/.github/workflows/security.yaml @@ -8,41 +8,47 @@ jobs: security: + name: Security check (PHP ${{ matrix.php }}) + runs-on: ubuntu-latest strategy: fail-fast: false matrix: - php: ['7.4', '8.0'] + 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 }} + 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 - - 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} - if: steps.cache-composer.outputs.cache-hit != 'true' - - - name: Composer v2 - run: sudo composer self-update --2 + - 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@v2 + - uses: symfonycorp/security-checker-action@v4 diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 46a6a2e..4bf7505 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -9,12 +9,14 @@ jobs: php: + name: Quality tests (PHP ${{ matrix.php }}) + runs-on: ubuntu-latest strategy: fail-fast: false matrix: - php: ['7.4', '8.0'] + php: ['8.0', '8.1'] env: SYMFONY_ARGS: --no-tls @@ -22,34 +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 https://get.symfony.com/cli/installer | bash - echo "${HOME}/.symfony/bin" >> $GITHUB_PATH + curl -1sLf 'https://dl.cloudsmith.io/public/symfony/stable/setup.deb.sh' | sudo -E bash + sudo apt install symfony-cli + + - name: Determine composer cache directory + id: composer-cache-directory + 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 }}-${{ 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} - if: steps.cache-composer.outputs.cache-hit != 'true' - - - name: Composer v2 - run: sudo composer self-update --2 + - 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 cc40bca..2983cad 100644 --- a/.php-version.dist +++ b/.php-version.dist @@ -1 +1 @@ -8.0 +8.2 diff --git a/Makefile b/Makefile index 6bdca1f..0c58f03 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ .DEFAULT_GOAL := help SHELL=/bin/bash APP_DIR=tests/Application -SYLIUS_VERSION=1.10.0 +SYLIUS_VERSION=1.12.0 SYMFONY=cd ${APP_DIR} && symfony COMPOSER=symfony composer CONSOLE=${SYMFONY} console @@ -69,6 +69,8 @@ setup_application: (cd ${APP_DIR} && ${COMPOSER} config repositories.plugin '{"type": "path", "url": "../../"}') (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 @@ -144,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 @@ -160,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 a9462a6..82b2114 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,7 @@ "license": "MIT", "require": { "php": "~7.4|~8.0", - "sylius/sylius": ">=1.8 <1.11", + "sylius/sylius": ">=1.9 <1.13", "gedmo/doctrine-extensions": "^2.4.12 || ^3.0" }, "require-dev": { @@ -29,7 +29,7 @@ "mikey179/vfsstream": "^1.6", "mockery/mockery": "^1.4", "pamil/prophecy-common": "^0.1", - "phpspec/phpspec": "^6.1", + "phpspec/phpspec": "^6.1 || ^7.2", "phpstan/phpstan": "^0.12.57", "phpstan/phpstan-doctrine": "^0.12.19", "phpstan/phpstan-webmozart-assert": "^0.12.7", @@ -55,7 +55,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", @@ -63,10 +63,23 @@ }, "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" } + }, + "config": { + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true, + "symfony/thanks": true, + "ergebnis/composer-normalize": true, + "symfony/flex": true, + "php-http/discovery": true + } } } From 531ada7034051047e2aa522da510bffcdf98356c Mon Sep 17 00:00:00 2001 From: Maxime Huran Date: Thu, 29 Jun 2023 17:32:14 +0200 Subject: [PATCH 2/3] Update module for Sylius 1.12 compatibility --- .../MonsieurBizSyliusAlertMessageExtension.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DependencyInjection/MonsieurBizSyliusAlertMessageExtension.php b/src/DependencyInjection/MonsieurBizSyliusAlertMessageExtension.php index 8ea2af9..ba9ad77 100644 --- a/src/DependencyInjection/MonsieurBizSyliusAlertMessageExtension.php +++ b/src/DependencyInjection/MonsieurBizSyliusAlertMessageExtension.php @@ -31,7 +31,7 @@ public function load(array $config, ContainerBuilder $container): void $loader->load('services.yaml'); } - public function getAlias() + public function getAlias(): string { return str_replace('monsieur_biz', 'monsieurbiz', parent::getAlias()); } From 20bc66a19387232cd215f61d4cf1f1d638d0b317 Mon Sep 17 00:00:00 2001 From: Maxime Huran Date: Thu, 29 Jun 2023 17:48:47 +0200 Subject: [PATCH 3/3] Use channel interface for mapping and methods --- src/Entity/Message.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Entity/Message.php b/src/Entity/Message.php index 1849b1d..fcc0c4c 100644 --- a/src/Entity/Message.php +++ b/src/Entity/Message.php @@ -19,7 +19,7 @@ use Doctrine\ORM\Mapping as ORM; use Gedmo\Mapping\Annotation as Gedmo; use Gedmo\Timestampable\Timestampable; -use Sylius\Component\Channel\Model\Channel; +use Sylius\Component\Core\Model\ChannelInterface; use Sylius\Component\Resource\Model\ResourceInterface; use Sylius\Component\Resource\Model\TimestampableInterface; use Sylius\Component\Resource\Model\TimestampableTrait; @@ -78,8 +78,8 @@ class Message implements ResourceInterface, TimestampableInterface, ToggleableIn protected $description; /** - * @var Collection - * @ORM\ManyToMany(targetEntity="\Sylius\Component\Channel\Model\Channel") + * @var Collection + * @ORM\ManyToMany(targetEntity="\Sylius\Component\Core\Model\ChannelInterface") * @ORM\JoinTable( * name="mbiz_alert_message_channels", * joinColumns={@ORM\JoinColumn(name="message_id", referencedColumnName="id")}, @@ -175,19 +175,19 @@ public function setTemplateHtml(?string $templateHtml): void } /** - * @return Collection + * @return Collection */ public function getChannels(): Collection { return $this->channels; } - public function addChannel(Channel $channel): void + public function addChannel(ChannelInterface $channel): void { $this->channels->add($channel); } - public function removeChannel(Channel $channel): void + public function removeChannel(ChannelInterface $channel): void { $this->channels->removeElement($channel); }