Skip to content

Commit 3b1bfb7

Browse files
committed
[CI] Use BuildTestAppAction
1 parent 20c9eba commit 3b1bfb7

File tree

2 files changed

+51
-137
lines changed

2 files changed

+51
-137
lines changed

.github/workflows/build.yaml

Lines changed: 50 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -4,188 +4,102 @@ 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:
9-
types: [ created ]
13+
types: [created]
1014
schedule:
1115
-
12-
cron: "0 1 * * 6" # Run at 1am every Saturday
16+
cron: "0 1 * * *" # Run at 1am every day
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 }}, ${{ matrix.database == 'mysql' && format('MySQL {0}', matrix.mysql) || matrix.database == 'postgres' && format('PostgreSQL {0}', matrix.postgres) }}"
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"]
2533
symfony: ["^6.4", "~7.3.0"]
2634
sylius: ["~2.0.0", "~2.1.0"]
27-
database: ["mysql", "postgres"]
35+
database: ["mysql:8.4", "mariadb:11.4", "postgres:16"]
2836
node: ["22.x"]
29-
mysql: ["8.4"]
30-
postgres: ["15.8"]
3137

3238
env:
3339
APP_ENV: test
34-
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) }}
3540

3641
steps:
3742
-
3843
uses: actions/checkout@v4
3944

4045
-
41-
name: Setup PHP
42-
uses: shivammathur/setup-php@v2
43-
with:
44-
php-version: "${{ matrix.php }}"
45-
extensions: intl
46-
tools: flex, symfony
47-
coverage: none
48-
49-
-
50-
name: Setup Node
51-
uses: actions/setup-node@v4
52-
with:
53-
node-version: "${{ matrix.node }}"
54-
55-
-
56-
name: Shutdown default database services
46+
name: Parse database string
5747
run: |
58-
sudo service mysql stop || true
59-
sudo service postgresql stop || true
60-
61-
-
62-
name: Setup MySQL
63-
if: matrix.database == 'mysql'
64-
uses: mirromutth/mysql-action@v1.1
65-
with:
66-
mysql version: "${{ matrix.mysql }}"
67-
mysql root password: "root"
68-
69-
-
70-
name: Setup PostgreSQL
71-
if: matrix.database == 'postgres'
72-
uses: harmon758/postgresql-action@v1
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
7364
with:
74-
postgresql version: "${{ matrix.postgres }}"
75-
postgresql password: "postgres"
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 }}"
7674

7775
-
78-
name: Output PHP version for Symfony CLI
79-
run: php -v | head -n 1 | awk '{ print $2 }' > .php-version
76+
name: Run security check
77+
run: composer audit --abandoned=ignore
8078

8179
-
82-
name: Install certificates
83-
run: symfony server:ca:install
84-
85-
-
86-
name: Get Composer cache directory
87-
id: composer-cache
88-
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
89-
90-
-
91-
name: Cache Composer
92-
uses: actions/cache@v4
93-
with:
94-
path: ${{ steps.composer-cache.outputs.dir }}
95-
key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json **/composer.lock') }}
96-
restore-keys: |
97-
${{ runner.os }}-php-${{ matrix.php }}-composer-
98-
99-
-
100-
name: Restrict Symfony version
101-
if: matrix.symfony != ''
102-
run: |
103-
composer global config --no-plugins allow-plugins.symfony/flex true
104-
composer global require --no-progress --no-scripts --no-plugins "symfony/flex:^2.4"
105-
composer config extra.symfony.require "${{ matrix.symfony }}"
80+
name: Validate composer.json
81+
run: composer validate --ansi --strict
10682

10783
-
108-
name: Restrict Sylius version
109-
if: matrix.sylius != ''
110-
run: composer require "sylius/sylius:${{ matrix.sylius }}" --no-update --no-scripts --no-interaction
84+
name: Run ECS
85+
run: vendor/bin/ecs check
11186

11287
-
113-
name: Install PHP dependencies
114-
run: composer install --no-interaction
88+
name: Lint container
89+
run: vendor/bin/console lint:container
11590

11691
-
11792
name: Run PHPStan
11893
run: vendor/bin/phpstan analyse -c phpstan.neon.dist
11994

12095
-
121-
name: Run ECS
122-
run: vendor/bin/ecs check
123-
124-
-
125-
name: Run unit tests
96+
name: Run PHPUnit (Unit)
12697
run: vendor/bin/phpunit --colors=always --testsuite=unit
12798

12899
-
129-
name: Get Yarn cache directory
130-
id: yarn-cache
131-
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
132-
133-
-
134-
name: Cache Yarn
135-
uses: actions/cache@v4
136-
with:
137-
path: ${{ steps.yarn-cache.outputs.dir }}
138-
key: ${{ runner.os }}-node-${{ matrix.node }}-yarn-${{ hashFiles('**/package.json **/yarn.lock') }}
139-
restore-keys: |
140-
${{ runner.os }}-node-${{ matrix.node }}-yarn-
141-
142-
-
143-
name: Install JS dependencies
144-
run: (cd vendor/sylius/test-application && yarn install)
145-
146-
-
147-
name: Prepare test application database
148-
run: |
149-
vendor/bin/console doctrine:database:create -vvv
150-
vendor/bin/console doctrine:migrations:migrate -n -vvv -q
151-
152-
-
153-
name: Validate database schema
154-
run: vendor/bin/console doctrine:schema:validate
155-
156-
-
157-
name: Prepare test application assets
158-
run: |
159-
vendor/bin/console assets:install -vvv
160-
(cd vendor/sylius/test-application && yarn build)
161-
162-
-
163-
name: Prepare test application cache
164-
run: vendor/bin/console cache:warmup -vvv
165-
166-
-
167-
name: Load fixtures in test application
168-
run: vendor/bin/console sylius:fixtures:load -n
169-
-
170-
name: Validate composer.json
171-
run: composer validate --ansi --strict
172-
173-
-
174-
name: Validate container
175-
run: vendor/bin/console lint:container
176-
177-
-
178-
name: Run Non-unit PHPUnit tests
100+
name: Run PHPUnit (Non-unit)
179101
run: vendor/bin/phpunit --colors=always --testsuite=non-unit
180102

181-
-
182-
name: Run Chrome Headless
183-
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 &
184-
185-
-
186-
name: Run webserver
187-
run: symfony server:start --port=8080 --daemon
188-
189103
-
190104
name: Run Behat
191105
run: |
@@ -197,7 +111,7 @@ jobs:
197111
uses: actions/upload-artifact@v4
198112
if: failure()
199113
with:
200-
name: "Behat logs - ${{ matrix.sylius }}-${{ github.run_id }}-${{ github.run_number }}"
114+
name: "Behat logs - Sylius ${{ matrix.sylius }}, PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}, ${{ matrix.database }}"
201115
path: etc/build/
202116
if-no-files-found: ignore
203117
compression-level: 6

behat.yaml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ default:
1313

1414
Behat\MinkExtension:
1515
files_path: "%paths.base%/vendor/sylius/sylius/src/Sylius/Behat/Resources/fixtures/"
16-
base_url: "https://127.0.0.1:8080/"
16+
base_url: "http://127.0.0.1:8080/"
1717
default_session: symfony
1818
javascript_session: chrome
1919
sessions:

0 commit comments

Comments
 (0)