Skip to content

Commit 5bea9a9

Browse files
[CI] Use BuildTestAppAction (#43)
| Q | A | --------------- | ----- | Branch? | 1.1 | Bug fix? | no | New feature? | no | Related tickets | - Refactors `.github/workflows/build.yml` to use `SyliusLabs/BuildTestAppAction@v3.2.0` instead of manually defining all setup steps. Also changes scheduled run from weekly to daily. Refs: - https://docs.sylius.com/plugins-development-guide/test-application - https://github.com/SyliusLabs/BuildTestAppAction
2 parents c161046 + df45726 commit 5bea9a9

File tree

1 file changed

+38
-116
lines changed

1 file changed

+38
-116
lines changed

.github/workflows/build.yml

Lines changed: 38 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ on:
44
push:
55
branches-ignore:
66
- 'dependabot/**'
7+
paths-ignore:
8+
- "adr/**"
9+
- "*.md"
710
pull_request:
811
paths-ignore:
912
- "adr/**"
@@ -12,14 +15,18 @@ on:
1215
types: [created]
1316
schedule:
1417
-
15-
cron: "0 1 * * 6" # Run at 1am every Saturday
18+
cron: "0 1 * * *" # Run at 1am every day
1619
workflow_dispatch: ~
1720

21+
concurrency:
22+
group: ${{ github.workflow }}-${{ github.ref }}
23+
cancel-in-progress: true
24+
1825
jobs:
1926
tests:
2027
runs-on: ubuntu-latest
2128

22-
name: "Sylius ${{ matrix.sylius }}, PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}, MySQL ${{ matrix.mysql }}"
29+
name: "Sylius ${{ matrix.sylius }}, PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}, MySQL ${{ matrix.database_version }}"
2330

2431
strategy:
2532
fail-fast: false
@@ -28,139 +35,50 @@ jobs:
2835
symfony: ["^6.4", "~7.3.0"]
2936
sylius: ["~2.0.7", "~2.1.0"]
3037
node: ["22.x"]
31-
mysql: ["8.4"]
38+
database: ["mysql"]
39+
database_version: ["8.4"]
3240

3341
env:
3442
APP_ENV: test
35-
DATABASE_URL: "mysql://root:root@127.0.0.1/sylius?serverVersion=${{ matrix.mysql }}"
43+
DATABASE_URL: "mysql://root:root@127.0.0.1/sylius?serverVersion=${{ matrix.database_version }}"
3644

3745
steps:
3846
-
39-
uses: actions/checkout@v3
40-
41-
-
42-
name: Setup PHP
43-
uses: shivammathur/setup-php@v2
44-
with:
45-
php-version: "${{ matrix.php }}"
46-
extensions: intl
47-
tools: symfony
48-
coverage: none
49-
50-
-
51-
name: Setup Node
52-
uses: actions/setup-node@v4
53-
with:
54-
node-version: "${{ matrix.node }}"
55-
56-
-
57-
name: Shutdown default MySQL
58-
run: sudo service mysql stop
59-
60-
-
61-
name: Setup MySQL
62-
uses: mirromutth/mysql-action@v1.1
63-
with:
64-
mysql version: "${{ matrix.mysql }}"
65-
mysql root password: "root"
66-
67-
-
68-
name: Output PHP version for Symfony CLI
69-
run: php -v | head -n 1 | awk '{ print $2 }' > .php-version
70-
71-
-
72-
name: Get Composer cache directory
73-
id: composer-cache
74-
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
75-
76-
-
77-
name: Cache Composer
78-
uses: actions/cache@v4
79-
with:
80-
path: ${{ steps.composer-cache.outputs.dir }}
81-
key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json **/composer.lock') }}
82-
restore-keys: |
83-
${{ runner.os }}-php-${{ matrix.php }}-composer-
84-
85-
-
86-
name: Restrict Symfony version
87-
if: matrix.symfony != ''
88-
run: |
89-
composer global config --no-plugins allow-plugins.symfony/flex true
90-
composer global require --no-progress --no-scripts --no-plugins "symfony/flex:^2.4"
91-
composer config --no-plugins allow-plugins.symfony/thanks true
92-
composer config extra.symfony.require "${{ matrix.symfony }}"
93-
94-
-
95-
name: Restrict Sylius version
96-
if: matrix.sylius != ''
97-
run: composer require "sylius/sylius:${{ matrix.sylius }}" --no-update --no-scripts --no-interaction
98-
99-
-
100-
name: Install PHP dependencies
101-
run: composer install --no-interaction
102-
103-
-
104-
name: Run PHPStan
105-
run: vendor/bin/phpstan analyse -c phpstan.neon src/
106-
107-
-
108-
name: Run ECS
109-
run: vendor/bin/ecs
47+
uses: actions/checkout@v4
11048

11149
-
112-
name: Get Yarn cache directory
113-
id: yarn-cache
114-
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
115-
116-
-
117-
name: Cache Yarn
118-
uses: actions/cache@v4
50+
name: Build Sylius Test Application
51+
uses: SyliusLabs/BuildTestAppAction@v3.2.0
11952
with:
120-
path: ${{ steps.yarn-cache.outputs.dir }}
121-
key: ${{ runner.os }}-node-${{ matrix.node }}-yarn-${{ hashFiles('**/package.json **/yarn.lock') }}
122-
restore-keys: |
123-
${{ runner.os }}-node-${{ matrix.node }}-yarn-
124-
125-
-
126-
name: Install JS dependencies
127-
run: cd vendor/sylius/test-application && yarn install
128-
129-
-
130-
name: Prepare test application database
131-
run: |
132-
vendor/bin/console doctrine:database:create -vvv
133-
vendor/bin/console doctrine:migrations:migrate -vvv
134-
135-
-
136-
name: Prepare test application assets
137-
run: |
138-
vendor/bin/console assets:install -vvv
139-
cd vendor/sylius/test-application && yarn encore dev
140-
141-
-
142-
name: Prepare test application cache
143-
run: vendor/bin/console cache:warmup -vvv
53+
e2e_js: "yes"
54+
cache_key: "${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}"
55+
cache_restore_key: "${{ runner.os }}-php-${{ matrix.php }}-composer-"
56+
database: "${{ matrix.database }}"
57+
database_version: "${{ matrix.database_version }}"
58+
node_version: "${{ matrix.node }}"
59+
php_version: "${{ matrix.php }}"
60+
sylius_version: "${{ matrix.sylius }}"
61+
symfony_version: "${{ matrix.symfony }}"
14462

14563
-
146-
name: Load fixtures in test application
147-
run: vendor/bin/console sylius:fixtures:load -n
64+
name: Run security check
65+
run: composer audit --abandoned=ignore
14866

14967
-
15068
name: Validate composer.json
15169
run: composer validate --ansi --strict
15270

15371
-
154-
name: Validate database schema
155-
run: vendor/bin/console doctrine:schema:validate
72+
name: Run ECS
73+
run: vendor/bin/ecs
15674

15775
-
158-
name: Run Chrome Headless
159-
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 &
76+
name: Lint container
77+
run: vendor/bin/console lint:container
16078

16179
-
162-
name: Run webserver
163-
run: symfony server:start --port=8080 --daemon
80+
name: Run PHPStan
81+
run: vendor/bin/phpstan analyse -c phpstan.neon src/
16482

16583
-
16684
name: Run PHPUnit
@@ -175,15 +93,19 @@ jobs:
17593
uses: actions/upload-artifact@v4
17694
if: failure()
17795
with:
178-
name: "Behat logs - Sylius ${{ matrix.sylius }}, PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}, MySQL ${{ matrix.mysql }}"
96+
name: "Behat logs - Sylius ${{ matrix.sylius }}, PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}"
17997
path: etc/build/
18098
if-no-files-found: ignore
99+
compression-level: 6
100+
overwrite: true
181101

182102
-
183103
name: Upload test log logs
184104
uses: actions/upload-artifact@v4
185105
if: failure()
186106
with:
187-
name: "Var logs - Sylius ${{ matrix.sylius }}, PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}, MySQL ${{ matrix.mysql }}"
107+
name: "Var logs - Sylius ${{ matrix.sylius }}, PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}"
188108
path: tests/Application/var/log/
189109
if-no-files-found: ignore
110+
compression-level: 6
111+
overwrite: true

0 commit comments

Comments
 (0)