Skip to content

Commit 45b4c0e

Browse files
authored
Use BuildTestAppAction and migrate from Panther to Chrome session (#491)
## Summary - Replace Panther with Chrome session for Behat (simpler, no port conflicts) - Use new `SyliusLabs/BuildTestAppAction@v4` for CI workflow - Change `BEHAT_BASE_URL` from nginx to standard `http://127.0.0.1:8080/` - Make `base_url` configurable via env var - Test all LTS databases: MySQL 8.0/8.4, MariaDB 10.11/11.4, PostgreSQL 15/16/17 Related: SyliusLabs/BuildTestAppAction#19
2 parents c34bc0b + 2f240e4 commit 45b4c0e

File tree

4 files changed

+62
-146
lines changed

4 files changed

+62
-146
lines changed

.github/workflows/build.yaml

Lines changed: 60 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -4,141 +4,97 @@ on:
44
push:
55
branches-ignore:
66
- 'dependabot/**'
7-
pull_request: ~
7+
paths-ignore:
8+
- "*.md"
9+
pull_request:
10+
paths-ignore:
11+
- "*.md"
812
release:
913
types: [created]
1014
schedule:
1115
-
1216
cron: "0 1 * * 6" # Run at 1am every Saturday
1317
workflow_dispatch: ~
1418

19+
concurrency:
20+
group: ${{ github.workflow }}-${{ github.ref }}
21+
cancel-in-progress: true
22+
1523
jobs:
1624
tests:
1725
runs-on: ubuntu-latest
1826

19-
name: "Sylius ${{ matrix.sylius }}, PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}, MySQL ${{ matrix.mysql }}"
27+
name: "Sylius ${{ matrix.sylius }}, PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}, ${{ matrix.database }}"
2028

2129
strategy:
2230
fail-fast: false
2331
matrix:
2432
php: ["8.3"]
25-
symfony: ["^6.4", "^7.3"]
26-
sylius: ["~2.0.0", "~2.1.0"]
33+
symfony: ["^6.4", "^7.4"]
34+
sylius: ["~2.0.0", "~2.1.0", "~2.2.0"]
35+
database: ["mysql:8.4"]
2736
node: ["22.x"]
28-
mysql: ["8.4"]
37+
38+
exclude:
39+
- sylius: "~2.0.0"
40+
symfony: "^7.4"
41+
42+
include:
43+
- php: "8.3"
44+
symfony: "^7.4"
45+
sylius: "~2.2.0"
46+
database: "mysql:8.0"
47+
node: "22.x"
48+
- php: "8.3"
49+
symfony: "^7.4"
50+
sylius: "~2.2.0"
51+
database: "mariadb:10.11"
52+
node: "22.x"
53+
- php: "8.3"
54+
symfony: "^7.4"
55+
sylius: "~2.2.0"
56+
database: "mariadb:11.4"
57+
node: "22.x"
58+
- php: "8.3"
59+
symfony: "^7.4"
60+
sylius: "~2.2.0"
61+
database: "postgres:15"
62+
node: "22.x"
63+
- php: "8.3"
64+
symfony: "^7.4"
65+
sylius: "~2.2.0"
66+
database: "postgres:16"
67+
node: "22.x"
68+
- php: "8.3"
69+
symfony: "^7.4"
70+
sylius: "~2.2.0"
71+
database: "postgres:17"
72+
node: "22.x"
2973

3074
env:
3175
APP_ENV: test
32-
BEHAT_BASE_URL: "http://127.0.0.1:8080/"
33-
DATABASE_URL: "mysql://root:root@127.0.0.1/sylius?serverVersion=${{ matrix.mysql }}"
3476

3577
steps:
3678
-
3779
uses: actions/checkout@v4
3880

3981
-
40-
name: Setup PHP
41-
uses: shivammathur/setup-php@v2
42-
with:
43-
php-version: "${{ matrix.php }}"
44-
extensions: intl
45-
tools: flex, symfony
46-
coverage: none
47-
48-
-
49-
name: Setup Node
50-
uses: actions/setup-node@v4
82+
name: Build Sylius Test Application
83+
uses: SyliusLabs/BuildTestAppAction@v4
5184
with:
52-
node-version: "${{ matrix.node }}"
53-
54-
-
55-
name: Shutdown default MySQL
56-
run: sudo service mysql stop
57-
58-
-
59-
name: Setup MySQL
60-
uses: mirromutth/mysql-action@v1.1
61-
with:
62-
mysql version: "${{ matrix.mysql }}"
63-
mysql root password: "root"
64-
65-
-
66-
name: Output PHP version for Symfony CLI
67-
run: php -v | head -n 1 | awk '{ print $2 }' > .php-version
68-
69-
-
70-
name: Get Composer cache directory
71-
id: composer-cache
72-
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
73-
74-
-
75-
name: Cache Composer
76-
uses: actions/cache@v4
77-
with:
78-
path: ${{ steps.composer-cache.outputs.dir }}
79-
key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json **/composer.lock') }}
80-
restore-keys: |
81-
${{ runner.os }}-php-${{ matrix.php }}-composer-
82-
83-
-
84-
name: Restrict Symfony version
85-
if: matrix.symfony != ''
86-
run: |
87-
composer global require --no-progress --no-scripts --no-plugins "symfony/flex:^2.4"
88-
composer global config --no-plugins allow-plugins.symfony/flex true
89-
composer config extra.symfony.require "${{ matrix.symfony }}"
90-
91-
-
92-
name: Restrict Sylius version
93-
if: matrix.sylius != ''
94-
run: composer require "sylius/sylius:${{ matrix.sylius }}" --no-update --no-scripts --no-interaction
95-
96-
-
97-
name: Install PHP dependencies
98-
run: composer install --no-interaction
85+
e2e_js: "yes"
86+
cache_key: "${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}"
87+
cache_restore_key: "${{ runner.os }}-php-${{ matrix.php }}-composer-"
88+
database: "${{ matrix.database }}"
89+
node_version: "${{ matrix.node }}"
90+
php_version: "${{ matrix.php }}"
91+
sylius_version: "${{ matrix.sylius }}"
92+
symfony_version: "${{ matrix.symfony }}"
9993

10094
-
10195
name: Run unit tests
10296
run: vendor/bin/phpunit --colors=always --testsuite=unit
10397

104-
-
105-
name: Get Yarn cache directory
106-
id: yarn-cache
107-
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
108-
109-
-
110-
name: Cache Yarn
111-
uses: actions/cache@v4
112-
with:
113-
path: ${{ steps.yarn-cache.outputs.dir }}
114-
key: ${{ runner.os }}-node-${{ matrix.node }}-yarn-${{ hashFiles('**/package.json **/yarn.lock') }}
115-
restore-keys: |
116-
${{ runner.os }}-node-${{ matrix.node }}-yarn-
117-
118-
-
119-
name: Install JS dependencies
120-
run: (cd vendor/sylius/test-application && yarn install)
121-
122-
-
123-
name: Prepare test application database
124-
run: |
125-
(vendor/bin/console doctrine:database:create -vvv)
126-
(vendor/bin/console doctrine:schema:create -vvv)
127-
128-
-
129-
name: Prepare test application assets
130-
run: |
131-
vendor/bin/console assets:install -vvv
132-
(cd vendor/sylius/test-application && yarn build)
133-
134-
-
135-
name: Prepare test application cache
136-
run: vendor/bin/console cache:warmup -vvv
137-
138-
-
139-
name: Load fixtures in test application
140-
run: vendor/bin/console sylius:fixtures:load -n
141-
14298
-
14399
name: Validate composer.json
144100
run: composer validate --ansi --strict
@@ -151,14 +107,6 @@ jobs:
151107
name: Run Non-unit PHPUnit tests
152108
run: vendor/bin/phpunit --colors=always --testsuite=non-unit
153109

154-
-
155-
name: Run Chrome Headless
156-
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 &
157-
158-
-
159-
name: Run webserver
160-
run: symfony server:start --port=8080 --no-tls --daemon
161-
162110
-
163111
name: Run Behat
164112
run: vendor/bin/behat --colors --strict -vvv --no-interaction -f progress || vendor/bin/behat --colors --strict -vvv --no-interaction -f progress --rerun
@@ -168,7 +116,7 @@ jobs:
168116
uses: actions/upload-artifact@v4
169117
if: failure()
170118
with:
171-
name: "Behat logs - ${{ matrix.sylius }}-${{ github.run_id }}-${{ github.run_number }}"
119+
name: "Behat logs - Sylius ${{ matrix.sylius }} - ${{ matrix.database }} - ${{ github.run_id }}"
172120
path: etc/build/
173121
if-no-files-found: ignore
174122
compression-level: 6

behat.yml.dist

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ default:
1111

1212
extensions:
1313
DMore\ChromeExtension\Behat\ServiceContainer\ChromeExtension: ~
14-
Robertfausk\Behat\PantherExtension: ~
1514

1615
FriendsOfBehat\MinkDebugExtension:
1716
directory: etc/build
@@ -22,44 +21,14 @@ default:
2221
files_path: "%paths.base%/vendor/sylius/sylius/src/Sylius/Behat/Resources/fixtures/"
2322
base_url: "%env(BEHAT_BASE_URL)%"
2423
default_session: symfony
25-
javascript_session: panther
24+
javascript_session: chrome
2625
sessions:
2726
symfony:
2827
symfony: ~
2928
chrome:
3029
chrome:
3130
api_url: http://127.0.0.1:9222
3231
validate_certificate: false
33-
panther:
34-
panther:
35-
manager_options:
36-
connection_timeout_in_ms: 5000
37-
request_timeout_in_ms: 120000
38-
chromedriver_arguments:
39-
- --log-path=etc/build/chromedriver.log
40-
- --verbose
41-
capabilities:
42-
acceptSslCerts: true
43-
acceptInsecureCerts: true
44-
unexpectedAlertBehaviour: accept
45-
options:
46-
webServerDir: '%paths.base%/vendor/sylius/test-application/public'
47-
browser_arguments:
48-
- --window-size=1200,1000
49-
- --headless
50-
- --no-sandbox
51-
- --disable-dev-shm-usage
52-
- --disable-gpu
53-
- --disable-infobars
54-
- --disable-features=TranslateUI
55-
- --disable-translate
56-
- --disable-popup-blocking
57-
- --disable-blink-features=AutomationControlled
58-
- --disable-component-extensions-with-background-pages
59-
- --disable-background-networking
60-
- --disable-dev-tools
61-
- --disable-extensions
62-
- --disable-password-manager-leak-detection
6332
show_auto: false
6433

6534
FriendsOfBehat\SymfonyExtension:

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
"phpstan/phpstan-doctrine": "^1.3",
3131
"phpstan/phpstan-webmozart-assert": "^1.2",
3232
"phpunit/phpunit": "^10.5",
33-
"robertfausk/behat-panther-extension": "^1.1",
3433
"sylius-labs/coding-standard": "^4.4",
3534
"sylius-labs/suite-tags-extension": "~0.2",
3635
"sylius/sylius-rector": "^2.0",

tests/TestApplication/.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
DATABASE_URL=mysql://root@127.0.0.1/acme_sylius_example_plugin_%kernel.environment%
22

3-
BEHAT_BASE_URL="http://nginx/"
3+
BEHAT_BASE_URL="http://127.0.0.1:8080/"
44

55
SYLIUS_TEST_APP_BUNDLES_PATH="tests/TestApplication/config/bundles.php"
66
SYLIUS_TEST_APP_CONFIGS_TO_IMPORT="@AcmeSyliusExamplePlugin/tests/TestApplication/config/config.yaml"

0 commit comments

Comments
 (0)