diff --git a/.github/workflows/recipe.yaml b/.github/workflows/recipe.yaml index 9a0b4a3b8..44e3d2351 100644 --- a/.github/workflows/recipe.yaml +++ b/.github/workflows/recipe.yaml @@ -9,25 +9,29 @@ jobs: recipe: - name: Sylius ${{ matrix.sylius }}, PHP ${{ matrix.php }} - runs-on: ubuntu-latest - env: - SYMFONY_ENDPOINT: http://127.0.0.1/ - strategy: fail-fast: false matrix: php: ['8.0', '8.1', '8.2'] - sylius: ['~1.10.0', '~1.11.0', '~1.12.0'] + sylius: ["~1.11.0", "~1.12.0", "~1.13.0"] + exclude: + - php: '8.2' + sylius: '~1.11.0' + - php: '8.0' + sylius: '~1.12.0' + - php: '8.0' + sylius: '~1.13.0' steps: - name: Setup PHP uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} + extensions: gd, intl, json ini-values: date.timezone=UTC + tools: symfony-cli - name: Set project php-version run: | @@ -37,33 +41,24 @@ jobs: 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-settings-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 + - name: Determine composer cache directory + id: composer-cache-directory + working-directory: plugin + run: echo "directory=$(composer config cache-dir)" >> $GITHUB_OUTPUT - - name: Cache dependencies installed with composer - uses: actions/cache@v3 - id: cache-composer - with: - 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: Cache dependencies installed with composer + uses: actions/cache@v3 + id: cache-composer + with: + 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: 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 }} + - name: Composer Github Auth + run: composer config -g github-oauth.github.com ${{ github.token }} - name: Create Sylius-Standard project without install run: | @@ -79,20 +74,14 @@ jobs: working-directory: ./sylius run: | 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/"}' - composer config extra.symfony.allow-contrib true - composer config secure-http false - composer config --unset platform.php - - name: Require plugin without install + - name: Require plugin & install all dependencies working-directory: ./sylius run: | - composer require --no-install --no-scripts monsieurbiz/sylius-settings-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-settings-plugin="*@dev" diff --git a/.github/workflows/security.yaml b/.github/workflows/security.yaml index 0522893de..c100cfa13 100644 --- a/.github/workflows/security.yaml +++ b/.github/workflows/security.yaml @@ -7,15 +7,13 @@ on: jobs: security: - - name: PHP ${{ matrix.php }} runs-on: ubuntu-latest strategy: fail-fast: false matrix: - php: ['8.0', '8.1', '8.2'] + php: ['8.1', '8.2'] steps: - uses: actions/checkout@v3 @@ -24,31 +22,32 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} - ini-values: date.timezone=UTC + extensions: gd, intl, json - name: Set project php-version run: | - echo ${{ matrix.php }} > .php-version + echo "${{ matrix.php }}" > .php-version - - name: Determine composer cache directory - id: composer-cache-directory - run: echo "directory=$(composer config cache-dir)" >> $GITHUB_OUTPUT + - 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: ${{ steps.composer-cache-directory.outputs.directory }} - key: composer2-php:${{ matrix.php }}-${{ hashFiles('**/composer.json') }} - restore-keys: composer2-php:${{ matrix.php }}- + - name: Cache dependencies installed with composer + uses: actions/cache@v3 + id: cache-composer + with: + path: ${{ steps.composer-cache-directory.outputs.directory }} + key: composer2-php:${{ matrix.php }}-${{ github.sha }} + restore-keys: composer2-php:${{ matrix.php }}- - - name: Ensure that composer cache directory exists - run: mkdir -p ${{ steps.composer-cache-directory.outputs.directory }} + - 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 }} + - name: Composer Github Auth + run: composer config -g github-oauth.github.com ${{ github.token }} - name: Install PHP dependencies run: composer update --prefer-dist - uses: symfonycorp/security-checker-action@v4 + diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 42c050297..877ce6a6a 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -8,15 +8,13 @@ on: jobs: php: - - name: PHP ${{ matrix.php }} runs-on: ubuntu-latest strategy: fail-fast: false matrix: - php: ['8.0', '8.1', '8.2'] + php: ['8.1', '8.2'] env: SYMFONY_ARGS: --no-tls @@ -24,49 +22,48 @@ jobs: DOCKER_INTERACTIVE_ARGS: -t steps: - - uses: actions/checkout@v3 - + - uses: actions/checkout@v2 - uses: actions/setup-node@v2 with: node-version: '14' + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: gd, intl, json + ini-values: date.timezone=UTC + tools: symfony-cli + + - name: Set project php-version + run: | + echo "${{ matrix.php }}" > .php-version + + - 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: ${{ steps.composer-cache-directory.outputs.directory }} + key: composer2-php:${{ matrix.php }}-${{ github.sha }} + restore-keys: composer2-php:${{ matrix.php }}- - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - ini-values: date.timezone=UTC - tools: symfony-cli - - - name: Set project php-version - run: | - echo ${{ matrix.php }} > .php-version - - - 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: ${{ steps.composer-cache-directory.outputs.directory }} - key: composer2-php:${{ matrix.php }}-${{ hashFiles('**/composer.json') }} - restore-keys: composer2-php:${{ matrix.php }}- - - - name: Ensure that composer cache directory exists - run: mkdir -p ${{ steps.composer-cache-directory.outputs.directory }} + - 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 }} + - name: Composer Github Auth + run: composer config -g github-oauth.github.com ${{ github.token }} - run: make install - - run: make sylius.fixtures.local - - run: make test.composer - run: make test.phpcs + - run: make test.phpunit + - run: make test.phpstan - run: make test.phpmd diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 29f25c04d..765b7acc7 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -60,7 +60,7 @@ 'combine_consecutive_issets' => true, 'combine_consecutive_unsets' => true, 'comment_to_phpdoc' => true, - 'compact_nullable_typehint' => true, + 'compact_nullable_type_declaration' => true, 'concat_space' => [ 'spacing' => 'one', ], @@ -120,7 +120,7 @@ ], 'native_constant_invocation' => true, 'native_function_casing' => true, - 'new_with_braces' => true, + 'new_with_parentheses' => true, 'no_alias_functions' => true, 'no_alternative_syntax' => true, 'no_blank_lines_after_class_opening' => true, @@ -159,14 +159,14 @@ 'no_short_bool_cast' => true, 'no_spaces_after_function_name' => true, 'no_spaces_around_offset' => true, - 'no_spaces_inside_parenthesis' => true, + 'spaces_inside_parentheses' => true, 'no_superfluous_elseif' => true, 'no_superfluous_phpdoc_tags' => [ 'allow_mixed' => true, ], 'no_unset_cast' => true, 'no_unneeded_control_parentheses' => true, - 'no_unneeded_curly_braces' => true, + 'no_unneeded_braces' => true, 'no_unneeded_final_method' => true, 'no_unset_on_property' => true, 'no_unused_imports' => true, diff --git a/Makefile b/Makefile index eb16aa52a..782df10bc 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,13 @@ .DEFAULT_GOAL := help SHELL=/bin/bash APP_DIR=tests/Application -SYLIUS_VERSION=1.12.0 +SYLIUS_VERSION=1.13.0 SYMFONY=cd ${APP_DIR} && symfony COMPOSER=symfony composer CONSOLE=${SYMFONY} console export COMPOSE_PROJECT_NAME=settings +export MIGRATIONS_NAMESPACE=MonsieurBiz\\SyliusSettingsPlugin\\Migrations +export USER_UID=$(shell id -u) PLUGIN_NAME=sylius-${COMPOSE_PROJECT_NAME}-plugin COMPOSE=docker-compose YARN=yarn @@ -70,18 +72,21 @@ 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 (cd ${APP_DIR} && ${COMPOSER} install --no-interaction) $(MAKE) apply_dist - (cd ${APP_DIR} && ${COMPOSER} require --no-progress monsieurbiz/${PLUGIN_NAME}="*@dev") + (cd ${APP_DIR} && ${COMPOSER} require --no-progress --no-interaction monsieurbiz/${PLUGIN_NAME}="*@dev") rm -rf ${APP_DIR}/var/cache ${APP_DIR}/docker-compose.yaml: rm -f ${APP_DIR}/docker-compose.yml rm -f ${APP_DIR}/docker-compose.yaml + rm -f ${APP_DIR}/compose.yml # Remove Sylius file about Docker + rm -f ${APP_DIR}/compose.override.dist.yml # Remove Sylius file about Docker ln -s ../../docker-compose.yaml.dist ${APP_DIR}/docker-compose.yaml .PHONY: ${APP_DIR}/docker-compose.yaml @@ -106,7 +111,7 @@ apply_dist: ### TESTS ### ¯¯¯¯¯ -test.all: test.composer test.phpstan test.phpmd test.phpspec test.phpcs test.yaml test.schema test.twig test.container ## Run all tests in once +test.all: test.composer test.phpstan test.phpmd test.phpunit test.phpspec test.phpcs test.yaml test.schema test.twig test.container ## Run all tests in once test.composer: ## Validate composer.json ${COMPOSER} validate --strict @@ -117,6 +122,9 @@ test.phpstan: ## Run PHPStan test.phpmd: ## Run PHPMD ${COMPOSER} phpmd +test.phpunit: ## Run PHPUnit + ${COMPOSER} phpunit + test.phpspec: ## Run PHPSpec ${COMPOSER} phpspec @@ -130,7 +138,7 @@ test.container: ## Lint the symfony container ${CONSOLE} lint:container test.yaml: ## Lint the symfony Yaml files - ${CONSOLE} lint:yaml ../../recipes ../../src/Resources/config + ${CONSOLE} lint:yaml ../../src/Resources/config --parse-tags test.schema: ## Validate MySQL Schema ${CONSOLE} doctrine:schema:validate @@ -153,9 +161,6 @@ sylius.database: ## Setup the database sylius.fixtures: ## Run the fixtures ${CONSOLE} sylius:fixtures:load -n default -sylius.fixtures.local: ## Run the local fixtures (for testing purpose) - ${CONSOLE} sylius:fixtures:load -n local - sylius.assets: ## Install all assets with symlinks ${CONSOLE} assets:install --symlink ${CONSOLE} sylius:install:assets @@ -164,6 +169,9 @@ sylius.assets: ## Install all assets with symlinks messenger.setup: ## Setup Messenger transports ${CONSOLE} messenger:setup-transports +doctrine.diff: ## Doctrine diff + ${CONSOLE} doctrine:migration:diff --namespace="${MIGRATIONS_NAMESPACE}" + ### ### PLATFORM ### ¯¯¯¯¯¯¯¯ @@ -201,19 +209,6 @@ server.start: ## Run the local webserver using Symfony server.stop: ## Stop the local webserver ${SYMFONY} local:server:stop - -ifdef CODESPACES -### -### GITHUB CODESPACES -### ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ - -codespace.hostname: ${APP_DIR}/.env.local ## Init the SYLIUS_FIXTURES_HOSTNAME variable in .env.local - echo SYLIUS_FIXTURES_HOSTNAME=${CODESPACE_NAME}-8000.${GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN} >> ${APP_DIR}/.env.local -endif - -${APP_DIR}/.env.local: - touch ${APP_DIR}/.env.local - ### ### HELP ### ¯¯¯¯ diff --git a/README.md b/README.md index d949e0a0a..c83d5ebc4 100644 --- a/README.md +++ b/README.md @@ -3,16 +3,29 @@