diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml new file mode 100644 index 0000000..22c479d --- /dev/null +++ b/.github/workflows/e2e.yaml @@ -0,0 +1,72 @@ +name: E2E Tests Workflow +on: + pull_request: + schedule: + - cron: '0 8 * * *' + workflow_dispatch: + inputs: + rvvupHyvaCheckoutVersion: + description: 'Rvvup Hyva Checkout Version' + required: true + default: 'dev-main' +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true +jobs: + end-2-end-tests: + strategy: + matrix: + include: + - MAGENTO_VERSION: 2.4.5 + - MAGENTO_VERSION: 2.4.6 + - MAGENTO_VERSION: 2.4.7 + + env: + MAGENTO_VERSION: ${{ matrix.MAGENTO_VERSION }} + RVVUP_HYVA_CHECKOUT_VERSION: ${{ github.event.inputs.rvvupHyvaCheckoutVersion || format('dev-{0}', github.head_ref || github.ref_name) }} + MAGENTO_REPO_PUBLIC_KEY: ${{ secrets.REPO_PUB_KEY }} + MAGENTO_REPO_PRIVATE_KEY: ${{ secrets.REPO_SEC_KEY }} + RVVUP_API_KEY: ${{ secrets.RVVUP_API_KEY }} + HYVA_SSH_PRIVATE_KEY: ${{ secrets.HYVA_SSH_PRIVATE_KEY }} + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Start Docker + run: | + docker compose up -d --build + + - name: Install dependencies + run: npm install + - name: Install Playwright Browsers + run: npx playwright install --with-deps + + - name: Wait for Magento Store + uses: mydea/action-wait-for-api@v1.0.0 + with: + url: http://local.dev.rvvuptech.com:89/magento_version + method: GET + expected-status: "200" + timeout: "500" + interval: "5" + + - name: Run Playwright tests + run: TEST_BASE_URL=http://local.dev.rvvuptech.com:89 npx playwright test + + - name: Prepare logs + if: always() + run: | + mkdir -p logs + docker-compose logs > logs/container_logs.log + docker cp magento-hyva-checkout-magento-1:/bitnami/magento/var/log logs + - uses: actions/upload-artifact@v4 + if: always() + with: + name: results-${{ matrix.MAGENTO_VERSION }}-${{ github.run_number }} + path: | + playwright-report/ + var/log/ + magento.log + nginx-proxy.log + diff --git a/docker-compose.yml b/docker-compose.yml index 5a763cf..d91bcc7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,11 +10,10 @@ services: - 'rvvup_hyva_data_mariadb:/bitnami/mariadb' magento: ports: - - '80:8080' - - '443:8443' + - '89:8080' + - '8443:8443' environment: - BITNAMI_DEBUG=true - - MAGENTO_HOST=localhost - MAGENTO_DATABASE_HOST=mariadb - MAGENTO_DATABASE_PORT_NUMBER=3306 - MAGENTO_DATABASE_USER=bn_magento @@ -23,7 +22,7 @@ services: - ELASTICSEARCH_PORT_NUMBER=9200 # ALLOW_EMPTY_PASSWORD is recommended only for development. - ALLOW_EMPTY_PASSWORD=yes - - MAGENTO_HOST=local.dev.rvvuptech.com + - MAGENTO_HOST=local.dev.rvvuptech.com:89 - MAGENTO_USERNAME=admin - MAGENTO_PASSWORD=password1 - MAGENTO_EMAIL=admin@test.com @@ -32,6 +31,8 @@ services: - MAGENTO_REPO_PUBLIC_KEY=$MAGENTO_REPO_PUBLIC_KEY - MAGENTO_REPO_PRIVATE_KEY=$MAGENTO_REPO_PRIVATE_KEY - HYVA_SSH_PRIVATE_KEY=$HYVA_SSH_PRIVATE_KEY + - MAGENTO_SMTP_HOST=mailpit + - MAGENTO_SMTP_PORT=1025 build: context: . dockerfile: Dockerfile @@ -44,6 +45,10 @@ services: image: docker.io/bitnami/elasticsearch:7 volumes: - 'rvvup_hyva_elasticsearch_data:/bitnami/elasticsearch/data' + mailpit: + image: docker.io/axllent/mailpit:v1.18 + ports: + - '9925:8025' volumes: rvvup_hyva_data_mariadb: driver: local diff --git a/docker/scripts/configure-base-store.sh b/docker/scripts/configure-base-store.sh index 6c25b6b..234200c 100755 --- a/docker/scripts/configure-base-store.sh +++ b/docker/scripts/configure-base-store.sh @@ -9,4 +9,13 @@ bin/magento config:set currency/options/default GBP bin/magento config:set general/locale/timezone Europe/London bin/magento config:set general/locale/code en_GB bin/magento sampledata:deploy + +echo "Configuring SMTP settings to point to $MAGENTO_SMTP_HOST:$MAGENTO_SMTP_PORT" +bin/magento config:set system/smtp/disable 0 +bin/magento config:set system/smtp/transport smtp +bin/magento config:set system/smtp/host $MAGENTO_SMTP_HOST +bin/magento config:set system/smtp/port $MAGENTO_SMTP_PORT + +bin/magento sampledata:deploy + composer require n98/magerun2-dist \ No newline at end of file diff --git a/run-e2e-tests.sh b/run-e2e-tests.sh index 2059952..b489e34 100755 --- a/run-e2e-tests.sh +++ b/run-e2e-tests.sh @@ -3,7 +3,7 @@ start=$(date +%s) docker compose up -d --build attempt=1 while true; do - http_status=$(curl -o /dev/null -s -w "%{http_code}\n" -I "http://local.dev.rvvuptech.com/magento_version") + http_status=$(curl -o /dev/null -s -w "%{http_code}\n" -I "http://local.dev.rvvuptech.com:89/magento_version") if [ "$http_status" -eq 200 ]; then echo -e "\rServer responded with 200 OK / Time taken: $(($(date +%s) - start)) seconds, continuing..." @@ -16,7 +16,7 @@ while true; do done if [ "$1" == "--ui" ]; then - ENV TEST_BASE_URL=http://local.dev.rvvuptech.com npx playwright test --ui + ENV TEST_BASE_URL=http://local.dev.rvvuptech.com:89 npx playwright test --ui else - ENV TEST_BASE_URL=http://local.dev.rvvuptech.com npx playwright test + ENV TEST_BASE_URL=http://local.dev.rvvuptech.com:89 npx playwright test fi