Skip to content

Commit

Permalink
Login before tests (#5196) (#5244)
Browse files Browse the repository at this point in the history
* Login before tests (#5196)

* Login before tests

* Changeset

* Composite actions

* Composite actions

* Apply in other workflows

* Apply in other workflows

* Don't run export tests on PRs (#5206)

* Revert Don't run export tests on PRs (#5206) (#5208)

This reverts commit 3ec3cf3.

* Apply in other workflows

* Apply in other workflows

* Apply in other workflows

* Apply in other workflows

* Apply in other workflows

* Apply in other workflows

---------

Co-authored-by: Wojciech Mista <wojciech.mista@hotmail.com>

* Update workflows

* Update readonlyApps test to not include upcomming apps

---------

Co-authored-by: Patryk Andrzejewski <vox3r69@gmail.com>
Co-authored-by: Wojciech Mista <wojciech.mista@hotmail.com>
  • Loading branch information
3 people authored Nov 14, 2024
1 parent ebc71e1 commit bcabc89
Show file tree
Hide file tree
Showing 49 changed files with 595 additions and 113 deletions.
5 changes: 5 additions & 0 deletions .changeset/fuzzy-impalas-juggle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": patch
---

Now we login accounts before playwright jobs are being started. This means playwright shards only consume account files, skipping the authentication part, it avoids account suspending by the API due to multiple attempnts in the same time
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,5 @@
"@typescript-eslint/restrict-template-expressions": "off",
"react-refresh/only-export-components": "warn"
},
"ignorePatterns": ["node_modules/", "**/types/**/*", "type-policies.ts"]
"ignorePatterns": ["node_modules/", "**/types/**/*", "type-policies.ts", "playwright/auth.js"]
}
48 changes: 48 additions & 0 deletions .github/actions/prepare-accounts/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Prepare accounts
description: Prepare accounts that are used by 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
E2E_ENCODE_PASS:
description: "Password for encoding credentials"
required: true

outputs:
ACCOUNTS:
description: "Encrypted accounts"
value: ${{ steps.accounts.outputs.ACCOUNTS }}


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

- name: Prepare accounts
shell: bash
id: accounts
env:
BASE_URL: ${{ inputs.BASE_URL }}
API_URL: ${{ inputs.API_URL }}
E2E_USER_NAME: ${{ inputs.E2E_USER_NAME }}
E2E_USER_PASSWORD: ${{ inputs.E2E_USER_PASSWORD }}
E2E_ENCODE_PASS: ${{ inputs.E2E_ENCODE_PASS }}
E2E_PERMISSIONS_USERS_PASSWORD: ${{ inputs.E2E_PERMISSIONS_USERS_PASSWORD }}
run: |
ACCOUNTS=$(node playwright/auth.js login)
echo "ACCOUNTS=${ACCOUNTS}" >> "$GITHUB_OUTPUT"
32 changes: 32 additions & 0 deletions .github/actions/restore-accounts/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Restore accounts
description: Restore accounts to be consumed by Playwright
inputs:
ACCOUNTS:
description: "Accounts encrypted string"
required: true
E2E_ENCODE_PASS:
description: "Password for encoding credentials"
required: true
BASE_URL:
description: "Dashboard base url"
required: true
API_URL:
description: "API url"
required: true

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

- name: Restore accounts
shell: bash
env:
E2E_ENCODE_PASS: ${{ inputs.E2E_ENCODE_PASS }}
ACCOUNTS: ${{ inputs.ACCOUNTS }}
API_URL: ${{ inputs.API_URL }}
BASE_URL: ${{ inputs.BASE_URL }}
run: |
node playwright/auth.js restore "$ACCOUNTS"
16 changes: 15 additions & 1 deletion .github/actions/run-pw-tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ inputs:
PW_RETRIES:
description: "Playwright retries"
required: true
ACCOUNTS:
description: "Accounts hash"
required: true
E2E_ENCODE_PASS:
description: "Password for encoding credentials"
required: true

runs:
using: "composite"
Expand All @@ -43,6 +49,14 @@ runs:
shell: bash
run: npm ci

- name: Restore accounts
uses: ./.github/actions/restore-accounts
with:
BASE_URL: ${{ inputs.BASE_URL }}
API_URL: ${{ inputs.API_URL }}
ACCOUNTS: ${{ inputs.ACCOUNTS }}
E2E_ENCODE_PASS: ${{ inputs.E2E_ENCODE_PASS }}

- name: Install Playwright Browsers
shell: bash
run: npx playwright install --with-deps
Expand Down Expand Up @@ -71,4 +85,4 @@ runs:
with:
name: all-blob-reports
path: blob-report
retention-days: 1
retention-days: 1
20 changes: 18 additions & 2 deletions .github/workflows/pr-automation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
inputs:
shards:
type: number
description: 'Number of shards to use for parallel testing'
description: "Number of shards to use for parallel testing"
required: false
default: 2 # This is the default only for manually (re-)triggered runs. Default for runs triggered by pull requests is configured via `jobs.initialize-cloud.generate-shard-matrix.env.CONCURRENCY`.

