ci(git): Copy generic CI/CD files #30
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: Playwright test | |
| on: ['push', 'pull_request'] | |
| jobs: | |
| playwright: | |
| runs-on: ubuntu-latest | |
| container: | |
| image: yireo/magento2playwright:2.4.8-p3 | |
| env: | |
| GIT_DEPTH: 1 | |
| GIT_STRATEGY: fetch | |
| MAGENTO_BASE_URL: "http://127.0.0.1:8888/" | |
| MAGENTO_BACKEND_FRONTNAME: "admin" | |
| MAGENTO_ADMIN_FIRSTNAME: "CI" | |
| MAGENTO_ADMIN_LASTNAME: "User" | |
| MAGENTO_ADMIN_EMAIL: "admin@example.com" | |
| MAGENTO_ADMIN_USER: "admin" | |
| MAGENTO_ADMIN_PASSWORD: "Admin123!@#" | |
| MAGENTO_LANGUAGE: "en_US" | |
| MAGENTO_CURRENCY: "USD" | |
| MAGENTO_TIMEZONE: "UTC" | |
| MAGENTO_USE_REWRITES: "1" | |
| MAGENTO_SEARCH_ENGINE: "opensearch" | |
| COMPOSER_ALLOW_SUPERUSER: "1" | |
| COMPOSER_MEMORY_LIMIT: "-1" | |
| MYSQL_HOST: "mysql" | |
| MYSQL_USER: "magento2" | |
| MYSQL_PASSWORD: "magento2" | |
| MYSQL_DATABASE: "magento2" | |
| MYSQL_ROOT_PASSWORD: "root" | |
| MYSQL_PORT: "3306" | |
| OPENSEARCH_HOST: "opensearch" | |
| OPENSEARCH_PORT: "9200" | |
| OPENSEARCH_JAVA_OPTS: "-Xms128m -Xmx128m" | |
| OPENSEARCH_INITIAL_ADMIN_PASSWORD: "admin" | |
| MAGENTO_VERSION: "2.4.8-p3" | |
| DISABLE_INVENTORY: true | |
| DISABLE_GRAPHQL: true | |
| DISABLE_ADOBE: true | |
| GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }} | |
| services: | |
| mysql: | |
| image: yireo/mariadb:10 | |
| env: | |
| MYSQL_DATABASE: magento2 | |
| MYSQL_USER: magento2 | |
| MYSQL_PASSWORD: magento2 | |
| MYSQL_ROOT_PASSWORD: root | |
| options: >- | |
| --health-cmd="mysqladmin ping" | |
| --health-interval=1s | |
| --health-timeout=5s | |
| --health-retries=3 | |
| redis: | |
| image: redis:latest | |
| options: >- | |
| --health-cmd="redis-cli ping" | |
| --health-interval=1s | |
| --health-timeout=5s | |
| --health-retries=3 | |
| opensearch: | |
| image: yireo/opensearch | |
| env: | |
| OPENSEARCH_JAVA_OPTS: "-Xms256m -Xmx256m" | |
| OPENSEARCH_INITIAL_ADMIN_PASSWORD: "admin" | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 1 | |
| - name: Detecting Playwright tests | |
| run: test -d $GITHUB_WORKSPACE/Test/Playwright || echo "SKIP_JOB=true" >> $GITHUB_ENV || true | |
| - 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: Configure Git safe directory | |
| if: env.SKIP_JOB != 'true' | |
| run: git config --global --add safe.directory "$GITHUB_WORKSPACE" | |
| - name: Setting up module variables | |
| if: env.SKIP_JOB != 'true' | |
| run: | | |
| echo COMPOSER_NAME=`jq '.name' composer.json -r` >> $GITHUB_ENV | |
| echo MAGENTO_MODULE=`jq '.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 gitlab-domains gitlab.yireo.com | |
| composer config --global --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 /tmp/magento/package-source | |
| composer require -n --prefer-source -- "${COMPOSER_NAME}:@dev" loki-checkout/magento2-core-cli:@dev loki-checkout/magento2-sample-data:@dev loki-checkout/magento2-functional-tests:@dev yireo/magento2-enable-module-sequence:@dev | |
| - name: Setup Magento | |
| if: env.SKIP_JOB != 'true' | |
| run: | | |
| cd /tmp/magento | |
| $GITHUB_WORKSPACE/.github/workflows/magento-install.sh || true | |
| bin/magento module:enable Yireo_EnableModuleSequence | |
| bin/magento module:sequence LokiCheckout_FunctionalTests LokiCheckout_SampleData LokiCheckout_CoreCli "${MAGENTO_MODULE}" | |
| bin/magento setup:upgrade | |
| bin/magento loki-checkout:sample-data:add-product | |
| bin/magento loki-checkout:modules:dump | |
| magerun2 config:store:set loki_checkout/functional_tests/token loki -n | |
| - name: Verify Magento installation | |
| if: env.SKIP_JOB != 'true' | |
| run: | | |
| echo "Verifying Magento installation in workspace..." | |
| test -f /tmp/magento/bin/magento || (echo "ERROR: Magento installation verification failed" && exit 1) || true | |
| echo "Magento installation verified successfully" | |
| - name: Run Playwright tests | |
| if: env.SKIP_JOB != 'true' | |
| run: | | |
| echo "Navigating to Playwright test directory..." | |
| cd /tmp/magento/vendor/loki-checkout/magento2-functional-tests/Test/Playwright/ | |
| echo "Installing npm dependencies..." | |
| # @todo: Add package-json.lock and run npm ci | |
| npm install | |
| npx playwright install chromium | |
| echo "Creating .env file..." | |
| printf "TEST_URL=http://127.0.0.1:8888\nTEST_TOKEN=loki\n" > .env | |
| echo "Running Playwright tests for project ${MAGENTO_MODULE}" | |
| CI=true TEST_TOKEN=loki MAGENTO_ROOT=/tmp/magento npx playwright test --project=${MAGENTO_MODULE} | |
| - name: Upload Playwright report | |
| if: ${{ !cancelled() }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: playwright-report | |
| path: playwright-report/ | |
| retention-days: 14 | |
| - name: Upload raw test results | |
| if: ${{ failure() }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test-results | |
| path: test-results/ | |
| retention-days: 14 |