Skip to content

Commit 8973aff

Browse files
[CI] Use BuildTestAppAction (#481)
| Q | A | --------------- | ----- | Branch? | 2.0 | Bug fix? | no | New feature? | no | Related tickets | - Refactors `.github/workflows/build.yaml` to use `SyliusLabs/BuildTestAppAction@v3.1.0` instead of manually defining all setup steps. Also updates `sylius/test-application` and fixes action configuration. Refs: - https://docs.sylius.com/plugins-development-guide/test-application - https://github.com/SyliusLabs/BuildTestAppAction
2 parents a9f5644 + 2763b07 commit 8973aff

File tree

1 file changed

+20
-131
lines changed

1 file changed

+20
-131
lines changed

.github/workflows/build.yaml

Lines changed: 20 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111
types: [created]
1212
schedule:
1313
-
14-
cron: "0 1 * * 6" # Run at 1am every Saturday
14+
cron: "0 1 * * *" # Run at 1am every day
1515
workflow_dispatch: ~
1616

1717
concurrency:
@@ -32,7 +32,7 @@ jobs:
3232
sylius: ["~2.0.0", "~2.1.0"]
3333
node: ["22.x"]
3434
database: ["mysql"]
35-
mysql: ["8.4"]
35+
database_version: ["8.4"]
3636
wkhtmltopdf: ["0.12.6.1-2"]
3737
state_machine_adapter: ["symfony_workflow"]
3838

@@ -43,7 +43,7 @@ jobs:
4343
sylius: "~2.1.0"
4444
node: "24.x"
4545
database: "mysql"
46-
mysql: "8.4"
46+
database_version: "8.4"
4747
wkhtmltopdf: "0.12.6.1-2"
4848
state_machine_adapter: "winzou_state_machine"
4949

@@ -53,7 +53,7 @@ jobs:
5353
sylius: "~2.1.0"
5454
node: "24.x"
5555
database: "mysql"
56-
mysql: "8.4"
56+
database_version: "8.4"
5757
wkhtmltopdf: false
5858
state_machine_adapter: "symfony_workflow"
5959

@@ -63,57 +63,20 @@ jobs:
6363
sylius: "~2.1.0"
6464
node: "24.x"
6565
database: "postgres"
66-
postgres: "15.8"
66+
database_version: "15.8"
6767
wkhtmltopdf: "0.12.6.1-2"
6868
state_machine_adapter: "symfony_workflow"
6969

7070
env:
7171
APP_ENV: test
72-
DATABASE_URL: ${{ matrix.database == 'mysql' && format('mysql://root:root@127.0.0.1/sylius?serverVersion={0}', matrix.mysql) || format('pgsql://postgres:postgres@127.0.0.1/sylius?serverVersion={0}', matrix.postgres) }}
72+
DATABASE_URL: ${{ matrix.database == 'mysql' && format('mysql://root:root@127.0.0.1/sylius?serverVersion={0}', matrix.database_version) || format('pgsql://postgres:postgres@127.0.0.1/sylius?serverVersion={0}', matrix.database_version) }}
7373
TEST_SYLIUS_STATE_MACHINE_ADAPTER: "${{ matrix.state_machine_adapter }}"
7474
TEST_SYLIUS_REFUND_PDF_GENERATION_DISABLED: ${{ matrix.wkhtmltopdf == false }}
7575

7676
steps:
7777
-
7878
uses: actions/checkout@v4
7979

80-
-
81-
name: Setup PHP
82-
uses: shivammathur/setup-php@v2
83-
with:
84-
php-version: "${{ matrix.php }}"
85-
extensions: intl
86-
tools: symfony
87-
coverage: none
88-
89-
-
90-
name: Setup Node
91-
uses: actions/setup-node@v4
92-
with:
93-
node-version: "${{ matrix.node }}"
94-
95-
-
96-
name: Shutdown default database services
97-
run: |
98-
sudo service mysql stop || true
99-
sudo service postgresql stop || true
100-
101-
-
102-
name: Setup MySQL
103-
if: matrix.database == 'mysql'
104-
uses: mirromutth/mysql-action@v1.1
105-
with:
106-
mysql version: "${{ matrix.mysql }}"
107-
mysql root password: "root"
108-
109-
-
110-
name: Setup PostgreSQL
111-
if: matrix.database == 'postgres'
112-
uses: harmon758/postgresql-action@v1
113-
with:
114-
postgresql version: "${{ matrix.postgres }}"
115-
postgresql password: "postgres"
116-
11780
-
11881
name: Setup cache for wkhtmltopdf
11982
uses: actions/cache@v4
@@ -131,96 +94,30 @@ jobs:
13194
wget https://github.com/wkhtmltopdf/packaging/releases/download/${{ matrix.wkhtmltopdf }}/wkhtmltox_${{ matrix.wkhtmltopdf }}.jammy_amd64.deb
13295
sudo dpkg -i wkhtmltox_${{ matrix.wkhtmltopdf }}.jammy_amd64.deb
13396
134-
-
135-
name: Output PHP version for Symfony CLI
136-
run: php -v | head -n 1 | awk '{ print $2 }' > .php-version
137-
138-
-
139-
name: Get Composer cache directory
140-
id: composer-cache
141-
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
142-
143-
-
144-
name: Cache Composer
145-
uses: actions/cache@v4
146-
with:
147-
path: ${{ steps.composer-cache.outputs.dir }}
148-
key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json **/composer.lock') }}
149-
restore-keys: |
150-
${{ runner.os }}-php-${{ matrix.php }}-composer-
151-
152-
-
153-
name: Restrict Symfony version
154-
if: matrix.symfony != ''
155-
run: |
156-
composer global config --no-plugins allow-plugins.symfony/flex true
157-
composer global require --no-progress --no-scripts --no-plugins "symfony/flex:^1.10"
158-
composer config extra.symfony.require "${{ matrix.symfony }}"
159-
160-
-
161-
name: Restrict Sylius version
162-
if: matrix.sylius != ''
163-
run: composer require "sylius/sylius:${{ matrix.sylius }}" --no-update --no-scripts --no-interaction
164-
16597
-
16698
name: Require Winzou State Machine
16799
if: "${{ matrix.state_machine_adapter == 'winzou_state_machine' }}"
168100
run: |
169-
composer require winzou/state-machine:^0.4 --no-update
170-
composer require winzou/state-machine-bundle:^0.6 --no-update
171-
172-
-
173-
name: Install PHP dependencies
174-
run: composer update --no-interaction
101+
composer require winzou/state-machine:^0.4 --no-update
102+
composer require winzou/state-machine-bundle:^0.6 --no-update
175103
176104
-
177-
name: Get Yarn cache directory
178-
id: yarn-cache
179-
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
180-
181-
-
182-
name: Cache Yarn
183-
uses: actions/cache@v4
105+
name: Build Sylius Test Application
106+
uses: SyliusLabs/BuildTestAppAction@v3.2.0
184107
with:
185-
path: ${{ steps.yarn-cache.outputs.dir }}
186-
key: ${{ runner.os }}-node-${{ matrix.node }}-yarn-${{ hashFiles('**/package.json **/yarn.lock') }}
187-
restore-keys: |
188-
${{ runner.os }}-node-${{ matrix.node }}-yarn-
189-
190-
-
191-
name: Install JS dependencies
192-
run: (cd vendor/sylius/test-application && yarn install)
193-
194-
- name: Check out database schema update
195-
run: |
196-
vendor/bin/console doctrine:database:create
197-
vendor/bin/console doctrine:schema:update --force
198-
vendor/bin/console doctrine:schema:validate
199-
vendor/bin/console doctrine:database:drop --force
200-
201-
-
202-
name: Prepare test application database
203-
run: |
204-
vendor/bin/console doctrine:database:create -vvv
205-
vendor/bin/console doctrine:migrations:migrate -n -vvv -q
206-
207-
-
208-
name: Prepare test application assets
209-
run: |
210-
vendor/bin/console assets:install public -vvv
211-
(cd vendor/sylius/test-application && yarn build:prod)
212-
213-
-
214-
name: Prepare test application cache
215-
run: vendor/bin/console cache:warmup -vvv
216-
217-
-
218-
name: Load fixtures in test application
219-
run: vendor/bin/console sylius:fixtures:load -n
108+
e2e_js: "yes"
109+
cache_key: "${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}"
110+
cache_restore_key: "${{ runner.os }}-php-${{ matrix.php }}-composer-"
111+
database: "${{ matrix.database }}"
112+
database_version: "${{ matrix.database_version }}"
113+
node_version: "${{ matrix.node }}"
114+
php_version: "${{ matrix.php }}"
115+
sylius_version: "${{ matrix.sylius }}"
116+
symfony_version: "${{ matrix.symfony }}"
220117

221118
-
222119
name: Run security check
223-
run: symfony security:check
120+
run: composer audit --abandoned=ignore
224121

225122
-
226123
name: Validate composer.json
@@ -242,14 +139,6 @@ jobs:
242139
name: Run PHPUnit
243140
run: vendor/bin/phpunit --colors=always
244141

245-
-
246-
name: Run Chrome Headless
247-
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 &
248-
249-
-
250-
name: Run webserver
251-
run: symfony server:start --port=8080 --daemon
252-
253142
-
254143
name: Run Behat
255144
run: |

0 commit comments

Comments
 (0)