Skip to content

Commit

Permalink
Merge pull request #16 from JacquesDurand/chore/sylius-112-compatibility
Browse files Browse the repository at this point in the history
chore(deps): sylius 1.12 compatibility
  • Loading branch information
maximehuran authored Jul 3, 2023
2 parents 4a3591b + f6d07ea commit cbba811
Show file tree
Hide file tree
Showing 9 changed files with 111 additions and 101 deletions.
77 changes: 37 additions & 40 deletions .github/workflows/recipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,59 +4,62 @@ 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']
sylius: ["~1.8.0", "~1.9.0", "~1.10.0", "~1.11.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-sales-reports-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: 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 }}

Expand All @@ -73,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"
36 changes: 22 additions & 14 deletions .github/workflows/security.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,52 @@ name: Security
on:
push:
pull_request:
schedule:
- cron: '0 0 * * 1'

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}
- 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
35 changes: 23 additions & 12 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,50 +4,61 @@ on:
push:
branches: [ master ]
pull_request:
schedule:
- cron: '0 0 * * 1'

jobs:

php:

name: Quality tests (PHP ${{ matrix.php }})

runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
php: ['8.0']
php: ['8.0', '8.1']

env:
SYMFONY_ARGS: --no-tls
COMPOSER_ARGS: --prefer-dist
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 }}
Expand Down
2 changes: 1 addition & 1 deletion .php-version.dist
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8.0
8.2
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
### ¯¯¯¯¯¯¯¯
Expand Down
16 changes: 10 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -28,7 +28,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",
Expand All @@ -54,15 +54,19 @@
"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",
"phpspec": "phpspec run"
},
"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"
Expand All @@ -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
}
}
}
32 changes: 9 additions & 23 deletions src/Controller/Admin/ReportsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit cbba811

Please sign in to comment.