Skip to content

Commit

Permalink
Manual run for playwright e2e (#4579)
Browse files Browse the repository at this point in the history
* Manual trigger, composite actions

* Manual trigger, composite actions

* Manual trigger, composite actions

* release mode

* release mode

* release mode

* release mode

* release mode

* main mode

* main mode

* main mode

* main mode

* main mode

* main mode

* main mode, full test

* main mode, full test

* main mode, full test

* main mode, full test

* main mode, full test

* Fix base url

* Fix base url

* Fix base url

* Fix base url

* Fix base url

* Automation test

* Automation test

* Automation test

* Automation test

* Release test

* Release test

* Release test

* Release test

* Release test

* Release test

* Release test

* Release test

* Release test

* Release test
  • Loading branch information
andrzejewsky committed Jan 4, 2024
1 parent 488a4b4 commit b606c3e
Show file tree
Hide file tree
Showing 13 changed files with 451 additions and 20 deletions.
5 changes: 5 additions & 0 deletions .changeset/poor-ducks-mate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": patch
---

Add manual test run for e2e
30 changes: 30 additions & 0 deletions .github/actions/merge-pw-reports/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Merge playwright reports
description: Merge reports from all shards

runs:
using: "composite"
steps:
- uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"

- name: Install dependencies
shell: bash
run: npm ci

- name: Download blob reports from GitHub Actions Artifacts
uses: actions/download-artifact@v3
with:
name: all-blob-reports
path: all-blob-reports

- name: Merge into HTML Report
shell: bash
run: npx playwright merge-reports --reporter html ./all-blob-reports

- name: Upload HTML report
uses: actions/upload-artifact@v3
with:
name: html-report--attempt-${{ github.run_attempt }}
path: playwright-report
retention-days: 14
73 changes: 73 additions & 0 deletions .github/actions/prepare-api-variables/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Prepare api variables
description: Prepare env config for cloud

inputs:
MODE:
description: "The mode of running tests (pull-request, release, main)"
required: true

outputs:
BASE_URL:
description: "Dashboard base url"
value: ${{ steps.generate.outputs.BASE_URL }}
API_URL:
description: "API url"
value: ${{ steps.generate.outputs.API_URL }}
POOL_NAME:
description: "The name of the instance"
value: ${{ steps.generate.outputs.POOL_NAME }}
POOL_INSTANCE:
description: "The full URL of the instance"
value: ${{ steps.generate.outputs.POOL_INSTANCE }}
BACKUP_NAMESPACE:
description: "The backup namespace"
value: ${{ steps.generate.outputs.BACKUP_NAMESPACE }}

runs:
using: "composite"
steps:
- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@102b1a064a9b145e56556e22b18b19c624538d94

- name: Generate
id: generate
shell: bash
env:
MODE: ${{ inputs.MODE }}
PREFIX: pr-
run: |
if [[ "$MODE" == 'pull-request' ]]; then
echo "BASE_URL=${PREFIX}${GITHUB_HEAD_REF_SLUG_URL}.dashboard.saleor.rocks" >> $GITHUB_OUTPUT
echo "API_URL=https://${PREFIX}${GITHUB_HEAD_REF_SLUG_URL}.staging.saleor.cloud/graphql/" >> $GITHUB_OUTPUT
echo "POOL_NAME=${PREFIX}${GITHUB_HEAD_REF_SLUG_URL}" >> $GITHUB_OUTPUT
echo "POOL_INSTANCE=https://${PREFIX}${GITHUB_HEAD_REF_SLUG_URL}.staging.saleor.cloud" >> $GITHUB_OUTPUT
echo "BACKUP_NAMESPACE=snapshot-automation-tests" >> $GITHUB_OUTPUT
exit 0
fi
if [[ "$MODE" == 'release' ]]; then
VERSION_SLUG=$(echo "${GITHUB_REF_SLUG}" | sed "s/\.//")
echo "BASE_URL=https://v${VERSION_SLUG}.staging.saleor.cloud/dashboard/" >> $GITHUB_OUTPUT
echo "API_URL=https://v${VERSION_SLUG}.staging.saleor.cloud/graphql/" >> $GITHUB_OUTPUT
echo "POOL_NAME=${GITHUB_REF_SLUG} Staging" >> $GITHUB_OUTPUT
echo "POOL_INSTANCE=https://v${VERSION_SLUG}.staging.saleor.cloud/" >> $GITHUB_OUTPUT
echo "BACKUP_NAMESPACE=snapshot-automation-tests-${GITHUB_REF_SLUG}" >> $GITHUB_OUTPUT
exit 0
fi
if [[ "$MODE" == 'main' ]]; then
echo "BASE_URL=https://automation-dashboard.staging.saleor.cloud/dashboard/" >> $GITHUB_OUTPUT
echo "API_URL=https://automation-dashboard.staging.saleor.cloud/graphql/" >> $GITHUB_OUTPUT
echo "POOL_NAME=automation-dashboard" >> $GITHUB_OUTPUT
echo "POOL_INSTANCE=https://automation-dashboard.staging.saleor.cloud" >> $GITHUB_OUTPUT
echo "BACKUP_NAMESPACE=snapshot-automation-tests" >> $GITHUB_OUTPUT
exit 0
fi
echo "Unknown mode: $MODE" >&2
exit 1
42 changes: 42 additions & 0 deletions .github/actions/prepare-backups-variables/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Prepare backup variables
description: Prepare database snapshots
inputs:
CLI_TOKEN:
description: "Saleor cli token"
required: true
BACKUP_NAMESPACE:
description: "The backups namespace"
required: true
outputs:
BACKUP_ID:
description: "The ID of backup"
value: ${{ steps.backup.outputs.BACKUP_ID }}
BACKUP_VER:
description: "The version of backup"
value: ${{ steps.backup.outputs.BACKUP_VER }}
BACKUP_NAME:
description: "The name of backup"
value: ${{ steps.backup.outputs.BACKUP_NAME }}
runs:
using: "composite"
steps:
- name: Saleor login
uses: ./.github/actions/cli-login
with:
token: ${{ inputs.CLI_TOKEN }}

- name: Obtain backup id
id: backup
shell: bash
env:
SALEOR_CLI_ENV: staging
BACKUP_NAME: ${{ inputs.BACKUP_NAMESPACE }}
run: |
BACKUPS=$(npx saleor backup list --name="$BACKUP_NAME" --latest --json)
BACKUP_ID=$(echo "$BACKUPS" | jq -r '.[0].key')
BACKUP_VER=$(echo "$BACKUPS" | jq -r '.[0].saleor_version')
BACKUP_NAME=$(echo "$BACKUPS" | jq -r '.[0].name')
echo "BACKUP_ID=$BACKUP_ID" >> $GITHUB_OUTPUT
echo "BACKUP_VER=$BACKUP_VER" >> $GITHUB_OUTPUT
echo "BACKUP_NAME=$BACKUP_NAME" >> $GITHUB_OUTPUT
73 changes: 73 additions & 0 deletions .github/actions/prepare-instance/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Prepare instance
description: Prepare cloud instance for testing
inputs:
STRATEGY:
description: "How to create the new instance (create|reload)"
required: false
default: "create"
CLI_TOKEN:
description: "Saleor cli token"
required: true
BASE_URL:
description: "Dashboard base url"
required: true
API_URL:
description: "API url"
required: true
POOL_NAME:
description: "The name of the instance"
required: true
POOL_INSTANCE:
description: "The full URL of the instance"
required: true
BACKUP_ID:
description: "The id of backup"
required: true
runs:
using: "composite"
steps:
- name: Saleor login
uses: ./.github/actions/cli-login
with:
token: ${{ inputs.CLI_TOKEN }}

- name: Instance check
if: ${{ inputs.STRATEGY == 'reload' }}
shell: bash
id: instance_check
env:
SALEOR_CLI_ENV: staging
INSTANCE_NAME: ${{ inputs.POOL_NAME }}
run: |
set +o pipefail
INSTANCE_KEY=$(npx saleor env show "$INSTANCE_NAME" --json | jq .key)
echo "INSTANCE_KEY=$INSTANCE_KEY" >> $GITHUB_OUTPUT
- name: Reload snapshot
shell: bash
if: ${{ steps.instance_check.outputs.INSTANCE_KEY }}
env:
SALEOR_CLI_ENV: staging
BACKUP_ID: ${{ inputs.BACKUP_ID }}
INSTANCE_NAME: ${{ inputs.POOL_NAME }}
run: |
npx saleor backup restore "$BACKUP_ID" \
--environment="$INSTANCE_NAME" \
--skip-webhooks-update
- name: Create new instance
shell: bash
if: ${{ !steps.instance_check.outputs.INSTANCE_KEY }}
env:
SALEOR_CLI_ENV: staging
BACKUP_ID: ${{ inputs.BACKUP_ID }}
INSTANCE_NAME: ${{ inputs.POOL_NAME }}
run: |
npx saleor env create "$INSTANCE_NAME" \
--project=project-for-pr-testing \
--database=snapshot \
--restore-from="$BACKUP_ID" \
--saleor=saleor-master-staging \
--domain="$INSTANCE_NAME" \
--skip-restrict \
--skip-webhooks-update
68 changes: 68 additions & 0 deletions .github/actions/prepare-tests-variables/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Prepare tests variables
description: Prepare database snapshots
inputs:
MODE:
description: "The mode of running tests (pull-request, release, main)"
required: true
CLI_TOKEN:
description: "Saleor cli token"
required: true
outputs:
BASE_URL:
description: "Dashboard base url"
value: ${{ steps.api.outputs.BASE_URL }}
API_URL:
description: "API url"
value: ${{ steps.api.outputs.API_URL }}
POOL_NAME:
description: "The name of the instance"
value: ${{ steps.api.outputs.POOL_NAME }}
POOL_INSTANCE:
description: "The full URL of the instance"
value: ${{ steps.api.outputs.POOL_INSTANCE }}
BACKUP_ID:
description: "The ID of backup"
value: ${{ steps.backup.outputs.BACKUP_ID }}
BACKUP_VER:
description: "The version of backup"
value: ${{ steps.backup.outputs.BACKUP_VER }}
BACKUP_NAME:
description: "The name of backup"
value: ${{ steps.backup.outputs.BACKUP_NAME }}
BACKUP_NAMESPACE:
description: "The name of backup"
value: ${{ steps.api.outputs.BACKUP_NAMESPACE }}
runs:
using: "composite"
steps:
- name: Generate api
id: api
uses: ./.github/actions/prepare-api-variables
with:
MODE: ${{ inputs.MODE }}

- name: Generate backup
id: backup
uses: ./.github/actions/prepare-backups-variables
with:
CLI_TOKEN: ${{ inputs.CLI_TOKEN }}
BACKUP_NAMESPACE: ${{ steps.api.outputs.BACKUP_NAMESPACE }}

- name: Print annotations
shell: bash
env:
BASE_URL: ${{ steps.api.outputs.BASE_URL }}
API_URL: ${{ steps.api.outputs.API_URL }}
POOL_NAME: ${{ steps.api.outputs.POOL_NAME }}
POOL_INSTANCE: ${{ steps.api.outputs.POOL_INSTANCE }}
BACKUP_ID: ${{ steps.backup.outputs.BACKUP_ID }}
BACKUP_VER: ${{ steps.backup.outputs.BACKUP_VER }}
BACKUP_NAME: ${{ steps.backup.outputs.BACKUP_NAME }}
BACKUP_NAMESPACE: ${{ steps.api.outputs.BACKUP_NAMESPACE }}
run: |
echo "::notice title=BASE_URL::${BASE_URL}"
echo "::notice title=API_URL::${API_URL}"
echo "::notice title=POOL_NAME::${POOL_NAME}"
echo "::notice title=POOL_INSTANCE::${POOL_INSTANCE}"
echo "::notice title=BACKUP_NAMESPACE::${BACKUP_NAMESPACE}"
echo "::notice title=SNAPSHOT::backup_id=${BACKUP_ID}, version=${BACKUP_VER}, name=${BACKUP_NAME}"
54 changes: 54 additions & 0 deletions .github/actions/run-pw-tests/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Run Playwright tests
description: Run e2e tests using Playwright
inputs:
BASE_URL:
description: "Dashboard base url"
required: true
API_URL:
description: "API url"
required: true
E2E_USER_NAME:
description: "Username for e2e tests"
required: true
E2E_USER_PASSWORD:
description: "Password for e2e tests"
required: true
E2E_PERMISSIONS_USERS_PASSWORD:
description: "Permissions user password for e2e tests"
required: true
SHARD:
description: "Shard number"
required: true
runs:
using: "composite"
steps:
- uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"

- name: Install dependencies
shell: bash
run: npm ci

- name: Install Playwright Browsers
shell: bash
run: npx playwright install --with-deps

- name: Run tests
shell: bash
env:
API_URI: ${{ inputs.API_URL }}
BASE_URL: ${{ inputs.BASE_URL }}
E2E_USER_NAME: ${{ inputs.E2E_USER_NAME }}
E2E_USER_PASSWORD: ${{ inputs.E2E_USER_PASSWORD }}
E2E_PERMISSIONS_USERS_PASSWORD: ${{ inputs.E2E_PERMISSIONS_USERS_PASSWORD }}
SHARD_NUMBER: ${{ inputs.SHARD }}
run: npm run qa:pw-e2e -- --shard "$SHARD_NUMBER"

- name: Upload blob report to GitHub Actions Artifacts
uses: actions/upload-artifact@v3
if: always()
with:
name: all-blob-reports
path: blob-report
retention-days: 1
Loading

0 comments on commit b606c3e

Please sign in to comment.