Skip to content

Commit 48e448a

Browse files
committed
MAGE-1374 Port 3.16.0 updates to 3.17.0 including latest CI
2 parents 4775ed1 + d196a0e commit 48e448a

File tree

129 files changed

+1790
-1361
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+1790
-1361
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
10+
colors="true"
11+
columns="max"
12+
beStrictAboutTestsThatDoNotTestAnything="false"
13+
bootstrap="/var/www/html/dev/tests/unit/framework/bootstrap.php">
14+
<coverage>
15+
<include>
16+
<directory suffix=".php">/var/www/html/vendor/algolia/algoliasearch-magento-2</directory>
17+
</include>
18+
<exclude>
19+
<directory>/var/www/html/vendor/algolia/algoliasearch-magento-2/Test</directory>
20+
</exclude>
21+
</coverage>
22+
<testsuites>
23+
<testsuite name="Algolia_Unit_Tests">
24+
<directory>/var/www/html/vendor/algolia/algoliasearch-magento-2/Test/Unit</directory>
25+
</testsuite>
26+
</testsuites>
27+
<php>
28+
<includePath>.</includePath>
29+
<ini name="memory_limit" value="-1"/>
30+
<ini name="date.timezone" value="America/Los_Angeles"/>
31+
<ini name="xdebug.max_nesting_level" value="200"/>
32+
</php>
33+
<listeners>
34+
<listener class="Magento\Framework\TestFramework\Unit\Listener\ReplaceObjectManager"/>
35+
</listeners>
36+
</phpunit>

.circleci/config.yml

Lines changed: 184 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -1,112 +1,198 @@
1-
version: 2
1+
version: 2.1
22

3-
shared: &shared
4-
working_directory: ~/build_directory/algoliasearch-magento-2
5-
steps:
6-
- checkout
3+
orbs:
4+
php: circleci/[email protected]
5+
slack: circleci/[email protected]
76

8-
- run:
9-
name: Override the Algolia extension with the cloned one
10-
command: |
11-
cp -R ~/build_directory/algoliasearch-magento-2 ~/magento_directory/vendor/algolia
12-
cd ~/magento_directory
13-
sudo composer require algolia/algoliasearch-magento-2
14-
composer dump-autoload
7+
executors:
8+
magento-executor:
9+
machine:
10+
image: ubuntu-2404:2024.11.1
11+
docker_layer_caching: true
1512

