Skip to content

Commit caa9b15

Browse files
committed
Use SyliusLabs/BuildTestAppAction for CI workflow
1 parent 19d0f75 commit caa9b15

File tree

3 files changed

+41
-144
lines changed

3 files changed

+41
-144
lines changed

.github/workflows/build.yaml

Lines changed: 39 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -4,141 +4,78 @@ 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"]
33+
symfony: ["^6.4", "~7.3.0"]
2634
sylius: ["~2.0.0", "~2.1.0"]
35+
database: ["mysql:8.4"]
2736
node: ["22.x"]
28-
mysql: ["8.4"]
2937

3038
env:
3139
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 }}"
3440

3541
steps:
3642
-
3743
uses: actions/checkout@v4
3844

3945
-
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
51-
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 != ''
46+
name: Parse database string
8647
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
48+
DB_TYPE="${DATABASE%%:*}"
49+
DB_VERSION="${DATABASE##*:}"
50+
echo "DB_TYPE=$DB_TYPE" >> $GITHUB_ENV
51+
echo "DB_VERSION=$DB_VERSION" >> $GITHUB_ENV
52+
53+
if [ "$DB_TYPE" = "postgres" ]; then
54+
echo "DATABASE_URL=pgsql://postgres:postgres@127.0.0.1/sylius?serverVersion=$DB_VERSION" >> $GITHUB_ENV
55+
else
56+
echo "DATABASE_URL=mysql://root:root@127.0.0.1/sylius?serverVersion=$DB_VERSION" >> $GITHUB_ENV
57+
fi
58+
env:
59+
DATABASE: ${{ matrix.database }}
60+
61+
-
62+
name: Build Sylius Test Application
63+
uses: SyliusLabs/BuildTestAppAction@v3.2.0
64+
with:
65+
e2e_js: "yes"
66+
cache_key: "${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}"
67+
cache_restore_key: "${{ runner.os }}-php-${{ matrix.php }}-composer-"
68+
database: "${{ env.DB_TYPE }}"
69+
database_version: "${{ env.DB_VERSION }}"
70+
node_version: "${{ matrix.node }}"
71+
php_version: "${{ matrix.php }}"
72+
sylius_version: "${{ matrix.sylius }}"
73+
symfony_version: "${{ matrix.symfony }}"
9974

10075
-
10176
name: Run unit tests
10277
run: vendor/bin/phpunit --colors=always --testsuite=unit
10378

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-
14279
-
14380
name: Validate composer.json
14481
run: composer validate --ansi --strict
@@ -151,14 +88,6 @@ jobs:
15188
name: Run Non-unit PHPUnit tests
15289
run: vendor/bin/phpunit --colors=always --testsuite=non-unit
15390

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-
16291
-
16392
name: Run Behat
16493
run: vendor/bin/behat --colors --strict -vvv --no-interaction -f progress || vendor/bin/behat --colors --strict -vvv --no-interaction -f progress --rerun

behat.yml.dist

Lines changed: 2 additions & 33 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
@@ -20,46 +19,16 @@ default:
2019

2120
Behat\MinkExtension:
2221
files_path: "%paths.base%/vendor/sylius/sylius/src/Sylius/Behat/Resources/fixtures/"
23-
base_url: "%env(BEHAT_BASE_URL)%"
22+
base_url: "http://127.0.0.1:8080/"
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",

0 commit comments

Comments
 (0)