From edc011ae8af67a90fd1e63f4950e2d59158c8acc Mon Sep 17 00:00:00 2001 From: Can Demiralp Date: Fri, 1 Nov 2024 15:00:04 +0100 Subject: [PATCH 1/8] Install Magento and trigger E2E test on the repository --- .github/Makefile | 4 ++ .github/docker-compose.e2e.yml | 29 ++++++++++++++ .github/docker-compose.yml | 11 +++--- .github/scripts/e2e.sh | 29 ++++++++++++++ .github/workflows/e2e.yml | 72 +++++++++++++++++++++++++++++----- 5 files changed, 131 insertions(+), 14 deletions(-) create mode 100644 .github/docker-compose.e2e.yml create mode 100755 .github/scripts/e2e.sh diff --git a/.github/Makefile b/.github/Makefile index 610e65de..f0057afc 100644 --- a/.github/Makefile +++ b/.github/Makefile @@ -39,6 +39,10 @@ flush: # Full plugin setup plugin: install configure flush +# Production mode +production: + bin/magento deploy:mode:set production + # Setup permissions fs: find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} + diff --git a/.github/docker-compose.e2e.yml b/.github/docker-compose.e2e.yml new file mode 100644 index 00000000..f5f51a86 --- /dev/null +++ b/.github/docker-compose.e2e.yml @@ -0,0 +1,29 @@ +version: '3' +services: + playwright: + image: mcr.microsoft.com/playwright:v1.47.2 + shm_size: 1gb + ipc: host + cap_add: + - SYS_ADMIN + networks: + - backend + environment: + - INTEGRATION_TESTS_BRANCH + - MAGENTO_BASE_URL + - MAGENTO_ADMIN_USERNAME + - MAGENTO_ADMIN_PASSWORD + - PAYPAL_USERNAME + - PAYPAL_PASSWORD + - ADYEN_API_KEY + - ADYEN_CLIENT_KEY + - ADYEN_MERCHANT + - GOOGLE_USERNAME + - GOOGLE_PASSWORD + - WEBHOOK_USERNAME + - WEBHOOK_PASSWORD + volumes: + - ./scripts/e2e.sh:/e2e.sh + - ../test-report:/tmp/test-report +networks: + backend: diff --git a/.github/docker-compose.yml b/.github/docker-compose.yml index 588ba225..7cac6d40 100644 --- a/.github/docker-compose.yml +++ b/.github/docker-compose.yml @@ -11,9 +11,9 @@ services: MARIADB_DATABASE: magento MARIADB_USER: magento MARIADB_PASSWORD: magento - elastic: - image: elasticsearch:7.17.25 - container_name: elasticsearch + opensearch: + image: bitnami/opensearch:2 + container_name: opensearch-container networks: - backend ports: @@ -37,11 +37,12 @@ services: - magento2.test.com environment: DB_SERVER: mariadb - ELASTICSEARCH_SERVER: elasticsearch + OPENSEARCH_SERVER: opensearch-container MAGENTO_HOST: magento2.test.com VIRTUAL_HOST: magento2.test.com COMPOSER_MEMORY_LIMIT: -1 DEPLOY_SAMPLEDATA: + DONATION_ACCOUNT: ADMIN_USERNAME: ADMIN_PASSWORD: ADYEN_MERCHANT: @@ -51,7 +52,7 @@ services: MAGENTO_VERSION: depends_on: - db - - elastic + - opensearch volumes: - ../:/data/extensions/workdir - ./Makefile:/var/www/html/Makefile diff --git a/.github/scripts/e2e.sh b/.github/scripts/e2e.sh new file mode 100755 index 00000000..6fa23061 --- /dev/null +++ b/.github/scripts/e2e.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +# Base configuration and installation +set -euo pipefail +cd /tmp +git clone https://github.com/Adyen/adyen-integration-tools-tests.git +cd adyen-integration-tools-tests +git checkout $INTEGRATION_TESTS_BRANCH +rm -rf package-lock.json +npm i +npx playwright install + +option="$1" + +# Run the desired group of tests +case $option in + "standard") + echo "Running Standard Set of E2E Tests." + npm run test:ci:magento + ;; + "express-checkout") + echo "Running Express Checkout E2E Tests." + npm run test:ci:magento:express-checkout + ;; + "all") + echo "Running All Magento E2E Tests" + npm run test:ci:magento:all + ;; +esac diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index e0f9ca1b..de2b8bb7 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -1,17 +1,71 @@ name: Adyen Magento 2 Express Checkout Plugin E2E Trigger Workflow -run-name: Headless E2E tests for ${{ github.event.pull_request.head.ref}} +run-name: Headless E2E tests for ${{ github.event.pull_request.head.ref }} on: pull_request: - types: [opened, synchronize] - branches: [main, develop] + branches: [main] jobs: - test: - runs-on: ubuntu-latest - if: ${{ github.actor != 'renovate[bot]' || github.actor != 'lgtm-com[bot]' }} + build: + strategy: + matrix: + php-version: ["8.3"] + magento-version: ["2.4.7-p2"] + runs-on: + group: larger-runners + labels: ubuntu-latest-8-cores + timeout-minutes: 25 env: - GITHUB_TOKEN: ${{ secrets.ADYEN_AUTOMATION_BOT_TEST_ACCESS_TOKEN }} + PHP_VERSION: ${{ matrix.php-version }} + MAGENTO_VERSION: ${{ matrix.magento-version }} + ADYEN_API_KEY: ${{secrets.ADYEN_API_KEY}} + ADYEN_CLIENT_KEY: ${{secrets.ADYEN_CLIENT_KEY}} + ADYEN_MERCHANT: ${{secrets.ADYEN_MERCHANT}} + DEPLOY_SAMPLEDATA: 1 steps: - - name: Run E2E Tests - run: gh workflow run e2e-test-dispatch.yml -R Adyen/adyen-magento2 -F expressBranch=${{ github.event.pull_request.head.ref }} -F testGroup="express-checkout" + - uses: actions/checkout@v4 + + - name: Install Magento + run: docker compose -f .github/docker-compose.yml run --rm web make magento + + - name: Start web server in background + run: docker compose -f .github/docker-compose.yml up -d web + + - name: Setup permissions + run: docker exec magento2-container make fs + + - name: Check install + run: docker exec magento2-container make sys-check + + - name: Install plugin + run: docker exec -u www-data magento2-container make plugin + + - name: Kill Cron Jobs + run: docker exec magento2-container /etc/init.d/cron stop + + - name: Switch to production mode + run: docker exec -u www-data magento2-container make production + + - name: Setup permissions + run: docker exec magento2-container make fs + + - name: Run E2E tests + run: docker compose -f .github/docker-compose.e2e.yml run --rm playwright /e2e.sh express-checkout + env: + INTEGRATION_TESTS_BRANCH: ${{ env.TEST_BRANCH }} + MAGENTO_ADMIN_USERNAME: ${{secrets.MAGENTO_ADMIN_USERNAME}} + MAGENTO_ADMIN_PASSWORD: ${{secrets.MAGENTO_ADMIN_PASSWORD}} + MAGENTO_BASE_URL: ${{secrets.MAGENTO_BASE_URL}} + PAYPAL_USERNAME: ${{secrets.PLAYWRIGHT_PAYPAL_USERNAME}} + PAYPAL_PASSWORD: ${{secrets.PLAYWRIGHT_PAYPAL_PASSWORD}} + GOOGLE_USERNAME: ${{secrets.PLAYWRIGHT_GOOGLE_USERNAME}} + GOOGLE_PASSWORD: ${{secrets.PLAYWRIGHT_GOOGLE_PASSWORD}} + WEBHOOK_USERNAME: admin + WEBHOOK_PASSWORD: 1234 + + - name: Archive test result artifacts + if: always() + uses: actions/upload-artifact@v3 + with: + name: html-report + path: test-report From ea04eebf91adc887035f70f754b8e78fdee9a16c Mon Sep 17 00:00:00 2001 From: Can Demiralp Date: Fri, 1 Nov 2024 15:33:38 +0100 Subject: [PATCH 2/8] Use free Ubuntu runners --- .github/workflows/e2e.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index de2b8bb7..a5cc6124 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -10,10 +10,8 @@ jobs: strategy: matrix: php-version: ["8.3"] - magento-version: ["2.4.7-p2"] - runs-on: - group: larger-runners - labels: ubuntu-latest-8-cores + magento-version: ["2.4.6-p8"] + runs-on: ubuntu-latest timeout-minutes: 25 env: PHP_VERSION: ${{ matrix.php-version }} From e9615f81e742d4e0b2b3e489a40741cfec9f204d Mon Sep 17 00:00:00 2001 From: Can Demiralp Date: Fri, 1 Nov 2024 15:33:48 +0100 Subject: [PATCH 3/8] Migrate to Open Search --- .github/Dockerfile | 8 ++++---- .github/scripts/install_magento.sh | 24 ++++++++++-------------- .github/workflows/graphql-test.yml | 4 ++-- 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/.github/Dockerfile b/.github/Dockerfile index 8170eec1..4b181e87 100644 --- a/.github/Dockerfile +++ b/.github/Dockerfile @@ -9,10 +9,10 @@ DB_NAME=magento \ DB_USER=magento \ DB_PASSWORD=magento \ DB_PREFIX=m2_ \ -ELASTICSEARCH_SERVER="" \ -ELASTICSEARCH_PORT=9200 \ -ELASTICSEARCH_INDEX_PREFIX=magento2 \ -ELASTICSEARCH_TIMEOUT=15 \ +OPENSEARCH_SERVER="" \ +OPENSEARCH_PORT=9200 \ +OPENSEARCH_INDEX_PREFIX=magento2 \ +OPENSEARCH_TIMEOUT=15 \ ADMIN_NAME=admin \ ADMIN_LASTNAME=admin \ ADMIN_EMAIL=admin@example.com \ diff --git a/.github/scripts/install_magento.sh b/.github/scripts/install_magento.sh index 7daeb32f..ad81930b 100644 --- a/.github/scripts/install_magento.sh +++ b/.github/scripts/install_magento.sh @@ -20,29 +20,25 @@ else exit 1 fi -USE_ELASTICSEARCH='1' -if [[ "$MAGENTO_VERSION" =~ ^2\.3 ]]; then - USE_ELASTICSEARCH='0' -fi - -if [ "$USE_ELASTICSEARCH" == '1' ] && [ "$ELASTICSEARCH_SERVER" != "" ]; then +if [ "$OPENSEARCH_SERVER" != "" ]; then MAGENTO_INSTALL_ARGS=$(echo \ - --elasticsearch-host="$ELASTICSEARCH_SERVER" \ - --elasticsearch-port="$ELASTICSEARCH_PORT" \ - --elasticsearch-index-prefix="$ELASTICSEARCH_INDEX_PREFIX" \ - --elasticsearch-timeout="$ELASTICSEARCH_TIMEOUT") + --search-engine="opensearch" \ + --opensearch-host="$OPENSEARCH_SERVER" \ + --opensearch-port="$OPENSEARCH_PORT" \ + --opensearch-index-prefix="$OPENSEARCH_INDEX_PREFIX" \ + --opensearch-timeout="$OPENSEARCH_TIMEOUT") RET=1 while [ $RET -ne 0 ]; do - echo "Checking if $ELASTICSEARCH_SERVER is available." - curl -XGET "$ELASTICSEARCH_SERVER:$ELASTICSEARCH_PORT/_cat/health?v&pretty" >/dev/null 2>&1 + echo "Checking if $OPENSEARCH_SERVER is available." + curl -XGET "$OPENSEARCH_SERVER:$OPENSEARCH_PORT/_cat/health?v&pretty" >/dev/null 2>&1 RET=$? if [ $RET -ne 0 ]; then - echo "Connection to Elasticsearch is pending." + echo "Connection to OpenSearch is pending." sleep 5 fi done - echo "Elasticsearch server $ELASTICSEARCH_SERVER is available." + echo "OpenSearch server $OPENSEARCH_SERVER is available." fi if [[ -e /tmp/magento.tar.gz ]]; then diff --git a/.github/workflows/graphql-test.yml b/.github/workflows/graphql-test.yml index 8ffc8010..5b78e29f 100644 --- a/.github/workflows/graphql-test.yml +++ b/.github/workflows/graphql-test.yml @@ -6,8 +6,8 @@ jobs: build: strategy: matrix: - php-version: ["8.1"] - magento-version: ["2.4.5"] + php-version: [ "8.3" ] + magento-version: [ "2.4.6-p8" ] runs-on: ubuntu-latest env: PHP_VERSION: ${{ matrix.php-version }} From e2926a6df06c0427c3bc31712091150a0b9b381e Mon Sep 17 00:00:00 2001 From: Can Demiralp Date: Fri, 1 Nov 2024 15:39:07 +0100 Subject: [PATCH 4/8] Downgrade to PHP 8.2 --- .github/workflows/e2e.yml | 2 +- .github/workflows/graphql-test.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index a5cc6124..e6cc9ade 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -9,7 +9,7 @@ jobs: build: strategy: matrix: - php-version: ["8.3"] + php-version: ["8.2"] magento-version: ["2.4.6-p8"] runs-on: ubuntu-latest timeout-minutes: 25 diff --git a/.github/workflows/graphql-test.yml b/.github/workflows/graphql-test.yml index 5b78e29f..2d06971c 100644 --- a/.github/workflows/graphql-test.yml +++ b/.github/workflows/graphql-test.yml @@ -6,7 +6,7 @@ jobs: build: strategy: matrix: - php-version: [ "8.3" ] + php-version: [ "8.2" ] magento-version: [ "2.4.6-p8" ] runs-on: ubuntu-latest env: From e50ced8fdcb51c597c725eb8d92687cf15c8d1bd Mon Sep 17 00:00:00 2001 From: Can Demiralp Date: Wed, 6 Nov 2024 10:30:06 +0100 Subject: [PATCH 5/8] Switch to paid runners and set timeout --- .github/workflows/e2e.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index e6cc9ade..36b1151e 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -11,8 +11,10 @@ jobs: matrix: php-version: ["8.2"] magento-version: ["2.4.6-p8"] - runs-on: ubuntu-latest - timeout-minutes: 25 + runs-on: + group: larger-runners + labels: ubuntu-latest-8-cores + timeout-minutes: 10 env: PHP_VERSION: ${{ matrix.php-version }} MAGENTO_VERSION: ${{ matrix.magento-version }} From 19a02006705823af6185fd6eadd897f57c394bfa Mon Sep 17 00:00:00 2001 From: Can Demiralp Date: Wed, 6 Nov 2024 10:32:20 +0100 Subject: [PATCH 6/8] Rename the workflow --- .github/workflows/e2e.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 36b1151e..04982f51 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -1,4 +1,4 @@ -name: Adyen Magento 2 Express Checkout Plugin E2E Trigger Workflow +name: E2E test workflow run-name: Headless E2E tests for ${{ github.event.pull_request.head.ref }} on: From 63d919432bf4277431221a2a1083031e000a852a Mon Sep 17 00:00:00 2001 From: Can Demiralp Date: Wed, 6 Nov 2024 10:49:51 +0100 Subject: [PATCH 7/8] Update environment variables --- .github/docker-compose.e2e.yml | 3 +++ .github/workflows/e2e.yml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/.github/docker-compose.e2e.yml b/.github/docker-compose.e2e.yml index f5f51a86..d9cea1b6 100644 --- a/.github/docker-compose.e2e.yml +++ b/.github/docker-compose.e2e.yml @@ -20,8 +20,11 @@ services: - ADYEN_MERCHANT - GOOGLE_USERNAME - GOOGLE_PASSWORD + - AMAZON_USERNAME + - AMAZON_PASSWORD - WEBHOOK_USERNAME - WEBHOOK_PASSWORD + - CI volumes: - ./scripts/e2e.sh:/e2e.sh - ../test-report:/tmp/test-report diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 04982f51..8e25dfbb 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -60,8 +60,11 @@ jobs: PAYPAL_PASSWORD: ${{secrets.PLAYWRIGHT_PAYPAL_PASSWORD}} GOOGLE_USERNAME: ${{secrets.PLAYWRIGHT_GOOGLE_USERNAME}} GOOGLE_PASSWORD: ${{secrets.PLAYWRIGHT_GOOGLE_PASSWORD}} + AMAZON_USERNAME: ${{secrets.AMAZON_USERNAME}} + AMAZON_PASSWORD: ${{secrets.AMAZON_PASSWORD}} WEBHOOK_USERNAME: admin WEBHOOK_PASSWORD: 1234 + CI: TRUE - name: Archive test result artifacts if: always() From 25f996d33b0d41551218bc58c1275dab484f4093 Mon Sep 17 00:00:00 2001 From: Can Demiralp Date: Wed, 6 Nov 2024 10:51:02 +0100 Subject: [PATCH 8/8] Remove irrelevant env variable --- .github/docker-compose.e2e.yml | 2 -- .github/workflows/e2e.yml | 2 -- 2 files changed, 4 deletions(-) diff --git a/.github/docker-compose.e2e.yml b/.github/docker-compose.e2e.yml index d9cea1b6..0b5d1722 100644 --- a/.github/docker-compose.e2e.yml +++ b/.github/docker-compose.e2e.yml @@ -20,8 +20,6 @@ services: - ADYEN_MERCHANT - GOOGLE_USERNAME - GOOGLE_PASSWORD - - AMAZON_USERNAME - - AMAZON_PASSWORD - WEBHOOK_USERNAME - WEBHOOK_PASSWORD - CI diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 8e25dfbb..c3fd85f5 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -60,8 +60,6 @@ jobs: PAYPAL_PASSWORD: ${{secrets.PLAYWRIGHT_PAYPAL_PASSWORD}} GOOGLE_USERNAME: ${{secrets.PLAYWRIGHT_GOOGLE_USERNAME}} GOOGLE_PASSWORD: ${{secrets.PLAYWRIGHT_GOOGLE_PASSWORD}} - AMAZON_USERNAME: ${{secrets.AMAZON_USERNAME}} - AMAZON_PASSWORD: ${{secrets.AMAZON_PASSWORD}} WEBHOOK_USERNAME: admin WEBHOOK_PASSWORD: 1234 CI: TRUE