16-
- run:
17-
name: Start database server
18-
command: |
19-
sudo service mysql start
20-
sleep 2
21-
ps aux | grep mysql
22-
23-
- run:
24-
name: Install the extension
25-
command: |
26-
cd ~/magento_directory
27-
sudo service elasticsearch start # for some reasons has to be launched with the step
28-
sleep 10
29-
php -dmemory_limit=-1 bin/magento module:disable Magento_WebapiAsync Magento_Amqp Magento_MysqlMq Magento_MessageQueue
30-
php -dmemory_limit=-1 bin/magento module:enable Algolia_AlgoliaSearch
31-
sudo chmod -R 777 var/ pub/ generated/
32-
php -dmemory_limit=-1 bin/magento setup:upgrade
33-
php -dmemory_limit=-1 bin/magento setup:d:c
34-
php -dmemory_limit=-1 bin/magento setup:s:d -f
35-
36-
- run:
37-
name: Get the right tests config for DB and administration
38-
command: |
39-
rm -rf ~/magento_directory/vendor/dotmailer/dotmailer-magento2-extension/Test ~/magento_directory/vendor/dotmailer/dotmailer-magento2-extension-chat/Test
40-
mv ~/build_directory/algoliasearch-magento-2/dev/tests/install-config-mysql.php ~/magento_directory/dev/tests/integration/etc/install-config-mysql.php
41-
42-
- run:
43-
name: Before setup
44-
command: |
45-
echo 'memory_limit = 256M' | sudo tee /usr/local/etc/php/php.ini
46-
47-
- run:
48-
name: Get keys from dealer
49-
command: |
50-
if [ "$CIRCLE_PR_REPONAME" ]; then
51-
curl -s https://algoliasearch-client-keygen.herokuapp.com | sh >> $BASH_ENV
52-
fi
53-
54-
- run:
55-
name: Run tests
56-
command: |
57-
cd ~/magento_directory/dev/tests/integration
58-
sudo service elasticsearch start # for some reasons has to be launched with the step
59-
sleep 10
60-
61-
jobs:
62-
"magento-2.3":
63-
<<: *shared
64-
docker:
65-
- image: algolia/magento2-circleci:2.4.4-php7.4-v1
66-
67-
"magento-2.4":
68-
<<: *shared
69-
docker:
70-
- image: algolia/magento2-circleci:2.4.4-php7.4-v1
71-
72-
"quality-tools":
73-
docker:
74-
- image: algolia/magento2-circleci:2.4.4-php7.4-v1
75-
working_directory: ~/build_directory/algoliasearch-magento-2
13+
commands:
14+
setup-magento-environment:
15+
description: "Setup Magento environment with common configuration"
16+
parameters:
17+
php-version:
18+
type: string
19+
magento-version:
20+
type: string
7621
steps:
7722
- checkout
23+
- php/install_php:
24+
version: << parameters.php-version >>
25+
- php/install_composer
7826
- run:
79-
name: Setting permissions
27+
name: Configure composer authentication
8028
command: |
81-
sudo chown circleci:circleci ~/.composer/
82-
- restore_cache:
83-
keys:
84-
- composer-v4-{{ checksum "composer.json" }}
85-
- composer-v4-
86-
29+
composer config --global http-basic.repo.magento.com ${MAGENTO_AUTH_USERNAME} ${MAGENTO_AUTH_PASSWORD}
30+
composer config --global repositories.algolia vcs https://github.com/algolia/algoliasearch-magento-2
31+
- run:
32+
name: Setup folder structure and override file
33+
command: |
34+
mkdir ~/Sites
35+
cd ~/Sites
36+
cat \<<EOF > compose.override.yml
37+
services:
38+
phpfpm:
39+
image: markoshust/magento-php:<< parameters.php-version >>-fpm
40+
db:
41+
image: mariadb:10.11
42+
EOF
43+
- run:
44+
name: Setup magento enterprise
45+
working_directory: ~/Sites
46+
command: |
47+
curl -s https://raw.githubusercontent.com/markshust/docker-magento/master/lib/template | bash
48+
docker compose -f compose.yaml -f compose.override.yml up -d --remove-orphans
49+
bin/cli rm -rf composer.lock vendor composer.json
50+
bin/fixowns
51+
bin/setup-composer-auth
52+
bin/cli git clone [email protected]:magento/magento2.git .
53+
bin/cli git checkout tags/<< parameters.magento-version >>
54+
bin/composer require "algolia/algoliasearch-magento-2:dev-${CIRCLE_BRANCH}"
55+
bin/composer global require --dev phpunit/phpunit
56+
- run:
57+
name: Enable AlgoliaSearch extension
58+
working_directory: ~/Sites
59+
command: |
60+
bin/magento module:enable Algolia_AlgoliaSearch
8761
- run:
88-
name: Prepare environment
62+
name: Compile AlgoliaSearch extension
63+
working_directory: ~/Sites
8964
command: |
90-
sudo chown circleci:circleci ~/.composer/
91-
composer global config prefer-stable true
92-
composer global config minimum-stability dev
93-
composer global require algolia/magento2-tools
65+
bin/magento setup:di:compile
66+
bin/magento module:status Algolia_AlgoliaSearch
9467
95-
# We have to do this again because we restore the cache above, overwriting the vendor with the original.
96-
mkdir ~/magento_directory/vendor/algolia
97-
# rm -rf algoliasearch-magento-2
98-
cp -R ~/build_directory/algoliasearch-magento-2 ~/magento_directory/vendor/algolia
99-
cd ~/magento_directory
100-
composer dump-autoload
101-
- save_cache:
102-
key: composer-v4-{{ checksum "composer.json" }}
68+
jobs:
69+
magento-build:
70+
executor:
71+
name: magento-executor
72+
parameters:
73+
php-version:
74+
type: string
75+
magento-version:
76+
type: string
77+
steps:
78+
- setup-magento-environment:
79+
php-version: << parameters.php-version >>
80+
magento-version: << parameters.magento-version >>
81+
- run:
82+
name: Create test directories
83+
command: |
84+
mkdir ~/Sites/unit-tests
85+
mkdir ~/Sites/unit-coverage
86+
- persist_to_workspace:
87+
root: ~/Sites
10388
paths:
104-
- vendor
89+
- .
90+
- run:
91+
name: Run Unit Tests and copy results to CircleCI
92+
working_directory: ~/Sites
93+
command: |
94+
bin/cli sed -i '/<extensions>/,/<\/extensions>/d' /var/www/html/dev/tests/unit/phpunit.xml.dist
95+
bin/cli vendor/bin/phpunit -c /var/www/html/dev/tests/unit/phpunit.xml.dist --log-junit /var/www/html/dev/tests/unit/report/junit.xml /var/www/html/vendor/algolia/algoliasearch-magento-2/Test/Unit
96+
docker cp $(docker compose ps -q phpfpm):/var/www/html/dev/tests/unit/report/junit.xml ./unit-tests/
97+
- store_test_results:
98+
path: ~/Sites/unit-tests
99+
- run:
100+
name: Create Algolia-specific PHPUnit config for code coverage
101+
working_directory: ~/Sites
102+
command: |
103+
cp ~/project/.circleci/algolia-phpunit-code-coverage.xml algolia-phpunit.xml
104+
docker cp algolia-phpunit.xml $(docker compose ps -q phpfpm):/var/www/html/algolia-phpunit.xml
105+
- run:
106+
name: Run Unit Test Coverage and copy results to CircleCI
107+
working_directory: ~/Sites
108+
command: |
109+
bin/cli php -d xdebug.mode=coverage vendor/bin/phpunit -c /var/www/html/algolia-phpunit.xml --log-junit /var/www/html/dev/tests/unit/report/junit.xml --coverage-html /var/www/html/dev/tests/unit/report --coverage-text
110+
docker cp $(docker compose ps -q phpfpm):/var/www/html/dev/tests/unit/report ./unit-coverage/
111+
- store_artifacts:
112+
path: ~/Sites/unit-coverage/report
113+
destination: test-results/magento-<< parameters.magento-version >>-php-<< parameters.php-version >>
114+
115+
magento-integration-test:
116+
executor:
117+
name: magento-executor
118+
parameters:
119+
php-version:
120+
type: string
121+
magento-version:
122+
type: string
123+
steps:
124+
- setup-magento-environment:
125+
php-version: << parameters.php-version >>
126+
magento-version: << parameters.magento-version >>
127+
- run:
128+
name: Configure integration tests
129+
working_directory: ~/Sites
130+
command: |
131+
bin/cli cp dev/tests/integration/phpunit.xml.dist dev/tests/integration/phpunit.xml
132+
- run:
133+
name: Create integration test environment file
134+
working_directory: ~/Sites
135+
command: |
136+
echo "[email protected]" > .env
137+
echo "MAGENTO_ADMIN_FIRST_NAME=john" >> .env
138+
echo "MAGENTO_ADMIN_LAST_NAME=smith" >> .env
139+
echo "MAGENTO_ADMIN_USER=john.smith" >> .env
140+
echo "MAGENTO_ADMIN_PASSWORD=password123" >> .env
141+
echo "MAGENTO_ADMIN_FRONTNAME=admin" >> .env
142+
echo "MAGENTO_LOCALE=en_US" >> .env
143+
echo "MAGENTO_CURRENCY=USD" >> .env
144+
echo "MAGENTO_TIMEZONE=America/New_York" >> .env
145+
echo "ALGOLIA_APPLICATION_ID=$ALGOLIA_APPLICATION_ID" >> .env
146+
echo "ALGOLIA_SEARCH_KEY=$ALGOLIA_SEARCH_API_KEY" >> .env
147+
echo "ALGOLIA_API_KEY=$ALGOLIA_API_KEY" >> .env
148+
echo "INDEX_PREFIX=integration_test_" >> .env
149+
docker cp .env $(docker compose ps -q phpfpm):/var/www/html/dev/tests/integration/.env
150+
- run:
151+
name: Prepare integration test environment
152+
working_directory: ~/Sites
153+
command: |
154+
docker cp ../project/.circleci/install-config-mysql.php $(docker compose ps -q phpfpm):/var/www/html/dev/tests/integration/etc/install-config-mysql.php
155+
bin/magento module:enable --all
156+
bin/setup-integration-tests
157+
- run:
158+
name: Run Integration Tests
159+
working_directory: ~/Sites
160+
command: |
161+
bin/cli bash -c "cd ./dev/tests/integration && export $(cat .env | xargs) && ../../../vendor/bin/phpunit --debug --exclude-group problematic ../../../vendor/algolia/algoliasearch-magento-2/Test/Integration/"
162+
163+
notify:
164+
docker:
165+
- image: cimg/base:current
166+
steps:
167+
- slack/notify:
168+
event: fail
169+
template: basic_fail_1
170+
- slack/notify:
171+
event: pass
172+
template: success_tagged_deploy_1
105173

