Skip to content

Commit

Permalink
Support Sylius 1.13 + 1.14 & Symfony 5.4 + 6.4 (#53)
Browse files Browse the repository at this point in the history
* Allow Symfony 6

* Allow Symfony 4.4/5.4/6.0 and Sylius 1.11/1.12

* Remove tests/Application from build as there is no one

* Fix the build

* Allow Sylius 1.13 & 1.14 and Symfony 5.4 & 6.4

* CS fixes
  • Loading branch information
Zales0123 authored Dec 17, 2024
1 parent 410f783 commit ec7d20b
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 141 deletions.
66 changes: 13 additions & 53 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,25 @@ env:

jobs:
tests:
runs-on: ubuntu-18.04
runs-on: ubuntu-latest

name: "PHP ${{ matrix.php }}, MySQL ${{ matrix.mysql }}"
name: "PHP ${{ matrix.php }}, MySQL ${{ matrix.mysql }}, Sylius ${{ matrix.sylius }}"

strategy:
fail-fast: false
matrix:
php: [7.4, 7.3]
php: [8.1, 8.2, 8.3]
node: [10.x]
mysql: [5.7, 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.13.*, 1.14.*]

env:
APP_ENV: test
DATABASE_URL: "mysql://root:root@127.0.0.1/sylius?serverVersion=${{ matrix.mysql }}"

steps:
-
uses: actions/checkout@v2
uses: actions/checkout@v4

-
name: Setup PHP
Expand All @@ -52,7 +48,7 @@ jobs:

-
name: Setup Node
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: "${{ matrix.node }}"

Expand All @@ -79,24 +75,24 @@ jobs:
name: Run Chrome Headless
run: google-chrome-stable --enable-automation --disable-background-networking --no-default-browser-check --no-first-run --disable-popup-blocking --disable-default-apps --allow-insecure-localhost --disable-translate --disable-extensions --no-sandbox --enable-features=Metal --headless --remote-debugging-port=9222 --window-size=2880,1800 --proxy-server='direct://' --proxy-bypass-list='*' http://127.0.0.1 > /dev/null 2>&1 &

-
name: Run webserver
run: (cd tests/Application && symfony server:start --port=8080 --dir=public --daemon)

-
name: Get Composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

-
name: Cache Composer
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json **/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-${{ matrix.php }}-composer-
-
name: Require Sylius version
run: composer require sylius/sylius:"${{ matrix.sylius }}" --no-update

-
name: Install PHP dependencies
run: composer install --no-interaction
Expand All @@ -108,57 +104,21 @@ jobs:

-
name: Cache Yarn
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ${{ steps.yarn-cache.outputs.dir }}
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)

-
name: Prepare test application database
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

-
name: Validate database schema
run: (cd tests/Application && bin/console doctrine:schema:validate)

-
name: Run php-cs-fixer
name: Run php-cs-fixer
run: vendor/bin/php-cs-fixer fix --verbose --diff --dry-run

-
name: Run PHPStan
run: vendor/bin/phpstan analyse -c phpstan.neon -l max src/

-
name: Run PHPSpec
run: vendor/bin/phpspec run --ansi -f progress --no-interaction

-
name: Run PHPUnit
run: vendor/bin/phpunit --colors=always
6 changes: 3 additions & 3 deletions .github/workflows/test-application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
fail-fast: false
matrix:
include:
- php-version: '7.4'
- php-version: '8.2'
dependency-versions: 'highest'
php-extensions: 'ctype, iconv, mysql, imagick'
tools: 'composer:v2'
Expand All @@ -38,7 +38,7 @@ jobs:

steps:
- name: Checkout project
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Install and configure PHP
uses: shivammathur/setup-php@v2
Expand All @@ -49,7 +49,7 @@ jobs:
coverage: none

- name: Install composer dependencies
uses: ramsey/composer-install@v1
uses: ramsey/composer-install@v3
with:
dependency-versions: ${{matrix.dependency-versions}}

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@
.idea