Expand Down Expand Up @@ -70,6 +70,8 @@ jobs:
deploy-dashboard:
if: github.event.pull_request.head.repo.full_name == 'saleor/saleor-dashboard'
outputs:
ACCOUNTS: ${{ steps.accounts.outputs.ACCOUNTS }}
runs-on: ubuntu-22.04
needs: initialize-cloud
permissions:
Expand Down Expand Up @@ -148,6 +150,16 @@ jobs:
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
env: ${{ needs.initialize-cloud.outputs.POOL_NAME }}

- name: Prepare accounts
id: accounts
uses: ./.github/actions/prepare-accounts
with:
BASE_URL: ${{ needs.initialize-cloud.outputs.BASE_URL }}
API_URL: ${{ needs.initialize-cloud.outputs.API_URL }}
E2E_USER_NAME: ${{ secrets.E2E_USER_NAME }}
E2E_USER_PASSWORD: ${{ secrets.E2E_USER_PASSWORD }}
E2E_ENCODE_PASS: ${{ secrets.E2E_ENCODE_PASS }}
E2E_PERMISSIONS_USERS_PASSWORD: ${{ secrets.E2E_PERMISSIONS_USERS_PASSWORD }}

run-tests:
runs-on: ubuntu-22.04
Expand All @@ -156,6 +168,7 @@ jobs:
fail-fast: false
matrix:
shard: ${{ fromJson(needs.initialize-cloud.outputs.SHARD_MATRIX) }}

steps:
- uses: actions/checkout@v4

Expand All @@ -171,13 +184,16 @@ jobs:
MAILPITURL: ${{ secrets.MAILPITURL }}
PW_WORKERS: ${{ vars.PW_WORKERS }}
PW_RETRIES: ${{ vars.PW_RETRIES }}
ACCOUNTS: ${{ needs.deploy-dashboard.outputs.ACCOUNTS }}
E2E_ENCODE_PASS: ${{ secrets.E2E_ENCODE_PASS }}

merge-reports:
if: "!cancelled()"

needs: run-tests
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4

- name: Merge playwright reports
uses: ./.github/actions/merge-pw-reports
uses: ./.github/actions/merge-pw-reports
13 changes: 13 additions & 0 deletions .github/workflows/run-test-cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
BACKUP_ID: ${{ steps.cloud_variables.outputs.BACKUP_ID }}
BACKUP_VER: ${{ steps.cloud_variables.outputs.BACKUP_VER }}
BACKUP_NAME: ${{ steps.cloud_variables.outputs.BACKUP_NAME }}
ACCOUNTS: ${{ steps.accounts.outputs.ACCOUNTS }}
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -44,6 +45,17 @@ jobs:
POOL_INSTANCE: ${{ steps.cloud_variables.outputs.POOL_INSTANCE }}
BACKUP_ID: ${{ steps.cloud_variables.outputs.BACKUP_ID }}

- name: Prepare accounts
id: accounts
uses: ./.github/actions/prepare-accounts
with:
BASE_URL: ${{ needs.cloud_variables.outputs.BASE_URL }}
API_URL: ${{ needs.cloud_variables.outputs.API_URL }}
E2E_USER_NAME: ${{ secrets.E2E_USER_NAME }}
E2E_USER_PASSWORD: ${{ secrets.E2E_USER_PASSWORD }}
E2E_ENCODE_PASS: ${{ secrets.E2E_ENCODE_PASS }}
E2E_PERMISSIONS_USERS_PASSWORD: ${{ secrets.E2E_PERMISSIONS_USERS_PASSWORD }}

create-run-on-testmo:
runs-on: ubuntu-22.04
needs: initialize-cloud
Expand Down Expand Up @@ -76,6 +88,7 @@ jobs:
API_URL: ${{ needs.initialize-cloud.outputs.API_URL }}
E2E_USER_NAME: ${{ secrets.E2E_USER_NAME }}
E2E_USER_PASSWORD: ${{ secrets.E2E_USER_PASSWORD }}
ACCOUNTS: ${{ needs.initialize-cloud.outputs.ACCOUNTS }}
E2E_PERMISSIONS_USERS_PASSWORD: ${{ secrets.E2E_PERMISSIONS_USERS_PASSWORD }}
MAILPITURL: ${{ secrets.MAILPITURL }}
PW_WORKERS: ${{ vars.PW_WORKERS }}
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/run-test-manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
BACKUP_ID: ${{ steps.cloud_variables.outputs.BACKUP_ID }}
BACKUP_VER: ${{ steps.cloud_variables.outputs.BACKUP_VER }}
BACKUP_NAME: ${{ steps.cloud_variables.outputs.BACKUP_NAME }}
ACCOUNTS: ${{ steps.accounts.outputs.ACCOUNTS }}
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -51,6 +52,18 @@ jobs:
POOL_INSTANCE: ${{ steps.cloud_variables.outputs.POOL_INSTANCE }}
BACKUP_ID: ${{ steps.cloud_variables.outputs.BACKUP_ID }}

