-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathaction.yaml
314 lines (268 loc) · 12.1 KB
/
action.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
name: "Build Sylius Test Application"
description: "Builds a Sylius plugin's test application with the given PHP, Sylius, Symfony, MySQL versions."
inputs:
# General
build_type:
required: true
description: "A build type to be used"
default: "app" # available options are "sylius" (to tests Sylius itself), "app" (to test Sylius-based application, e.g. Sylius-Standard), "plugin" (to test Sylius plugin)
application_root_dir:
required: false
description: "The application directory to be used (useful for monorepos with isolation tests)"
default: "" # If empty directory will be resolved based on the build type
application_test_dir:
required: false
description: "The application test directory to be used (useful for monorepos with isolation tests)"
default: "" # If empty directory will be resolved based on the build type
cache_key:
required: false
description: "A cache key to be used"
default: "" # If empty no cache is used
cache_restore_key:
required: false
description: "A cache restore key to be used"
default: "" # If empty no cache is used
e2e:
required: false
description: "Whether prepare the test application for e2e tests"
default: "no"
e2e_js:
required: false
description: "Whether prepare the test application for e2e tests with JS"
default: "no"
# Database
database:
required: true
description: "A database engine to be used"
default: "mysql" # available options are "mysql", "mariadb", "postgresql"
database_version:
required: true
description: "A database version to be used"
legacy_postgresql_setup:
required: false
description: "Whether to use legacy PostgreSQL setup (before 1.13)"
default: "yes"
# PHP
php_version:
required: true
description: "A PHP version to be used"
php_extensions:
required: true
description: "PHP extensions to be installed"
default: "intl, gd, opcache, mysql, pdo_mysql, pgsql, pdo_pgsql"
php_tools:
required: true
description: "PHP tools to be installed"
default: "symfony"
php_coverage:
required: false
description: "PHP coverage"
default: "none"
# Symfony
symfony_version:
required: true
description: "A Symfony version to be used"
# Sylius
sylius_version:
required: false
description: "A Sylius version to be used"
default: "" # If empty no Sylius restriction is applied, also it allows to use this action while testing Sylius itself
sylius_integration:
required: false
description: "A Sylius integration to be used"
default: "" # If empty no Sylius integration is applied
# Node.js (only when e2e_js is set to "yes")
node_version:
required: false
description: "A Node.js version to be used"
default: "20.x"
# Chrome (only when e2e_js is set to "yes")
chrome_version:
required: false
description: "Chrome version to be used"
default: "stable"
runs:
using: "composite"
steps:
-
name: Set application_dir environment variable
shell: bash
env:
BUILD_TYPE: ${{ inputs.build_type }}
APPLICATION_ROOT_DIR: ${{ inputs.application_root_dir }}
run: |
if [ "$APPLICATION_ROOT_DIR" != "" ]; then
echo "application_dir=${APPLICATION_ROOT_DIR}" >> $GITHUB_ENV
else
echo "application_dir=." >> $GITHUB_ENV
fi
-
name: Set test_dir environment variable
shell: bash
env:
BUILD_TYPE: ${{ inputs.build_type }}
APPLICATION_ROOT_DIR: ${{ env.application_dir }}
APPLICATION_TEST_DIR: ${{ inputs.application_test_dir }}
run: |
if [ "$APPLICATION_TEST_DIR" != "" ]; then
echo "test_dir=${APPLICATION_TEST_DIR}" >> $GITHUB_ENV
elif [ "$BUILD_TYPE" = "plugin" ]; then
echo "test_dir=tests/Application" >> $GITHUB_ENV
else
echo "test_dir=${APPLICATION_ROOT_DIR}" >> $GITHUB_ENV
fi
#####################################################################
# Set up a database #
#####################################################################
- name: Shutdown default MySQL
run: sudo service mysql stop
shell: bash
- name: Setup MySQL
if: inputs.database == 'mysql'
uses: mirromutth/[email protected]
with:
mysql version: "${{ inputs.database_version }}"
mysql root password: "root"
- name: Setup MariaDB
if: inputs.database == 'mariadb'
uses: getong/[email protected]
with:
mariadb version: "${{ inputs.database_version }}"
mysql root password: "root"
- name: Setup PostgreSQL
if: inputs.database == 'postgresql'
uses: harmon758/postgresql-action@v1
with:
postgresql version: "${{ inputs.database_version }}"
postgresql password: "postgres"
#####################################################################
# Set up PHP & Symfony & Sylius #
#####################################################################
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "${{ inputs.php_version }}"
extensions: "${{ inputs.php_extensions }}"
tools: "${{ inputs.php_tools }}"
coverage: "${{ inputs.php_coverage }}"
- name: Output PHP version for Symfony CLI
run: php -v | head -n 1 | awk '{ print $2 }' > .php-version
shell: bash
- name: Install certificates
run: symfony server:ca:install
shell: bash
- name: Restrict Symfony version
run: |
composer global config --no-plugins allow-plugins.symfony/flex true
composer global require --no-progress --no-scripts --no-plugins "symfony/flex:^1.17 || ^2.0"
composer config extra.symfony.require "${{ inputs.symfony_version }}"
shell: bash
working-directory: "${{ env.application_dir }}"
- name: Restrict Sylius version
if: inputs.sylius_version != '' && inputs.build_type != 'sylius'
run: composer require "sylius/sylius:${{ inputs.sylius_version }}" --no-update --no-scripts --no-interaction
shell: bash
working-directory: "${{ env.application_dir }}"
- name: Get Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
shell: bash
- name: "Restore dependencies"
if: inputs.cache_key != ''
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ inputs.cache_key }}
restore-keys: |
${{ inputs.cache_restore_key }}
- name: Install PHP dependencies
run: composer install --no-interaction
env:
COMPOSER_ROOT_VERSION: dev-main
shell: bash
working-directory: "${{ env.application_dir }}"
- name: Install Sylius integration
if: inputs.integration != '' && inputs.build_type != 'sylius'
run: composer integration ${{ inputs.integration }}
env:
COMPOSER_ROOT_VERSION: dev-main
shell: bash
working-directory: "${{ env.application_dir }}"
#####################################################################
# Prepare for end-to-end tests #
#####################################################################
- uses: browser-actions/setup-chrome@latest
if: inputs.e2e_js == 'yes'
with:
chrome-version: "${{ inputs.chrome_version }}"
- name: Run Chrome Headless
if: inputs.e2e_js == 'yes'
run: |
export DISPLAY=:99
chrome --enable-automation --disable-background-networking --no-default-browser-check --no-first-run --disable-popup-blocking --disable-default-apps --allow-insecure-localhost --disable-translate --remote-debugging-port=9222 --disable-extensions --no-sandbox --enable-features=Metal --headless --window-size=2880,1800 --proxy-server='direct://' --proxy-bypass-list='*' http://127.0.0.1 > /dev/null 2>&1 &
shell: bash
working-directory: "${{ env.test_dir }}"
- name: Run webserver
if: inputs.e2e == 'yes' || inputs.e2e_js == 'no'
run: symfony server:start --port=8080 --dir=${{ env.test_dir }}/public --daemon
shell: bash
- name: Configure Encore for non-JS end-to-end tests
if: inputs.e2e == 'yes' && inputs.e2e_js == 'no'
run: |
mkdir -p public/build/admin public/build/shop
echo "{}" > public/build/admin/manifest.json
echo "{}" > public/build/shop/manifest.json
shell: bash
working-directory: "${{ env.test_dir }}"
#####################################################################
# Set up Node.js #
#####################################################################
- name: Setup Node
if: inputs.e2e_js == 'yes' && inputs.node_version != ''
uses: actions/setup-node@v4
with:
node-version: "${{ inputs.node_version }}"
- name: Install JS dependencies
if: inputs.e2e_js == 'yes' && inputs.node_version != ''
run: yarn install
shell: bash
working-directory: "${{ env.test_dir }}"
- name: Build JS assets
if: inputs.e2e_js == 'yes' && inputs.node_version != ''
run: yarn build
shell: bash
working-directory: "${{ env.test_dir }}"
#####################################################################
# Prepare the application #
#####################################################################
- name: Prepare application database
if: inputs.database != 'postgresql' || (inputs.database == 'postgresql' && inputs.legacy_postgresql_setup == 'no')
run: |
bin/console doctrine:database:create --if-not-exists -vvv
bin/console doctrine:migrations:migrate -n -vvv
shell: bash
working-directory: "${{ env.test_dir }}"
- name: Prepare application database (legacy)
if: inputs.database == 'postgresql' && inputs.legacy_postgresql_setup == 'yes'
run: |
bin/console doctrine:database:create --if-not-exists -vvv
bin/console doctrine:schema:up --force -vvv
bin/console doctrine:schema:validate
bin/console doctrine:migrations:sync-metadata-storage
shell: bash
working-directory: "${{ env.test_dir }}"
- name: Install assets
run: bin/console assets:install public -vvv
shell: bash
working-directory: "${{ env.test_dir }}"
- name: Warm up cache
run: bin/console cache:warmup -vvv
shell: bash
working-directory: "${{ env.test_dir }}"
- name: Load fixtures
run: bin/console sylius:fixtures:load -n
shell: bash
working-directory: "${{ env.test_dir }}"
branding:
icon: activity
color: green