forked from Smile-SA/elasticsuite
-
Notifications
You must be signed in to change notification settings - Fork 0
448 lines (398 loc) · 22.3 KB
/
20-integration.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
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
name: Integration
on:
push:
branches:
- 2.10.x
pull_request_target:
branches:
- 2.10.x
types: [labeled,synchronize]
jobs:
build:
if: (github.event_name != 'pull_request') || contains(github.event.pull_request.labels.*.name, 'safe to test')
runs-on: ubuntu-20.04
name: 'Integration'
services:
mysql:
image: docker://mysql:5.7
env:
MYSQL_ROOT_PASSWORD: magento2
MYSQL_DATABASE: magento2
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
elasticsearch:
image: docker://magento/magento-cloud-docker-elasticsearch:7.9-1.3.0
ports:
- 9200:9200
options: -e="discovery.type=single-node" --health-cmd="curl http://localhost:9200/_cluster/health" --health-interval=10s --health-timeout=5s --health-retries=10
strategy:
fail-fast: false
matrix:
include:
- php-versions: '7.4'
magento-versions: '2.4.3-p3'
magento-editions: 'community'
experimental: false
- php-versions: '7.4'
magento-versions: '2.4.3-p3'
magento-editions: 'enterprise'
experimental: false
- php-versions: '8.1'
magento-versions: '2.4.4-p9'
magento-editions: 'community'
experimental: true
- php-versions: '8.1'
magento-versions: '2.4.4-p9'
magento-editions: 'enterprise'
experimental: true
- php-versions: '8.1'
magento-versions: '2.4.5-p8'
magento-editions: 'community'
experimental: false
- php-versions: '8.1'
magento-versions: '2.4.5-p8'
magento-editions: 'enterprise'
experimental: false
continue-on-error: ${{ matrix.experimental }}
env:
magento-directory: /var/www/magento
MAGENTO_USERNAME: ${{ secrets.MAGENTO_USERNAME }}
MAGENTO_PASSWORD: ${{ secrets.MAGENTO_PASSWORD }}
steps:
- name: "[Init] Checkout"
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
persist-credentials: false
- name: "[Init] Setup PHP"
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: hash, iconv, mbstring, intl, bcmath, ctype, gd, pdo, mysql, curl, zip, dom, sockets, soap, openssl, simplexml, xsl
ini-values: post_max_size=256M, max_execution_time=180
- name: "[Init] Add php-fpm"
env:
version: ${{ matrix.php-versions }}
run: |
sudo apt-get install -y php$version-fpm
sudo service php$version-fpm start
sudo cp /usr/sbin/php-fpm$version /usr/bin/php-fpm
sudo service php$version-fpm start
sudo service php$version-fpm status
- name: "[Init] Setup Apache with PHP-FPM"
env:
MAGENTO_ROOT: ${{ env.magento-directory }}
version: ${{ matrix.php-versions }}
run: |
sudo apt-get -qq update
sudo apt-get -qq install apache2
sudo a2enmod rewrite actions alias proxy proxy_fcgi
sudo usermod -a -G www-data $USER
sudo cp -f Resources/tests/apache/apache.conf /etc/apache2/sites-available/000-default.conf
sudo mkdir -p $MAGENTO_ROOT
sudo chown -R $USER:www-data $MAGENTO_ROOT
sudo sed -e "s?%MAGENTO_ROOT%?$(readlink -f $MAGENTO_ROOT)?g" --in-place /etc/apache2/sites-available/000-default.conf
sudo sed -e "s?%PHP_VERSION%?$version?g" --in-place /etc/apache2/sites-available/000-default.conf
sudo apachectl configtest
sudo systemctl restart apache2
sudo service apache2 status
- name: "[Init] Prepare GraphQL test suite"
run: |
sudo chown $USER -R /usr/local/lib/node_modules
npm install -g graphqurl
- name: "[Init] Downgrade Composer"
env:
MAGENTO_VERSION: ${{ matrix.magento-versions }}
run: |
function version { echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; }
if [ $(version $MAGENTO_VERSION) -lt $(version "2.4.2") ]; then
composer self-update --1
else
composer self-update 2.1.14
fi
- name: "[Init] Optimize Composer"
env:
MAGENTO_VERSION: ${{ matrix.magento-versions }}
run: |
function version { echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; }
if [ $(version $MAGENTO_VERSION) -lt $(version "2.4.2") ]; then
composer global require hirak/prestissimo:0.3.10
fi
- name: "[Init] Determine composer cache directory"
id: composer-cache-directory
run: "echo \"directory=$(composer config cache-dir)\" >> $GITHUB_OUTPUT"
- name: "[Init] Cache Composer cache"
id: composer-cache
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache-directory.outputs.directory }}
key: composer-${{ matrix.php-versions }}-${{ matrix.magento-editions }}-${{ matrix.magento-versions }}
restore-keys: |
composer-${{ matrix.php-versions }}-${{ matrix.magento-editions }}-${{ matrix.magento-versions }}
- name: "[Init] Cache Sample data repo"
id: sampledata-cache
uses: actions/cache@v3
with:
path: ${{github.workspace}}/data
key: sampledata-${{ matrix.php-versions }}-${{ matrix.magento-editions }}-${{ matrix.magento-versions }}
restore-keys: |
sampledata-${{ matrix.php-versions }}-${{ matrix.magento-editions }}-${{ matrix.magento-versions }}
sampledata-${{ matrix.php-versions }}-${{ matrix.magento-editions }}-
sampledata-${{ matrix.php-versions }}-
sampledata-
- name: "[Init] Prepare Sample Data local clones"
if: steps.sampledata-cache.outputs.cache-hit != 'true'
working-directory: ${{ env.magento-directory }}
run: |
composer config --global github-protocols https
git config --global url."https://github.com/PMET-public".insteadOf "git@github.com:PMET-public"
if [ ! -d "$GITHUB_WORKSPACE/data/PMET-public" ]; then
rm -rf "$GITHUB_WORKSPACE/data/PMET-public"
git clone https://github.com/PMET-public/module-catalog-sample-data-venia.git "$GITHUB_WORKSPACE/data/PMET-public/module-catalog-sample-data-venia"
git clone https://github.com/PMET-public/module-configurable-sample-data-venia.git "$GITHUB_WORKSPACE/data/PMET-public/module-configurable-sample-data-venia"
git clone https://github.com/PMET-public/sample-data-media-venia.git "$GITHUB_WORKSPACE/data/PMET-public/sample-data-media-venia"
fi
- name: "[Init] Prepare Sample Data local repos"
working-directory: ${{ env.magento-directory }}
env:
MAGENTO_VERSION: ${{ matrix.magento-versions }}
run: |
function version { echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; }
if [ $(version $MAGENTO_VERSION) -lt $(version "2.4.2") ]; then
composer config --global --no-interaction --ansi repositories.module-catalog-sample-data-venia git "$GITHUB_WORKSPACE/data/PMET-public/module-catalog-sample-data-venia"
composer config --global --no-interaction --ansi repositories.module-configurable-sample-data-venia git "$GITHUB_WORKSPACE/data/PMET-public/module-configurable-sample-data-venia"
composer config --global --no-interaction --ansi repositories.sample-data-media-venia git "$GITHUB_WORKSPACE/data/PMET-public/sample-data-media-venia"
fi
composer config --global repositories
- name: "[Init] Cache Magento install"
id: magento-cache
uses: actions/cache@v3
with:
path: ${{ env.magento-directory }}
key: magento-${{ matrix.php-versions }}-${{ matrix.magento-editions }}-${{ matrix.magento-versions }}
restore-keys: |
magento-${{ matrix.php-versions }}-${{ matrix.magento-editions }}-${{ matrix.magento-versions }}
- name: "[Init] Prepare credentials"
if: ${{env.MAGENTO_USERNAME}} != 0
run: composer config -g http-basic.repo.magento.com "$MAGENTO_USERNAME" "$MAGENTO_PASSWORD"
- name: "[Init] Prepare Magento install if needed"
if: steps.magento-cache.outputs.cache-hit == 'true'
working-directory: ${{ env.magento-directory }}
run: |
rm -rf app/etc/env.php app/etc/config.php
composer config discard-changes true
composer remove magento/module-catalog-sample-data-venia --no-update --no-interaction
composer remove magento/module-configurable-sample-data-venia --no-update --no-interaction
composer remove magento/sample-data-media-venia --no-update --no-interaction
composer remove smile/elasticsuite --no-update --no-interaction
composer update --no-interaction --ignore-platform-reqs magento/module-catalog-sample-data-venia magento/module-configurable-sample-data-venia magento/sample-data-media-venia smile/elasticsuite
composer config discard-changes false
- name: "[Init] Install proper version of Magento through Composer"
if: steps.magento-cache.outputs.cache-hit != 'true'
env:
MAGENTO_VERSION: ${{ matrix.magento-versions }}
MAGENTO_EDITION: ${{ matrix.magento-editions }}
MAGENTO_ROOT: ${{ env.magento-directory }}
EXPERIMENTAL: ${{ matrix.experimental }}
run: |
STABILITY="--stability=stable"
if [ $EXPERIMENTAL = true ]; then
STABILITY=""
fi
sudo rm -rf $MAGENTO_ROOT
sudo mkdir -p $MAGENTO_ROOT
sudo chown -R $USER:www-data $MAGENTO_ROOT
composer create-project --repository-url=https://repo.magento.com magento/project-$MAGENTO_EDITION-edition=$MAGENTO_VERSION $STABILITY $MAGENTO_ROOT --quiet
- name: "[Init] Fix symfony/console and symfony string version"
working-directory: ${{ env.magento-directory }}
env:
MAGENTO_VERSION: ${{ matrix.magento-versions }}
run: |
function version { echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; }
if [ $(version $MAGENTO_VERSION) -lt $(version "2.4.4") ]; then
composer require symfony/console:4.4.26 --ignore-platform-reqs
composer require symfony/string:5.4.2 --ignore-platform-reqs
fi
- name: "[Init] Add current build of Elasticsuite"
working-directory: ${{ env.magento-directory }}
run: |
composer require --dev "smile/elasticsuite:${GITHUB_BASE_REF:-${GITHUB_REF##*/}}-dev" --ignore-platform-reqs
rm -rf vendor/smile/elasticsuite/**
cp -Rf $GITHUB_WORKSPACE/* vendor/smile/elasticsuite/
- name: "[Init] Fix Magento directory permissions"
env:
MAGENTO_ROOT: ${{ env.magento-directory }}
working-directory: ${{ env.magento-directory }}
run: |
sudo chmod -R a=r,u+w,a+X .
sudo find var pub/static pub/media app/etc generated/ -type f -exec chmod g+w {} \;
sudo find var pub/static pub/media app/etc generated/ -type d -exec chmod g+ws {} \;
sudo chown -R runner:www-data .
sudo chmod u+x bin/magento
- name: "[Test] Install Magento"
working-directory: ${{ env.magento-directory }}
run: php bin/magento setup:install --db-host="0.0.0.0" --db-password="magento2" --admin-user="admin" --admin-password="smile1234" --admin-email="admin@example.com" --admin-firstname="Admin" --admin-lastname="Smile" --db-name="magento2" --elasticsearch-host="localhost" --elasticsearch-port="9200" -q
- name: "[Test] Setup Upgrade"
working-directory: ${{ env.magento-directory }}
run: php bin/magento setup:upgrade -q
- name: "[Test] Reindex"
working-directory: ${{ env.magento-directory }}
run: php bin/magento index:reindex
- name: "[Test] Cache Flush"
working-directory: ${{ env.magento-directory }}
run: php bin/magento cache:flush
- name: "[Test] Compile"
working-directory: ${{ env.magento-directory }}
run: php bin/magento setup:di:compile
- name: "[Test] Data : Require for Magento <2.4.2"
working-directory: ${{ env.magento-directory }}
env:
MAGENTO_VERSION: ${{ matrix.magento-versions }}
run: |
function version { echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; }
if [ $(version $MAGENTO_VERSION) -lt $(version "2.4.2") ]; then
composer config discard-changes true
composer require magento/module-catalog-sample-data-venia:dev-master@dev --no-update --no-interaction --ignore-platform-reqs
composer require magento/module-configurable-sample-data-venia:dev-master@dev --no-update --no-interaction --ignore-platform-reqs
composer require magento/sample-data-media-venia:dev-master@dev --no-update --no-interaction --ignore-platform-reqs
composer update --no-interaction --ignore-platform-reqs magento/module-catalog-sample-data-venia magento/module-configurable-sample-data-venia magento/sample-data-media-venia
fi
- name: "[Test] Data : Require for Magento >=2.4.2"
working-directory: ${{ env.magento-directory }}
env:
MAGENTO_VERSION: ${{ matrix.magento-versions }}
run: |
function version { echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; }
if [ $(version $MAGENTO_VERSION) -ge $(version "2.4.2") ]; then
composer config discard-changes true
composer require magento/module-catalog-sample-data-venia --no-update --no-interaction --ignore-platform-reqs
composer require magento/module-configurable-sample-data-venia --no-update --no-interaction --ignore-platform-reqs
composer require magento/sample-data-media-venia --no-update --no-interaction --ignore-platform-reqs
composer update --no-interaction --ignore-platform-reqs magento/module-catalog-sample-data-venia magento/module-configurable-sample-data-venia magento/sample-data-media-venia
fi
- name: "[Init] Data : Prepare for Magento >= 2.4.4"
working-directory: ${{ env.magento-directory }}
run: |
function version { echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; }
if [ $(version $MAGENTO_VERSION) -ge $(version "2.4.2") ]; then
sed -i '/^<\/config>/i <preference for="Magento\\Framework\\Filesystem\\DriverInterface" type="Magento\\Framework\\Filesystem\\Driver\\File" />' app/etc/di.xml
fi
- name: "[Init] Data : Remove Downloadable / Virtual products"
working-directory: ${{ env.magento-directory }}
run: |
rm -rf vendor/magento/module-catalog-sample-data-venia/Setup/Patch/Data/InstallDownloadableProducts.php
- name: "[Test] Data : Install"
working-directory: ${{ env.magento-directory }}
run: php bin/magento setup:upgrade --keep-generated
- name: "[Test] Cache Clean before re-indexing"
working-directory: ${{ env.magento-directory }}
run: php bin/magento cache:clean
- name: "[Test] Data : Index"
working-directory: ${{ env.magento-directory }}
run: php bin/magento index:reindex
- name: "[Test] Web : Homepage"
run: |
echo "==> Testing homepage..."
curl_status=`curl --silent --connect-timeout 8 --output /dev/null -LI http://localhost/ -LI -w "%{http_code}\n"`
echo ${curl_status}
if [[ ${curl_status} -ge 400 ]];
then
exit 2;
fi;
- name: "[Test] Web : Catalogsearch"
run: |
echo "==> Testing catalogsearch..."
curl_status=`curl --silent --connect-timeout 8 --output /dev/null -LI http://localhost/catalogsearch/result/?q=top -LI -w "%{http_code}\n"`
echo ${curl_status}
if [[ ${curl_status} -ge 400 ]];
then
exit 2;
fi;
- name: "[Test] Web : Autocomplete"
run: |
echo "==> Testing Autocomplete..."
curl_status=`curl --silent --connect-timeout 8 --output /dev/null -LI http://localhost/search/ajax/suggest/?q=top -LI -w "%{http_code}\n"`
echo ${curl_status}
if [[ ${curl_status} -ge 400 ]];
then
exit 2;
fi;
- name: "[Test] Rest : Schema"
run: |
echo "==> Testing Rest Schema..."
curl -i -X GET http://localhost/rest/all/schema?services=all
- name: "[Test] GraphQl : Schema"
run: |
echo "==> Testing GraphQL Schema..."
curl -i -X POST http://localhost/graphql -H "Content-Type: application/json" -d @$GITHUB_WORKSPACE/Resources/tests/graphql/introspection_query.json
- name: "[Test] GraphQl : Search"
run: |
echo "==> Testing Search"
gq \
http://localhost/graphql \
-l \
-H "Content-Type: application/json" \
--variablesFile="$GITHUB_WORKSPACE/Resources/tests/graphql/search/variables.json" \
--queryFile="$GITHUB_WORKSPACE/Resources/tests/graphql/search/query.gql"
- name: "[Test] GraphQl : Search (filtered)"
run: |
echo "==> Testing Search"
gq \
http://localhost/graphql \
-l \
-H "Content-Type: application/json" \
--variablesFile="$GITHUB_WORKSPACE/Resources/tests/graphql/search/filter/variables.json" \
--queryFile="$GITHUB_WORKSPACE/Resources/tests/graphql/search/filter/query.gql"
- name: "[Test] GraphQl : Category"
run: |
echo "==> Testing Search"
gq \
http://localhost/graphql \
-l \
-H "Content-Type: application/json" \
--variablesFile="$GITHUB_WORKSPACE/Resources/tests/graphql/category/variables.json" \
--queryFile="$GITHUB_WORKSPACE/Resources/tests/graphql/category/query.gql"
- name: "[Test] GraphQl : Category (filtered)"
run: |
echo "==> Testing Search"
gq \
http://localhost/graphql \
-l \
-H "Content-Type: application/json" \
--variablesFile="$GITHUB_WORKSPACE/Resources/tests/graphql/category/filter/variables.json" \
--queryFile="$GITHUB_WORKSPACE/Resources/tests/graphql/category/filter/query.gql"
- name: "[Test] GraphQl : Product Detail"
run: |
echo "==> Testing Search"
gq \
http://localhost/graphql \
-l \
-H "Content-Type: application/json" \
--variablesFile="$GITHUB_WORKSPACE/Resources/tests/graphql/search/variables.json" \
--queryFile="$GITHUB_WORKSPACE/Resources/tests/graphql/search/query.gql"
- name: "[Test] GraphQl : View More (Category)"
run: |
echo "==> Testing Search"
gq \
http://localhost/graphql \
-l \
-H "Content-Type: application/json" \
--variablesFile="$GITHUB_WORKSPACE/Resources/tests/graphql/viewmore/category/variables.json" \
--queryFile="$GITHUB_WORKSPACE/Resources/tests/graphql/viewmore/category/query.gql"
- name: "[Test] GraphQl : View More (Search)"
run: |
echo "==> Testing Search"
gq \
http://localhost/graphql \
-l \
-H "Content-Type: application/json" \
--variablesFile="$GITHUB_WORKSPACE/Resources/tests/graphql/viewmore/search/variables.json" \
--queryFile="$GITHUB_WORKSPACE/Resources/tests/graphql/viewmore/search/query.gql"
- name: "[End] Job failed, gathering logs"
env:
MAGENTO_ROOT: ${{ env.magento-directory }}
if: ${{ failure() }}
run: |
tail -n 100 /var/log/apache2/apache-error.log
tail -n 100 $MAGENTO_ROOT/var/log/*.log