- name: Prepare accounts
id: accounts
uses: ./.github/actions/prepare-accounts
with:
BASE_URL: ${{ steps.cloud_variables.outputs.BASE_URL }}
API_URL: ${{ steps.cloud_variables.outputs.API_URL }}
E2E_USER_NAME: ${{ secrets.E2E_USER_NAME }}
E2E_USER_PASSWORD: ${{ secrets.E2E_USER_PASSWORD }}
E2E_ENCODE_PASS: ${{ secrets.E2E_ENCODE_PASS }}
E2E_PERMISSIONS_USERS_PASSWORD: ${{ secrets.E2E_PERMISSIONS_USERS_PASSWORD }}


create-run-on-testmo:
runs-on: ubuntu-22.04
needs: initialize-cloud
Expand Down Expand Up @@ -84,6 +97,7 @@ jobs:
E2E_USER_NAME: ${{ secrets.E2E_USER_NAME }}
E2E_USER_PASSWORD: ${{ secrets.E2E_USER_PASSWORD }}
E2E_PERMISSIONS_USERS_PASSWORD: ${{ secrets.E2E_PERMISSIONS_USERS_PASSWORD }}
ACCOUNTS: ${{ needs.initialize-cloud.outputs.ACCOUNTS }}
MAILPITURL: ${{ secrets.MAILPITURL }}
PW_WORKERS: ${{ vars.PW_WORKERS }}
PW_RETRIES: ${{ vars.PW_RETRIES }}
Expand Down
21 changes: 17 additions & 4 deletions .github/workflows/run-tests-on-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ on:
required: true
SLACK_QA_STATUSES_WEBHOOK_URL:
required: true

jobs:
add-check-and-prepare-instance:
runs-on: ubuntu-latest
Expand All @@ -47,6 +47,7 @@ jobs:
BACKUP_NAME: ${{ steps.cloud_variables.outputs.BACKUP_NAME }}
CHECK_ID: ${{ steps.create-check.outputs.CHECK_ID }}
FRAMEWORK: ${{ steps.check-framework.outputs.result }}
ACCOUNTS: ${{ steps.accounts.outputs.ACCOUNTS }}
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -84,7 +85,7 @@ jobs:
VERSION: ${{ env.VERSION }}

- name: Prepare instances
if: steps.check-framework.outputs.result == '"playwright"'
if: steps.check-framework.outputs.result == '"playwright"'
id: pool_variables
uses: ./.github/actions/prepare-instance
with:
Expand All @@ -97,20 +98,31 @@ jobs:
BACKUP_ID: ${{ steps.cloud_variables.outputs.BACKUP_ID }}

- uses: ./.github/actions/testmo/testmo-init
if: steps.check-framework.outputs.result == '"playwright"'
if: steps.check-framework.outputs.result == '"playwright"'
with:
testmoUrl: ${{ secrets.TESTMO_URL }}
testmoToken: ${{ secrets.TESTMO_TOKEN }}
testmoRunName: "Playwright run ${{ env.CUSTOM_VERSION }}"
id: init-testmo

- name: Prepare accounts
id: accounts
uses: ./.github/actions/prepare-accounts
with:
BASE_URL: ${{ steps.cloud_variables.outputs.BASE_URL }}
API_URL: ${{ steps.cloud_variables.outputs.API_URL }}
E2E_USER_NAME: ${{ secrets.E2E_USER_NAME }}
E2E_USER_PASSWORD: ${{ secrets.E2E_USER_PASSWORD }}
E2E_ENCODE_PASS: ${{ secrets.E2E_ENCODE_PASS }}
E2E_PERMISSIONS_USERS_PASSWORD: ${{ secrets.E2E_PERMISSIONS_USERS_PASSWORD }}

run-cy-tests:
runs-on: ubuntu-22.04
needs: "add-check-and-prepare-instance"
if: ${{ needs.add-check-and-prepare-instance.outputs.FRAMEWORK == '"cypress"' }}
steps:
- name: Trigger dashboard cypress automation tests
env:
env:
VERSION: ${{inputs.CUSTOM_VERSION}}
run: |
GITHUB_TOKEN=$( \
Expand Down Expand Up @@ -156,6 +168,7 @@ jobs:
E2E_USER_NAME: ${{ secrets.E2E_USER_NAME }}
E2E_USER_PASSWORD: ${{ secrets.E2E_USER_PASSWORD }}
E2E_PERMISSIONS_USERS_PASSWORD: ${{ secrets.E2E_PERMISSIONS_USERS_PASSWORD }}
ACCOUNTS: ${{ needs.add-check-and-prepare-instance.outputs.ACCOUNTS }}
MAILPITURL: ${{ secrets.MAILPITURL }}
URL_TO_RUN: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
PW_WORKERS: ${{ vars.PW_WORKERS }}
Expand Down
Loading

0 comments on commit bcabc89

Please sign in to comment.