-
Notifications
You must be signed in to change notification settings - Fork 224
352 lines (313 loc) · 12.6 KB
/
magento_platform_tests.yml
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
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
---
name: Magento Platform Tests
on:
push:
branches:
- "master"
- "develop"
- "bugfix/*"
- "feature/*"
- "release/*"
paths:
- "bin/**"
- "config.yaml"
- "composer.json"
- "composer.lock"
- "res/**"
- "scoper.inc.php"
- "src/**"
- "version.txt"
pull_request_target:
branches:
- "master"
- "develop"
paths:
- "bin/**"
- "config.yaml"
- "composer.json"
- "composer.lock"
- "res/**"
- "scoper.inc.php"
- "src/**"
- "version.txt"
workflow_dispatch:
jobs:
phpunit:
name: Unit Tests
runs-on: ${{ matrix.operating-system }}
continue-on-error: true
strategy:
matrix:
include:
#- magento-version: magento-ce-2.4-develop
# operating-system: ubuntu-latest
# php-version: '8.1'
# mysql-version: '8.0'
# elasticsearch-version: 7.16.0
# composer-version: v2
# use-git-repository: true
# git-repository: https://github.com/magento/magento2.git
# git-branch: 2.4-develop
- magento-version: mage-os-latest
operating-system: ubuntu-latest
php-version: '8.1'
mysql-version: '8.0'
elasticsearch-version: '7.9.0'
composer-version: '2.2.17'
use-git-repository: false
git-repository: ""
- magento-version: mage-os-magento-mirror-2.4.5-p1
operating-system: ubuntu-latest
php-version: '8.1'
mysql-version: '8.0'
elasticsearch-version: '7.9.0'
composer-version: '2.2.17'
use-git-repository: false
git-repository: ""
- magento-version: mage-os-magento-mirror-2.4.3-p1
operating-system: ubuntu-latest
php-version: '7.4'
mysql-version: '8.0'
elasticsearch-version: '7.9.0'
composer-version: '2.2.17'
use-git-repository: false
git-repository: ""
- magento-version: magento-ce-2.4.7
operating-system: ubuntu-latest
php-version: '8.3'
mysql-version: '8.0'
elasticsearch-version: 7.16.0
composer-version: '2.2.17'
use-git-repository: false
git-repository: ""
git-branch: ""
- magento-version: magento-ce-2.4.7
operating-system: ubuntu-latest
php-version: '8.2'
mysql-version: '8.0'
elasticsearch-version: 7.16.0
composer-version: '2.2.17'
use-git-repository: false
git-repository: ""
git-branch: ""
- magento-version: magento-ce-2.4.6-p5
operating-system: ubuntu-latest
php-version: '8.2'
mysql-version: '8.0'
elasticsearch-version: 7.16.0
composer-version: '2.2.17'
use-git-repository: false
git-repository: ""
git-branch: ""
- magento-version: magento-ce-2.4.6-p5
operating-system: ubuntu-latest
php-version: '8.1'
mysql-version: '8.0'
elasticsearch-version: 7.16.0
composer-version: '2.2.17'
use-git-repository: false
git-repository: ""
git-branch: ""
- magento-version: magento-ce-2.4.5-p7
operating-system: ubuntu-latest
php-version: '8.1'
mysql-version: '8.0'
elasticsearch-version: 7.16.0
composer-version: '2.2.17'
use-git-repository: false
git-repository: ""
git-branch: ""
#- magento-version: magento-ce-2.4.4-p8
# operating-system: ubuntu-latest
# php-version: '8.1'
# mysql-version: '8.0'
# elasticsearch-version: 7.16.0
# composer-version: '2.2.17'
# use-git-repository: false
# git-repository: ""
# git-branch: ""
- magento-version: magento-ce-2.4.3-p2
operating-system: ubuntu-latest
php-version: '7.4'
mysql-version: '8.0'
elasticsearch-version: '7.9.0'
composer-version: '2.2.17'
use-git-repository: false
git-repository: ""
git-branch: ""
- magento-version: magento-ce-2.4.2-p1
operating-system: ubuntu-latest
php-version: '7.4'
mysql-version: '8.0'
elasticsearch-version: '7.9.0'
composer-version: '2.2.17'
use-git-repository: false
git-repository: ""
git-branch: ""
- magento-version: magento-ce-2.4.2
operating-system: ubuntu-latest
php-version: '7.4'
mysql-version: '8.0'
elasticsearch-version: '7.9.0'
composer-version: '2.2.17'
use-git-repository: false
git-repository: ""
git-branch: ""
services:
elaticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:${{ matrix.elasticsearch-version }}
# we bind the port to the host because the n98-magerun2 install command does not support to pass
# ES variables. So we cannot pass the random port via GitHub Action template variable.
ports:
- 9200:9200
- 9300:9300
options: -e="discovery.type=single-node" --health-cmd="curl http://localhost:9200/_cluster/health" --health-interval=10s --health-timeout=5s --health-retries=10
mysql:
image: mysql:${{ matrix.mysql-version }}
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: magento
ports:
- 3306
options: --tmpfs /tmp:rw --tmpfs /var/lib/mysql:rw --health-cmd="mysqladmin ping"
env:
MAGENTO_MARKETPLACE_USERNAME: ${{ secrets.MAGENTO_MARKETPLACE_USERNAME }}
MAGENTO_MARKETPLACE_PASSWORD: ${{ secrets.MAGENTO_MARKETPLACE_PASSWORD }}
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Dump GitHub context
run: echo "Register Github context"
env:
GITHUB_CONTEXT: ${{ toJSON(github) }}
# https://github.com/marketplace/actions/setup-php-action#matrix-setup
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
tools: composer:${{ matrix.composer-version }}, cs2pr
php-version: ${{ matrix.php-version }}
extensions: mcrypt, mbstring, intl
coverage: none
- name: Checkout PR
uses: actions/[email protected]
if: github.event_name == 'pull_request_target'
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Checkout HEAD
uses: actions/[email protected]
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
- name: Linux Setup
run: bash .github/workflows/linux-setup.sh
- name: Install Composer Presissimo Plugin
run: composer global require hirak/prestissimo
if: matrix.composer-version == 'v1'
- name: Get Composer Cache Directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
- name: Cache Dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: "${{ runner.os }}-php-${{ matrix.php-version }}-composer-${{ hashFiles('composer.lock') }}"
restore-keys: "${{ runner.os }}-php-${{ matrix.php-version }}-composer-"
- name: Install dependencies
# If we have a very broad restore-keys in the previous caching action,
# we might pull outdated dependencies from a parent branch for new branches.
# Over time, just running composer all the time to give it a chance
# to fix the outdated dependencies should be faster than having to pull
# everything from scratch for every new branch.
run: composer install --no-interaction --prefer-dist --no-progress --no-suggest
- name: Setup Magento Open Source Repository Credentials
run: |
composer global config http-basic.repo.magento.com "${MAGENTO_MARKETPLACE_USERNAME}" "${MAGENTO_MARKETPLACE_PASSWORD}";
# only run for Magento Open Source versions
# -> this is also a test if mage-os can be installed without credentials
if: startsWith(matrix.magento-version, 'magento-ce')
- name: Install Magento via git
run: |
git clone --branch "${{ matrix.git-branch }}" --single-branch ${{ matrix.git-repository }} "$GITHUB_WORKSPACE/magento";
cd "$GITHUB_WORKSPACE/magento";
composer --version;
composer install --no-interaction;
bin/magento setup:install \
--db-host="127.0.0.1:${{ job.services.mysql.ports['3306'] }}" \
--db-user=root \
--db-password=root \
--db-name=magento \
--cleanup-database \
--session-save=db \
--backend-frontname=admin \
--timezone="Europe/Berlin" \
--currency="EUR" \
--base-url="http://github.magerun.test/" \
--use-rewrites=1 \
--use-secure=1 \
--use-secure-admin=1 \
--admin-user=admin \
--admin-password=Password123 \
--admin-firstname=Armin \
--admin-lastname=Admin \
--admin-email="[email protected]" \
--search-engine="elasticsearch7" \
--elasticsearch-host="127.0.0.1" \
--elasticsearch-port=9200;
if: matrix.use-git-repository == true
- name: Install ${{ matrix.magento-version }} via n98-magerun2
run: |
composer --version;
bin/n98-magerun2 --ansi install \
--magentoVersionByName="${{ matrix.magento-version }}" --installationFolder="$GITHUB_WORKSPACE/magento" \
--dbHost=127.0.0.1 --dbPort=${{ job.services.mysql.ports['3306'] }} --dbUser=root --dbPass=root --dbName="magento" \
--useDefaultConfigParams=yes \
--installSampleData=no \
--baseUrl="http://github.magerun.test/";
if: matrix.use-git-repository == false
# @link https://github.com/magento/magento2/issues/38728
- name: Temporary downgrade credis to 1.5 for Magento 2.4.6/2.4.7
run: composer require colinmollenhour/php-redis-session-abstract:1.5.5
working-directory: ./magento
if: matrix.magento-version == 'magento-ce-2.4.6-p5' || matrix.magento-version == 'magento-ce-2.4.7' || matrix.magento-version == 'mage-os-latest'
- name: Configure matchers
uses: mheap/phpunit-matcher-action@main
- name: Run PHPUnit (Developer Mode)
run: vendor/bin/phpunit --debug --process-isolation
- name: Activate Magento Production Mode
working-directory: ./magento
run: |
rm -Rf generated/code;
bin/magento deploy:mode:set production;
- name: Run PHPUnit (Production Mode)
run: vendor/bin/phpunit --debug --process-isolation
# phpstan is temporarily disabled until we can find a solution to run against several Magento versions
# or run only against the latest version?
## we run phpstan after di:compile in production mode to prevent class not found errors in Magerun sources
#- name: Run PHPStan
# working-directory: ./magento
# run:
# ../vendor/bin/phpstan analyse --level 1 --autoload-file="../src/bootstrap.php" ../src
# if: matrix.magento-version == 'magento-ce-2.4.5-p2'
- name: Setup PHP for phar build
uses: shivammathur/setup-php@v2
with:
tools: composer:2
php-version: "7.4"
- name: Build phar file
run: |
composer self-update --2;
composer --version;
composer global remove hirak/prestissimo;
bash ./build.sh;
composer self-update --rollback &> /dev/null || true;
- name: Setup PHP for project tests
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
- name: Phar functional tests (Magerun)
run: bats tests/bats/functional_magerun_commands.bats
env:
N98_MAGERUN2_TEST_MAGENTO_ROOT: "${{ github.workspace }}/magento"
N98_MAGERUN2_BIN: "${{ github.workspace }}/n98-magerun2.phar"
- name: Phar functional tests (Magento Core)
run: bats tests/bats/functional_core_commands.bats
env:
N98_MAGERUN2_TEST_MAGENTO_ROOT: "${{ github.workspace }}/magento"
N98_MAGERUN2_BIN: "${{ github.workspace }}/n98-magerun2.phar"