.php_cs.cache
.php-cs-fixer.cache
33 changes: 17 additions & 16 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,30 @@
"description": "Producer for synchronization products with sulu.",
"license": "MIT",
"require": {
"php": "^7.3|^8.0",
"php": "^8.1",

"sylius/sylius": "^1.8",
"symfony/messenger": "^4.4|^5.0",
"symfony/config": "^4.4|^5.0",
"symfony/dependency-injection": "^4.4|^5.0",
"symfony/http-kernel": "^4.4|^5.0",
"symfony/serializer": "^4.4|^5.0"
"sylius/sylius": "1.13.* || 1.14.*",
"symfony/messenger": "^5.4 || ^6.4",
"symfony/config": "^5.4 || ^6.4",
"symfony/dependency-injection": "^5.4 || ^6.4",
"symfony/http-kernel": "^5.4 || ^6.4",
"symfony/serializer": "^5.4 || ^6.4"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.15",
"friendsofphp/php-cs-fixer": "^2.15 || ^3.0",
"phpstan/phpstan": "^1.0",
"phpstan/phpstan-doctrine": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
"phpstan/phpstan-symfony": "^1.0",
"phpstan/phpstan-webmozart-assert": "^1.0",
"jangregor/phpstan-prophecy": "^1.0",
"thecodingmachine/phpstan-strict-rules": "^1.0",
"phpunit/phpunit": "^8.2",
"symfony/browser-kit": "^4.4 || ^5.0",
"symfony/dotenv": "^4.4 || ^5.0",
"phpunit/phpunit": "^9.5",
"symfony/browser-kit": "^5.4 || ^6.4",
"symfony/dotenv": "^5.4 || ^6.4",
"phpstan/extension-installer": "^1.0",
"sensiolabs/security-checker": "^6.0",
"symfony/intl": "^4.4 || ^5.0",
"symfony/web-profiler-bundle": "^4.4 || ^5.0",
"symfony/web-server-bundle": "^4.4 || ^5.0"
"symfony/intl": "^5.4 || ^6.4",
"symfony/web-profiler-bundle": "^5.4 || ^6.4"
},
"autoload": {
"psr-4": {
Expand All @@ -40,7 +38,10 @@
}
},
"config": {
"sort-packages": true
"sort-packages": true,
"allow-plugins": {
"phpstan/extension-installer": false
}
},
"scripts": {
"post-install-cmd": [
Expand Down
6 changes: 5 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ parameters:
parallel:
processTimeout: 300.0
reportUnmatchedIgnoredErrors: false
checkMissingIterableValueType: false

excludePaths:
- %currentWorkingDirectory%/DependencyInjection/Configuration.php
Expand All @@ -14,3 +13,8 @@ parameters:

ignoreErrors:
- '/Parameter #1 \$configuration of method Symfony\\Component\\DependencyInjection\\Extension\\Extension::processConfiguration\(\) expects Symfony\\Component\\Config\\Definition\\ConfigurationInterface, Symfony\\Component\\Config\\Definition\\ConfigurationInterface\|null given\./'
- '/Call to an undefined method Sylius\\Component\\User\\Model\\UserInterface\:\:isAccountNonExpired\(\)\./'
- '/Call to an undefined method Sylius\\Component\\User\\Model\\UserInterface\:\:isAccountNonLocked\(\)\./'
- '/Call to an undefined method Sylius\\Component\\User\\Model\\UserInterface\:\:isCredentialsNonExpired\(\)\./'
-
identifier: missingType.iterableValue
2 changes: 1 addition & 1 deletion src/Command/BaseSynchronizeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

abstract class BaseSynchronizeCommand extends Command
{
const BULK_SIZE = 50;
public const BULK_SIZE = 50;

/**
* @var EntityManagerInterface
Expand Down
26 changes: 4 additions & 22 deletions src/Command/SynchronizeProductVariantsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,13 @@

class SynchronizeProductVariantsCommand extends BaseSynchronizeCommand
{
/**
* @var EntityManagerInterface
*/
private $entityManager;

/**
* @var ProductVariantMessageProducerInterface
*/
private $productVariantMessageProducer;

/**
* @var ProductVariantRepositoryInterface
*/
private $productVariantRepository;

/** @param ProductVariantRepositoryInterface<ProductVariantInterface> $productVariantRepository */
public function __construct(
EntityManagerInterface $entityManager,
ProductVariantMessageProducerInterface $productVariantMessageProducer,
ProductVariantRepositoryInterface $productVariantRepository
private EntityManagerInterface $entityManager,
private ProductVariantMessageProducerInterface $productVariantMessageProducer,
private ProductVariantRepositoryInterface $productVariantRepository,
) {
parent::__construct($entityManager);

$this->entityManager = $entityManager;
$this->productVariantMessageProducer = $productVariantMessageProducer;
$this->productVariantRepository = $productVariantRepository;
}

protected function configure(): void
Expand Down
26 changes: 4 additions & 22 deletions src/Command/SynchronizeProductsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,13 @@

class SynchronizeProductsCommand extends BaseSynchronizeCommand
{
/**
* @var EntityManagerInterface
*/
private $entityManager;

/**
* @var ProductMessageProducerInterface
*/
private $productMessageProducer;

/**
* @var ProductRepositoryInterface
*/
private $productRepository;

/** @param ProductRepositoryInterface<ProductInterface> $productRepository */
public function __construct(
EntityManagerInterface $entityManager,
ProductMessageProducerInterface $productMessageProducer,
ProductRepositoryInterface $productRepository
private EntityManagerInterface $entityManager,
private ProductMessageProducerInterface $productMessageProducer,
private ProductRepositoryInterface $productRepository,
) {
parent::__construct($entityManager);

$this->entityManager = $entityManager;
$this->productMessageProducer = $productMessageProducer;
$this->productRepository = $productRepository;
}

protected function configure(): void
Expand Down
26 changes: 4 additions & 22 deletions src/Command/SynchronizeTaxonCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,13 @@

class SynchronizeTaxonCommand extends BaseSynchronizeCommand
{
/**
* @var EntityManagerInterface
*/
private $entityManager;

/**
* @var TaxonMessageProducerInterface
*/
private $taxonMessageProducer;

/**
* @var TaxonRepositoryInterface
*/
private $taxonRepository;

/** @param TaxonRepositoryInterface<TaxonInterface> $taxonRepository */
public function __construct(
EntityManagerInterface $entityManager,
TaxonMessageProducerInterface $taxonMessageProducer,
TaxonRepositoryInterface $taxonRepository
private EntityManagerInterface $entityManager,
private TaxonMessageProducerInterface $taxonMessageProducer,
private TaxonRepositoryInterface $taxonRepository,
) {
parent::__construct($entityManager);

$this->entityManager = $entityManager;
$this->taxonMessageProducer = $taxonMessageProducer;
$this->taxonRepository = $taxonRepository;
}

protected function configure(): void
Expand Down
2 changes: 1 addition & 1 deletion src/Producer/ProductMessageProducer.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ProductMessageProducer implements ProductMessageProducerInterface

public function __construct(
ProductSerializerInterface $productSerializer,
MessageBusInterface $messageBus
MessageBusInterface $messageBus,
) {
$this->productSerializer = $productSerializer;
$this->messageBus = $messageBus;
Expand Down

0 comments on commit ec7d20b

Please sign in to comment.