Skip to content

Commit

Permalink
Login before test 320 (#5219)
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>

* Add deps installation (#5213)

* Port

* Missing encode pass (#5218)

* Add missing encode pass

* Add missing encode pass

* Update .changeset/two-zebras-check.md

Co-authored-by: Mikail <6186720+NyanKiyoshi@users.noreply.github.com>

---------

Co-authored-by: Mikail <6186720+NyanKiyoshi@users.noreply.github.com>

* Add missing encode pass

---------

Co-authored-by: Wojciech Mista <wojciech.mista@hotmail.com>
Co-authored-by: Mikail <6186720+NyanKiyoshi@users.noreply.github.com>
  • Loading branch information
3 people authored Oct 16, 2024
1 parent de0987c commit e466806
Show file tree
Hide file tree
Showing 48 changed files with 618 additions and 79 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,5 @@
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": "off"
},
"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"
18 changes: 16 additions & 2 deletions .github/actions/run-pw-tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,15 @@ inputs:
description: "Playwright retries"
required: true
PROJECT:
description: "Project name form playwright config"
description: "Project name from playwright config"
required: false
default: "e2e"
ACCOUNTS:
description: "Accounts hash"
required: true
E2E_ENCODE_PASS:
description: "Password for encoding credentials"
required: true

runs:
using: "composite"
Expand All @@ -47,6 +53,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 @@ -82,4 +96,4 @@ runs:
with:
name: all-blob-reports
path: blob-report
retention-days: 1
retention-days: 1
18 changes: 17 additions & 1 deletion .github/workflows/pr-automation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,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 @@ -151,6 +153,17 @@ 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:
if: ${{ contains(github.event.pull_request.labels.*.name, 'run pw-e2e') }}
runs-on: ubuntu-22.04
Expand All @@ -159,6 +172,7 @@ jobs:
fail-fast: false
matrix:
shard: ${{ fromJson(needs.initialize-cloud.outputs.SHARD_MATRIX) }}

steps:
- uses: actions/checkout@v4

Expand All @@ -174,6 +188,8 @@ 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() && contains(github.event.pull_request.labels.*.name, 'run pw-e2e')"
Expand All @@ -184,4 +200,4 @@ jobs:
- uses: actions/checkout@v4

- name: Merge playwright reports
uses: ./.github/actions/merge-pw-reports
uses: ./.github/actions/merge-pw-reports
34 changes: 33 additions & 1 deletion .github/workflows/run-test-cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,29 @@ 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

- name: Setup Node
uses: actions/setup-node@v3
with:
sparse-checkout: ./.github/actions
node-version-file: ".nvmrc"

- name: Cache node modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-qa-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-qa-${{ env.cache-name }}-
${{ runner.os }}-qa-
${{ runner.os }}-
- name: Install deps
run: npm ci

- name: Generate variables
id: cloud_variables
Expand All @@ -44,6 +63,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 +106,8 @@ jobs:
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 }}
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
35 changes: 34 additions & 1 deletion .github/workflows/run-test-manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,29 @@ 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

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"

- name: Cache node modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
sparse-checkout: ./.github/actions
path: ~/.npm
key: ${{ runner.os }}-qa-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-qa-${{ env.cache-name }}-
${{ runner.os }}-qa-
${{ runner.os }}-
- name: Install deps
run: npm ci

- name: Set variables mode
id: set_variables_mode
Expand Down Expand Up @@ -51,6 +70,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 +115,8 @@ jobs:
E2E_USER_NAME: ${{ secrets.E2E_USER_NAME }}
E2E_USER_PASSWORD: ${{ secrets.E2E_USER_PASSWORD }}
E2E_PERMISSIONS_USERS_PASSWORD: ${{ secrets.E2E_PERMISSIONS_USERS_PASSWORD }}
E2E_ENCODE_PASS: ${{ secrets.E2E_ENCODE_PASS }}
ACCOUNTS: ${{ needs.initialize-cloud.outputs.ACCOUNTS }}
MAILPITURL: ${{ secrets.MAILPITURL }}
PW_WORKERS: ${{ vars.PW_WORKERS }}
PW_RETRIES: ${{ vars.PW_RETRIES }}
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/run-tests-on-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,30 @@ jobs:
CHECK_ID: ${{ steps.create-check.outputs.CHECK_ID }}
FRAMEWORK: ${{ steps.check-framework.outputs.result }}
IS_OLD_VERSION: ${{ steps.get-environment-variables.outputs.IS_OLD_VERSION }}
ACCOUNTS: ${{ steps.accounts.outputs.ACCOUNTS }}
steps:
- uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"

- name: Cache node modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-qa-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-qa-${{ env.cache-name }}-
${{ runner.os }}-qa-
${{ runner.os }}-
- name: Install deps
run: npm ci

- id: check-framework
uses: actions/github-script@v7
env:
Expand Down Expand Up @@ -127,6 +148,17 @@ jobs:
--repo_token "$REPO_TOKEN" \
--project "$PROJECT"
- 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:
if: needs.add-check-and-prepare-instance.outputs.FRAMEWORK == '"cypress"'
needs: add-check-and-prepare-instance
Expand Down Expand Up @@ -211,6 +243,8 @@ jobs:
E2E_USER_NAME: ${{ secrets.E2E_USER_NAME }}
E2E_USER_PASSWORD: ${{ secrets.E2E_USER_PASSWORD }}
E2E_PERMISSIONS_USERS_PASSWORD: ${{ secrets.E2E_PERMISSIONS_USERS_PASSWORD }}
E2E_ENCODE_PASS: ${{ secrets.E2E_ENCODE_PASS }}
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 e466806

Please sign in to comment.