Skip to content

Commit

Permalink
accept param in ddev-share to avoid waiting
Browse files Browse the repository at this point in the history
export BASEURL to env variable instead of writing in file
remove unneeded exclude
  • Loading branch information
mmaymo committed Jan 25, 2023
1 parent 95fab31 commit 2bafe33
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 36 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ jobs:
matrix:
php-versions: [ '7.4' ]
wc-versions: [ '5.9.5' ]
exclude:
- php-versions: 7.2
wc-versions: 7.1.0

name: PHP ${{ matrix.php-versions }} WC ${{ matrix.wc-versions }}
steps:
Expand Down Expand Up @@ -43,14 +40,15 @@ jobs:
- name: Add ngrok Authtoken
run: ngrok config add-authtoken ${{ secrets.NGROK_AUTHTOKEN1 }}_${{ secrets.NGROK_AUTHTOKEN2 }}
- name: Run Ngrok
run: bin/ddev-share-e2e
run: bin/ddev-share --ci
- name: Run Playwright tests
run: npx playwright test TestCI.spec.js
env:
E2E_AUTH_USERNAME: ${{ secrets.E2E_AUTH_USERNAME }}
E2E_AUTH_PW: ${{ secrets.E2E_AUTH_PW }}
MOLLIE_LIVE_API_KEY: ${{ secrets.MOLLIE_LIVE_API_KEY }}
MOLLIE_TEST_API_KEY: ${{ secrets.MOLLIE_TEST_API_KEY }}
BASEURL: ${{ env.BASEURL }}
- uses: actions/upload-artifact@v2
if: always()
with:
Expand Down
19 changes: 14 additions & 5 deletions bin/ddev-share
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,22 @@ kill-ngrok(){
wp-replace "${NGROK_HOST}" "${PROJECT_HOST}"
}
echo "ngrok started with PID ${NGROK_PID}"

echo "Waiting a few seconds for the service to come up"
sleep 3
NGROK_HOST=$(ngrok-url)
wp-replace "${PROJECT_HOST}" "${NGROK_HOST}"
echo "export const baseUrl = 'https://${NGROK_HOST}';" > tests/e2e/Shared/base-url.js
echo "Your site is now reachable at https://${NGROK_HOST}"
echo "ctrl-c to stop sharing and revert database changes"
trap kill-ngrok INT
wait -f "${NGROK_PID}"

if [ -n "$1" ] && [ "$1" = "--ci" ]; then
echo "Running in CI mode"
#this sets the variable for the next step
export BASEURL="https://${NGROK_HOST}"
echo "BASEURL=$BASEURL" >> $GITHUB_ENV
else
echo "Running in local mode"
#this sets all variables at once, so we need to pass them all in
ddev config --web-environment="BASEURL=https://${NGROK_HOST}, WP_VERSION=6.1, WP_LOCALE=en_US, WP_TITLE=Mollie WordPress Test, PLUGIN_NAME=mollie-payments-for-woocommerce, ADMIN_USER=admin, ADMIN_PASS=admin, [email protected], WC_VERSION=7.2.2"
echo "ctrl-c to stop sharing and revert database changes"
trap kill-ngrok INT
wait -f "${NGROK_PID}"
fi
22 changes: 0 additions & 22 deletions bin/ddev-share-e2e

This file was deleted.

3 changes: 1 addition & 2 deletions playwright.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const { devices } = require('@playwright/test');
const {simple, virtual} = require('./tests/e2e/Shared/products');
const {banktransfer, paypal, creditcard} = require('./tests/e2e/Shared/gateways');
const baseURL = require('./tests/e2e/Shared/base-url');
/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
Expand Down Expand Up @@ -44,7 +43,7 @@ const config = {
/* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
actionTimeout: 0,
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL: baseURL.baseUrl,
baseURL: process.env.BASEURL,
storageState: './storageState.json',
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
Expand Down
3 changes: 0 additions & 3 deletions tests/e2e/Shared/base-url.js

This file was deleted.

0 comments on commit 2bafe33

Please sign in to comment.