106174
workflows:
107-
version: 2
108-
build:
175+
magento-build-and-test-workflow:
176+
jobs:
177+
- magento-build:
178+
matrix:
179+
parameters:
180+
php-version: ["8.2"]
181+
magento-version: ["2.4.6-p11", "2.4.7-p6"]
182+
- notify:
183+
context: mage-slack
184+
magento-integration-test-workflow:
185+
when:
186+
or:
187+
- equal: [ main, << pipeline.git.branch >> ]
188+
- matches:
189+
pattern: ".*release.*"
190+
value: << pipeline.git.branch >>
109191
jobs:
110-
- "magento-2.4"
111-
- "magento-2.3"
112-
- "quality-tools"
192+
- magento-integration-test:
193+
matrix:
194+
parameters:
195+
php-version: ["8.2"]
196+
magento-version: ["2.4.7-p6"]
197+
- notify:
198+
context: mage-slack

.circleci/install-config-mysql.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
return [
8+
'db-host' => 'db',
9+
'db-user' => 'magento',
10+
'db-password' => 'magento',
11+
'db-name' => 'magento_integration_tests',
12+
'db-prefix' => '',
13+
'backend-frontname' => 'backend',
14+
'search-engine' => 'opensearch',
15+
'opensearch-host' => 'opensearch',
16+
'admin-user' => \Magento\TestFramework\Bootstrap::ADMIN_NAME,
17+
'admin-password' => \Magento\TestFramework\Bootstrap::ADMIN_PASSWORD,
18+
'admin-email' => \Magento\TestFramework\Bootstrap::ADMIN_EMAIL,
19+
'admin-firstname' => \Magento\TestFramework\Bootstrap::ADMIN_FIRSTNAME,
20+
'admin-lastname' => \Magento\TestFramework\Bootstrap::ADMIN_LASTNAME,
21+
'amqp-host' => 'rabbitmq',
22+
'amqp-port' => '5672',
23+
'amqp-user' => 'magento',
24+
'amqp-password' => 'magento',
25+
'consumers-wait-for-messages' => '0',
26+
'session-save' => 'redis',
27+
'session-save-redis-host' => 'redis',
28+
'session-save-redis-port' => 6379,
29+
'session-save-redis-db' => 5,
30+
'session-save-redis-max-concurrency' => 20,
31+
'cache-backend' => 'redis',
32+
'cache-backend-redis-server' => 'redis',
33+
'cache-backend-redis-db' => 4,
34+
'cache-backend-redis-port' => 6379,
35+
'page-cache' => 'redis',
36+
'page-cache-redis-server' => 'redis',
37+
'page-cache-redis-db' => 3,
38+
'page-cache-redis-port' => 6379
39+
];

Api/Insights/EventProcessorInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public function convertAddToCart(
9191
string $eventName,
9292
string $indexName,
9393
Item $item,
94-
string $queryID = null
94+
?string $queryID = null
9595
): array;
9696

9797
/**
@@ -123,7 +123,7 @@ public function convertPurchaseForItems(
123123
string $eventName,
124124
string $indexName,
125125
array $items,
126-
string $queryID = null
126+
?string $queryID = null
127127
): array;
128128

129129
}

0 commit comments

Comments
 (0)