Skip to content

Commit cbc0eee

Browse files
Feature/GitHub action and ECS fix (#359)
* add github action build * ECS fix
1 parent 4c3400a commit cbc0eee

36 files changed

Lines changed: 325 additions & 212 deletions

.github/workflows/build.yml

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
name: Build
2+
3+
on:
4+
push: ~
5+
release:
6+
types: [created]
7+
schedule:
8+
-
9+
cron: "0 1 * * 6" # Run at 1am every Saturday
10+
11+
jobs:
12+
tests:
13+
runs-on: ubuntu-latest
14+
15+
name: "PHP ${{ matrix.php }}, MySQL ${{ matrix.mysql }}"
16+
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
php: [7.4, 7.3]
21+
node: [10.x]
22+
mysql: [5.7, 8.0]
23+
24+
exclude:
25+
- # PHP 7.3 does not support "caching_sha2_password" authentication plugin which is a default one in MySQL 8.0
26+
php: 7.3
27+
mysql: 8.0
28+
29+
env:
30+
APP_ENV: test
31+
DATABASE_URL: "mysql://root:root@127.0.0.1/sylius?serverVersion=${{ matrix.mysql }}"
32+
33+
steps:
34+
-
35+
uses: actions/checkout@v2
36+
37+
-
38+
name: Setup PHP
39+
uses: shivammathur/setup-php@v2
40+
with:
41+
php-version: "${{ matrix.php }}"
42+
ini-values: date.timezone=Europe/Warsaw, opcache.enable=1, opcache.enable_cli=1, opcache.memory_consumption=256, opcache.max_accelerated_files=32531, opcache.interned_strings_buffer=8, opcache.validate_timestamps=0, opcache.save_comments=1, opcache.fast_shutdown=0
43+
extensions: intl, gd, opcache, mysql, pdo_mysql, :xdebug
44+
tools: symfony
45+
coverage: none
46+
47+
-
48+
name: Setup Node
49+
uses: actions/setup-node@v1
50+
with:
51+
node-version: "${{ matrix.node }}"
52+
53+
-
54+
name: Shutdown default MySQL
55+
run: sudo service mysql stop
56+
57+
-
58+
name: Setup MySQL
59+
uses: mirromutth/mysql-action@v1.1
60+
with:
61+
mysql version: "${{ matrix.mysql }}"
62+
mysql root password: "root"
63+
64+
-
65+
name: Output PHP version for Symfony CLI
66+
run: php -v | head -n 1 | awk '{ print $2 }' > .php-version
67+
68+
-
69+
name: Install certificates
70+
run: symfony server:ca:install
71+
72+
-
73+
name: Run Chrome Headless
74+
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 --disable-web-security --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 &
75+
76+
-
77+
name: Run webserver
78+
run: (cd tests/Application && symfony server:start --port=8080 --dir=public --daemon)
79+
80+
-
81+
name: Get Composer cache directory
82+
id: composer-cache
83+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
84+
85+
-
86+
name: Cache Composer
87+
uses: actions/cache@v2
88+
with:
89+
path: ${{ steps.composer-cache.outputs.dir }}
90+
key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json **/composer.lock') }}
91+
restore-keys: |
92+
${{ runner.os }}-php-${{ matrix.php }}-composer-
93+
-
94+
name: Install PHP dependencies
95+
run: composer install --no-interaction
96+
97+
-
98+
name: Get Yarn cache directory
99+
id: yarn-cache
100+
run: echo "::set-output name=dir::$(yarn cache dir)"
101+
102+
-
103+
name: Cache Yarn
104+
uses: actions/cache@v2
105+
with:
106+
path: ${{ steps.yarn-cache.outputs.dir }}
107+
key: ${{ runner.os }}-node-${{ matrix.node }}-yarn-${{ hashFiles('**/package.json **/yarn.lock') }}
108+
restore-keys: |
109+
${{ runner.os }}-node-${{ matrix.node }}-yarn-
110+
-
111+
name: Install JS dependencies
112+
run: (cd tests/Application && yarn install)
113+
114+
-
115+
name: Prepare test application database
116+
run: |
117+
(cd tests/Application && bin/console doctrine:database:create -vvv)
118+
(cd tests/Application && bin/console doctrine:schema:create -vvv)
119+
120+
-
121+
name: Prepare test application assets
122+
run: |
123+
(cd tests/Application && bin/console assets:install public -vvv)
124+
(cd tests/Application && yarn build)
125+
-
126+
name: Prepare test application cache
127+
run: (cd tests/Application && bin/console cache:warmup -vvv)
128+
129+
-
130+
name: Load fixtures in test application
131+
run: (cd tests/Application && bin/console sylius:fixtures:load -n)
132+
133+
-
134+
name: Validate composer.json
135+
run: composer validate --ansi --strict
136+
137+
-
138+
name: Validate database schema
139+
run: (cd tests/Application && bin/console doctrine:schema:validate)
140+
141+
-
142+
name: Run PHPSpec
143+
run: vendor/bin/phpspec run --ansi -f progress --no-interaction
144+
145+
-
146+
name: Run PHPUnit
147+
run: vendor/bin/phpunit --colors=always
148+
149+
-
150+
name: Run Behat
151+
run: vendor/bin/behat --colors --strict -vvv --no-interaction || vendor/bin/behat --colors --strict -vvv --no-interaction --rerun
152+
153+
-
154+
name: Upload Behat logs
155+
uses: actions/upload-artifact@v2
156+
if: failure()
157+
with:
158+
name: Behat logs
159+
path: etc/build/
160+
if-no-files-found: ignore

.travis.yml

Lines changed: 0 additions & 91 deletions
This file was deleted.

behat.yml.dist

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,49 +4,34 @@ imports:
44

55
default:
66
extensions:
7+
DMore\ChromeExtension\Behat\ServiceContainer\ChromeExtension: ~
78

8-
FriendsOfBehat\SymfonyExtension:
9-
bootstrap: tests/Application/config/bootstrap.php
10-
kernel:
11-
debug: true
12-
class: Tests\BitBag\SyliusCmsPlugin\Application\Kernel
13-
path: tests/Application/Kernel.php
14-
environment: test
15-
16-
Lakion\Behat\MinkDebugExtension:
9+
FriendsOfBehat\MinkDebugExtension:
1710
directory: etc/build
1811
clean_start: false
1912
screenshot: true
2013

2114
Behat\MinkExtension:
2215
files_path: "%paths.base%/vendor/sylius/sylius/src/Sylius/Behat/Resources/fixtures/"
23-
base_url: "http://localhost:8080/"
16+
base_url: "https://127.0.0.1:8080/"
2417
default_session: symfony
25-
javascript_session: chrome
18+
javascript_session: chrome_headless
2619
sessions:
2720
symfony:
2821
symfony: ~
29-
chrome:
30-
selenium2:
31-
browser: chrome
32-
capabilities:
33-
browserName: chrome
34-
browser: chrome
35-
version: ""
36-
marionette: null # https://github.com/Behat/MinkExtension/pull/311
37-
chrome:
38-
switches:
39-
- "start-fullscreen"
40-
- "start-maximized"
41-
- "no-sandbox"
22+
chrome_headless:
23+
chrome:
24+
api_url: http://127.0.0.1:9222
25+
validate_certificate: false
26+
show_auto: false
27+
28+
FriendsOfBehat\SymfonyExtension:
29+
bootstrap: tests/Application/config/bootstrap.php
30+
kernel:
31+
class: Tests\BitBag\SyliusCmsPlugin\Application\Kernel
4232

4333
FriendsOfBehat\VariadicExtension: ~
4434

4535
FriendsOfBehat\SuiteSettingsExtension:
4636
paths:
4737
- "features"
48-
formatters:
49-
pretty:
50-
verbose: true
51-
paths: false
52-
snippets: false

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
"php": "^7.3",
1313
"league/csv": "^9.1",
1414
"friendsofsymfony/ckeditor-bundle": "^1.1|^2.0",
15-
"sylius/sylius": "^1.9"
15+
"sylius/sylius": "^1.9",
16+
"instaclick/php-webdriver": "^1.4",
17+
"dmore/behat-chrome-extension": "^1.3",
18+
"dmore/chrome-mink-driver": "^2.7"
1619
},
1720
"require-dev": {
1821
"behat/behat": "^3.7",

ecs.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use PhpCsFixer\Fixer\ArrayNotation\ArraySyntaxFixer;
6+
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
7+
use Symplify\EasyCodingStandard\ValueObject\Option;
8+
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;
9+
10+
return static function (ContainerConfigurator $containerConfigurator): void {
11+
$containerConfigurator->import('vendor/sylius-labs/coding-standard/ecs.php');
12+
$services = $containerConfigurator->services();
13+
$services->set(ArraySyntaxFixer::class)
14+
->call('configure', [[
15+
'syntax' => 'short',
16+
]]);
17+
18+
$parameters = $containerConfigurator->parameters();
19+
$parameters->set(Option::PATHS, [
20+
__DIR__ . '/src',
21+
__DIR__ . '/tests',
22+
]);
23+
24+
$parameters->set(Option::SETS, [
25+
// run and fix, one by one
26+
// SetList::SPACES,
27+
// SetList::ARRAY,
28+
// SetList::DOCBLOCK,
29+
// SetList::NAMESPACES,
30+
// SetList::CONTROL_STRUCTURES,
31+
// SetList::CLEAN_CODE,
32+
// SetList::PSR_12,
33+
// SetList::PHP_70,
34+
// SetList::PHP_71,
35+
]);
36+
};

src/Controller/Action/Admin/ImportDataAction.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ final class ImportDataAction
4242
/** @var TranslatorInterface */
4343
private $translator;
4444

45-
/**
46-
* @var Environment
47-
*/
45+
/** @var Environment */
4846
private $twig;
4947

5048
public function __construct(
@@ -55,7 +53,6 @@ public function __construct(
5553
TranslatorInterface $translator,
5654
Environment $twig
5755
) {
58-
5956
$this->importProcessor = $importProcessor;
6057
$this->formFactory = $formFactory;
6158
$this->flashBag = $flashBag;
@@ -72,7 +69,6 @@ public function __invoke(Request $request): Response
7269
$form->handleRequest($request);
7370

7471
if ($request->isMethod('POST') && $form->isSubmitted()) {
75-
7672
if ($form->isValid()) {
7773
/** @var UploadedFile $file */
7874
$file = $form->get('file')->getData();

0 commit comments

Comments
 (0)