ci(git): Copy generic CI/CD files #118
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Magento 2 Integration Tests | |
| on: ['push', 'pull_request'] | |
| jobs: | |
| integration-tests: | |
| name: Magento 2 Integration Tests | |
| runs-on: ubuntu-latest | |
| container: | |
| image: yireo/magento2installed:2.4.8-p3 | |
| services: | |
| mysql: | |
| image: yireo/mariadb:10 | |
| env: | |
| MYSQL_ROOT_PASSWORD: root | |
| MYSQL_USER: magento2 | |
| MYSQL_PASSWORD: magento2 | |
| MYSQL_DATABASE: magento2 | |
| options: --tmpfs /tmp:rw --tmpfs /var/lib/mysql:rw --health-cmd="mysqladmin ping" | |
| opensearch: | |
| image: yireo/opensearch:latest | |
| env: | |
| 'discovery.type': single-node | |
| ES_JAVA_OPTS: "-Xms256m -Xmx256m" | |
| options: --health-cmd="curl localhost:9200/_cluster/health?wait_for_status=yellow&timeout=60s" --health-interval=10s --health-timeout=5s --health-retries=3 | |
| redis: | |
| image: redis | |
| options: --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5 | |
| steps: | |
| - name: Checkout sources | |
| uses: actions/checkout@v4 | |
| - name: Detecting integration tests | |
| run: | | |
| test -d $GITHUB_WORKSPACE/Test/Integration || echo "SKIP_JOB=true" >> $GITHUB_ENV | |
| - name: Cleanup PHP | |
| if: env.SKIP_JOB != 'true' | |
| run: | | |
| test -f /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && rm -f /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini || true | |
| - name: Apply patch for reporting memory under Alpine | |
| if: env.SKIP_JOB != 'true' | |
| run: cd /tmp/magento && curl -fsSL https://patch-diff.githubusercontent.com/raw/magento/magento2/pull/39216.diff | git apply || true | |
| - name: Apply patch for changing MySQL client configuration | |
| if: env.SKIP_JOB != 'true' | |
| run: cd /tmp/magento && curl -fsSL https://patch-diff.githubusercontent.com/raw/magento/magento2/pull/40410.diff | git apply || true | |
| - name: Setting up module variables | |
| if: env.SKIP_JOB != 'true' | |
| run: | | |
| echo COMPOSER_NAME=`jq -e '.name' composer.json -r` >> $GITHUB_ENV | |
| echo MAGENTO_MODULE=`jq -e '.module_name' MODULE.json -r` >> $GITHUB_ENV | |
| - name: Configure GitLab | |
| if: env.SKIP_JOB != 'true' | |
| run: | | |
| test -n "${{ secrets.GITLAB_TOKEN }}" || exit 0 | |
| cd /tmp/magento | |
| composer config --auth gitlab-token.gitlab.yireo.com "${{ secrets.GITLAB_TOKEN }}" | |
| composer config repositories.loki-third-party composer https://gitlab.yireo.com/api/v4/group/loki-third-party/-/packages/composer/packages.json | |
| composer config repositories.loki-checkout composer https://gitlab.yireo.com/api/v4/group/loki-checkout/-/packages/composer/packages.json | |
| composer config repositories.loki-checkout-dev composer https://gitlab.yireo.com/api/v4/group/loki-checkout-dev/-/packages/composer/packages.json | |
| - name: Configure Magento Marketplace | |
| if: env.SKIP_JOB != 'true' | |
| run: | | |
| test -n "${{ secrets.MAGENTO_MARKETPLACE_PUBLIC_KEY }}" || exit 0 | |
| composer config --global --auth http-basic.repo.magento.com "${{ secrets.MAGENTO_MARKETPLACE_PUBLIC_KEY }}" "${{ secrets.MAGENTO_MARKETPLACE_PRIVATE_KEY }}" | |
| - name: Configure composer | |
| if: env.SKIP_JOB != 'true' | |
| run: | | |
| cd /tmp/magento | |
| composer config --global --auth github-oauth.github.com "${{ secrets.COMPOSER_GITHUB_TOKEN }}" | |
| test -f $GITHUB_WORKSPACE/.github/workflows/composer-additional.sh && source $GITHUB_WORKSPACE/.github/workflows/composer-additional.sh || true | |
| test -f $GITHUB_WORKSPACE/.github/workflows/composer-${MAGENTO_VERSION}.sh && source $GITHUB_WORKSPACE/.github/workflows/composer-${MAGENTO_VERSION}.sh || true | |
| - name: Add module source | |
| if: env.SKIP_JOB != 'true' | |
| run: | | |
| cp -R ${GITHUB_WORKSPACE} /tmp/magento/package-source | |
| cd /tmp/magento | |
| composer config repositories.local-source path package-source/ | |
| composer require -n --prefer-source -- ${COMPOSER_NAME}:@dev yireo/magento2-integration-test-helper | |
| - name: Run Magento 2 Integration Tests | |
| if: env.SKIP_JOB != 'true' | |
| run: | | |
| cd /tmp/magento/dev/tests/integration/ | |
| cp -R ${GITHUB_WORKSPACE}/.github/workflows/integration-tests/* . | |
| php ../../../vendor/bin/phpunit --atleast-version 9 && cp phpunit9.xml phpunit.xml | |
| php ../../../vendor/bin/phpunit --atleast-version 10 && cp phpunit10.xml phpunit.xml | |
| php -d memory_limit=-1 ../../../vendor/bin/phpunit -c phpunit.xml ../../../vendor/$COMPOSER_NAME/Test/Integration | |