|
1 |
| -version: 2 |
| 1 | +version: 2.1 |
2 | 2 |
|
3 |
| -shared: &shared |
4 |
| - working_directory: ~/build_directory/algoliasearch-magento-2 |
5 |
| - steps: |
6 |
| - - checkout |
| 3 | +orbs: |
| 4 | + |
| 5 | + |
7 | 6 |
|
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 |
15 | 12 |
|
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 |
76 | 21 | steps:
|
77 | 22 | - checkout
|
| 23 | + - php/install_php: |
| 24 | + version: << parameters.php-version >> |
| 25 | + - php/install_composer |
78 | 26 | - run:
|
79 |
| - name: Setting permissions |
| 27 | + name: Configure composer authentication |
80 | 28 | 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 |
87 | 61 | - run:
|
88 |
| - name: Prepare environment |
| 62 | + name: Compile AlgoliaSearch extension |
| 63 | + working_directory: ~/Sites |
89 | 64 | 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 |
94 | 67 |
|
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 |
103 | 88 | 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 | + |
| 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 |
105 | 173 |
|
106 | 174 | 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 >> |
109 | 191 | 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 |
0 commit comments