Skip to content

Commit

Permalink
Trigger E2E test on the repository workflows and start using Open Sea…
Browse files Browse the repository at this point in the history
…rch (#139)

* Install Magento and trigger E2E test on the repository

* Use free Ubuntu runners

* Migrate to Open Search

* Downgrade to PHP 8.2

* Switch to paid runners and set timeout

* Rename the workflow

* Update environment variables

* Remove irrelevant env variable

---------

Co-authored-by: Can Demiralp <[email protected]>
  • Loading branch information
candemiralp and Can Demiralp authored Nov 6, 2024
1 parent 6093b6c commit 76566d5
Show file tree
Hide file tree
Showing 8 changed files with 150 additions and 35 deletions.
8 changes: 4 additions & 4 deletions .github/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ DB_NAME=magento \
DB_USER=magento \
DB_PASSWORD=magento \
DB_PREFIX=m2_ \
ELASTICSEARCH_SERVER="<will be defined>" \
ELASTICSEARCH_PORT=9200 \
ELASTICSEARCH_INDEX_PREFIX=magento2 \
ELASTICSEARCH_TIMEOUT=15 \
OPENSEARCH_SERVER="<will be defined>" \
OPENSEARCH_PORT=9200 \
OPENSEARCH_INDEX_PREFIX=magento2 \
OPENSEARCH_TIMEOUT=15 \
ADMIN_NAME=admin \
ADMIN_LASTNAME=admin \
[email protected] \
Expand Down
4 changes: 4 additions & 0 deletions .github/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 {} +
Expand Down
30 changes: 30 additions & 0 deletions .github/docker-compose.e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
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
- CI
volumes:
- ./scripts/e2e.sh:/e2e.sh
- ../test-report:/tmp/test-report
networks:
backend:
11 changes: 6 additions & 5 deletions .github/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -51,7 +52,7 @@ services:
MAGENTO_VERSION:
depends_on:
- db
- elastic
- opensearch
volumes:
- ../:/data/extensions/workdir
- ./Makefile:/var/www/html/Makefile
Expand Down
29 changes: 29 additions & 0 deletions .github/scripts/e2e.sh
Original file line number Diff line number Diff line change
@@ -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
24 changes: 10 additions & 14 deletions .github/scripts/install_magento.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" != "<will be defined>" ]; then
if [ "$OPENSEARCH_SERVER" != "<will be defined>" ]; 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
Expand Down
75 changes: 65 additions & 10 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,72 @@
name: Adyen Magento 2 Express Checkout Plugin E2E Trigger Workflow
run-name: Headless E2E tests for ${{ github.event.pull_request.head.ref}}
name: E2E test workflow
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.2"]
magento-version: ["2.4.6-p8"]
runs-on:
group: larger-runners
labels: ubuntu-latest-8-cores
timeout-minutes: 10
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
CI: TRUE

- name: Archive test result artifacts
if: always()
uses: actions/upload-artifact@v3
with:
name: html-report
path: test-report
4 changes: 2 additions & 2 deletions .github/workflows/graphql-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ jobs:
build:
strategy:
matrix:
php-version: ["8.1"]
magento-version: ["2.4.5"]
php-version: [ "8.2" ]
magento-version: [ "2.4.6-p8" ]
runs-on: ubuntu-latest
env:
PHP_VERSION: ${{ matrix.php-version }}
Expand Down

0 comments on commit 76566d5

Please sign in to comment.