Skip to content

Run tests on 3.17.46-a186303 CORE #3133

Run tests on 3.17.46-a186303 CORE

Run tests on 3.17.46-a186303 CORE #3133

Workflow file for this run

name: Execute nightly tests
run-name: Run tests on ${{ inputs.environment }}${{github.event.client_payload.version}} ${{github.event.client_payload.project}}
on:
workflow_dispatch:
inputs:
tags:
required: true
description: "Select tests to run"
default: "@allEnv"
type: choice
options:
- "@allEnv"
- "@critical"
- "@stable"
- "@oldRelease"
environment:
required: true
description: "Environment to run tests against"
default: "https://automation-dashboard.staging.saleor.cloud/"
type: choice
options:
- https://automation-dashboard.staging.saleor.cloud/
- https://master.staging.saleor.cloud/
- Other
otherEnvironment:
required: false
description: 'Type env if "Other" option is selected'
type: string
default: "https://vXX.staging.saleor.cloud/"
browser:
required: true
description: "Browser"
default: "electron"
type: choice
options:
- electron
- firefox
- all
repository_dispatch:
types: [automation-tests-event]
jobs:
revert-automation-env-to-snap:
if: ${{ github.event.inputs.environment == null && github.event_name != 'repository_dispatch' }}
runs-on: ubuntu-22.04
env:
TOKEN: ${{ secrets.CLOUD_ACCESS_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
- name: Install dependencies
run: |
cd .github/workflows
npm ci
- name: clean automation environment
id: clean-automation-environment
run: |
node .github/workflows/cleanEnvironments.js \
--token "$TOKEN" \
--environments_to_clean_regex "automation-dashboard.staging.saleor.cloud"
- name: Notify Slack
if: ${{ failure() }}
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_SNAP_RESTORE }}
SLACK_USERNAME: RevertSnapshotBot
SLACK_COLOR: ${{ job.status }}
SLACK_TITLE: "Revert to snapshot job failed"
SLACK_MESSAGE: "https://github.com/saleor/saleor-dashboard/actions/workflows/tests-nightly.yml"
MSG_MINIMAL: true
testmo-report-preparation:
needs: ["revert-automation-env-to-snap"]
if: ${{ always() && github.event_name != 'repository_dispatch' }}
runs-on: ubuntu-22.04
outputs:
testmo-run-id: ${{ steps.init-testmo.outputs.testmo-run-id }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/testmo/testmo-init
with:
testmoUrl: ${{ secrets.TESTMO_URL }}
testmoToken: ${{ secrets.TESTMO_TOKEN }}
testmoRunName: "Cypress run ${{github.ref_name}}"
id: init-testmo
run-tests-in-parallel:
needs: [revert-automation-env-to-snap, testmo-report-preparation]
if: ${{ always() && github.event_name != 'repository_dispatch' && ! cancelled() }} #Wait for revert-automation-env-to-snap, bot run always, even if skipped
runs-on: ubuntu-22.04
env:
GREP_TAGS: ${{ github.event.inputs.tags || '@allEnv'}}
outputs:
status: ${{ steps.cypress.outcome }}
dashboard_url: ${{ steps.cypress.outputs.dashboardUrl }}
environment: ${{ steps.get-env-uri.outputs.ENV_URI }}
strategy:
fail-fast: false
matrix:
# run copies of the current job in parallel
containers: [1, 2, 3, 4, 5, 6]
steps:
- uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
- name: Check if other env
id: get-typed-env-uri
if: ${{ github.event.inputs.environment == 'Other' }}
run: |
echo "ENV_URI=${{github.event.inputs.otherEnvironment}}" >> $GITHUB_OUTPUT
- name: Get env
id: get-env-uri
env:
DEFAULT_ENV_URI: "https://automation-dashboard.staging.saleor.cloud/"
TYPED_ENV_URI: ""
run: |
echo "ENV_URI=${{ steps.get-typed-env-uri.outputs.ENV_URI || github.event.inputs.environment || env.DEFAULT_ENV_URI }}" >> $GITHUB_OUTPUT
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
- name: Get browsers
id: get-browsers
uses: actions/github-script@v6
env:
browser: ${{github.event.inputs.browser}}
event_name: ${{github.event_name}}
with:
result-encoding: string
script: |
const { browser } = process.env
const { event_name } = process.env
switch (event_name) {
case 'workflow_dispatch':
return browser
case 'schedule':
return 'electron'
default:
return 'electron'
}
- name: Cypress install
id: cypress-install
if: ${{ github.event.inputs.tests != 'Critical' && github.event_name != 'repository_dispatch'}}
uses: cypress-io/github-action@v6
with:
runTests: false
- name: Cypress run electron
id: cypress-electron
if: ${{ github.event.inputs.tests != 'Critical' && github.event_name != 'repository_dispatch' && contains(fromJSON('["electron", "all"]'), steps.get-browsers.outputs.result) && ! cancelled() }}
uses: ./.github/actions/e2e
with:
apiUrl: ${{ steps.get-env-uri.outputs.ENV_URI }}graphql/
appMountUri: ${{ secrets.APP_MOUNT_URI }}
baseUrl: ${{ steps.get-env-uri.outputs.ENV_URI }}dashboard/
userName: ${{ secrets.CYPRESS_USER_NAME }}
secondUserName: ${{ secrets.CYPRESS_SECOND_USER_NAME }}
userPassword: ${{ secrets.CYPRESS_USER_PASSWORD }}
permissionsUserPassword: ${{ secrets.CYPRESS_PERMISSIONS_USERS_PASSWORD }}
githubToken: ${{ secrets.GITHUB_TOKEN }}
mailpitUrl: ${{ secrets.CYPRESS_MAILPITURL }}
stripeSecretKey: ${{ secrets.STRIPE_SECRET_KEY }}
stripePublicKey: ${{ secrets.STRIPE_PUBLIC_KEY }}
cypressGrepTags: ${{ env.GREP_TAGS }}
split: ${{ strategy.job-total }}
splitIndex: ${{ strategy.job-index }}
commitInfoMessage: All tests triggered via ${{ github.event_name}} on ${{ steps.get-env-uri.outputs.ENV_URI }}
install: false
browser: electron
- name: Cypress run firefox
id: cypress-firefox
if: ${{ github.event.inputs.tests != 'Critical' && github.event_name != 'repository_dispatch' && contains(fromJSON('["firefox", "all"]'), steps.get-browsers.outputs.result) && ! cancelled() }}
uses: ./.github/actions/e2e
with:
apiUrl: ${{ steps.get-env-uri.outputs.ENV_URI }}graphql/
appMountUri: ${{ secrets.APP_MOUNT_URI }}
baseUrl: "${{ steps.get-env-uri.outputs.ENV_URI }}dashboard/"
userName: ${{ secrets.CYPRESS_USER_NAME }}
secondUserName: ${{ secrets.CYPRESS_SECOND_USER_NAME }}
userPassword: ${{ secrets.CYPRESS_USER_PASSWORD }}
permissionsUserPassword: ${{ secrets.CYPRESS_PERMISSIONS_USERS_PASSWORD }}
githubToken: ${{ secrets.GITHUB_TOKEN }}
mailpitUrl: ${{ secrets.CYPRESS_MAILPITURL }}
stripeSecretKey: ${{ secrets.STRIPE_SECRET_KEY }}
stripePublicKey: ${{ secrets.STRIPE_PUBLIC_KEY }}
cypressGrepTags: ${{ env.GREP_TAGS }}
split: ${{ strategy.job-total }}
splitIndex: ${{ strategy.job-index }}
commitInfoMessage: All tests triggered via ${{ github.event_name}} on ${{ steps.get-env-uri.outputs.ENV_URI }}
install: false
browser: firefox
- name: Testmo threads submit
if: ${{ github.event.inputs.tests != 'Critical' && github.event_name != 'repository_dispatch' && contains(fromJSON('["electron", "all"]'), steps.get-browsers.outputs.result) && ! cancelled() }}
uses: ./.github/actions/testmo/testmo-threads-submit-cypress
with:
testmoUrl: ${{ secrets.TESTMO_URL }}
testmoToken: ${{ secrets.TESTMO_TOKEN }}
testmoRunId: ${{ needs.testmo-report-preparation.outputs.testmo-run-id }}
manual-and-scheduled-triggered-test-complete:
needs: [run-tests-in-parallel, testmo-report-preparation]
if: ${{always() && github.event_name != 'repository_dispatch' && !contains(needs.run-tests-in-parallel.result, 'skipped') && !contains(needs.run-tests-in-parallel.result, 'cancelled')}}
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/combineReportsFromE2E
get-environment-variables:
if: ${{ github.event_name == 'repository_dispatch' && (github.event.client_payload.environment == 'SANDBOX' || github.event.client_payload.environment == 'STAGING')}}
runs-on: ubuntu-22.04
timeout-minutes: 30
outputs:
url: ${{ steps.get-environment-variables.outputs.url }}
is_old_version: ${{ steps.get-environment-variables.outputs.IS_OLD_VERSION }}
branch: ${{ steps.get-environment-variables.outputs.branch }}
env:
REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TOKEN: ${{ secrets.CLOUD_ACCESS_TOKEN }}
VERSION: ${{github.event.client_payload.version}}
PROJECT: ${{github.event.client_payload.project}}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
- name: Install dependencies
run: |
cd .github/workflows
npm ci
- name: get environment variables
id: get-environment-variables
run: |
node .github/workflows/cypressTestsHelpers/getEnvironmentVariables.js \
--version $VERSION \
--token "$TOKEN" \
--repo_token "$REPO_TOKEN" \
--project "$PROJECT"
run-tests-on-release:
if: ${{ github.event_name == 'repository_dispatch' && (github.event.client_payload.environment == 'SANDBOX' || github.event.client_payload.environment == 'STAGING')}}
needs: get-environment-variables
runs-on: ubuntu-22.04
env:
NODE_OPTIONS: "--max_old_space_size=4096"
outputs:
status: ${{ steps.cypress.outcome }}
dashboard_url: ${{ steps.cypress.outputs.dashboardUrl }}
container: cypress/browsers:node18.12.0-chrome106-ff106
strategy:
fail-fast: false
matrix:
# run copies of the current job in parallel
containers: [1, 2, 3, 4, 5, 6, 7, 8, 9]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ needs.get-environment-variables.outputs.branch }}
- name: Set tag for tests
id: set-tag-for-tests
uses: actions/github-script@v6
env:
is_old_version: ${{ needs.get-environment-variables.outputs.is_old_version }}
with:
result-encoding: string
script: |
const { is_old_version } = process.env
if(is_old_version == "true"){
return "@oldRelease"
}else{
return "@stable"
}
- name: Cypress install
id: cypress-install
continue-on-error: true
uses: cypress-io/github-action@v5
with:
runTests: false
- name: Cypress run - automatically
id: cypress
continue-on-error: true
uses: cypress-io/github-action@v6
env:
API_URI: ${{ needs.get-environment-variables.outputs.url }}graphql/
APP_MOUNT_URI: ${{ secrets.APP_MOUNT_URI }}
BASE_URL: ${{ needs.get-environment-variables.outputs.url }}dashboard/
## backward compatibility requires CYPRESS_baseUrl as env var name - can be removed when version lower than 3.17 are no longer supported
CYPRESS_baseUrl: ${{ needs.get-environment-variables.outputs.url }}dashboard/
CYPRESS_USER_NAME: ${{ secrets.CYPRESS_USER_NAME }}
CYPRESS_SECOND_USER_NAME: ${{ secrets.CYPRESS_SECOND_USER_NAME }}
CYPRESS_USER_PASSWORD: ${{ secrets.CYPRESS_USER_PASSWORD }}
CYPRESS_PERMISSIONS_USERS_PASSWORD: ${{ secrets.CYPRESS_PERMISSIONS_USERS_PASSWORD }}
STRIPE_SECRET_KEY: ${{ secrets.STRIPE_SECRET_KEY }}
STRIPE_PUBLIC_KEY: ${{ secrets.STRIPE_PUBLIC_KEY }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CYPRESS_MAILPITURL: ${{ secrets.CYPRESS_MAILPITURL }}
COMMIT_INFO_MESSAGE: Triggered via release - ${{github.event.client_payload.project}} ${{github.event.client_payload.version}}, ${{github.event.client_payload.pullRequestUrl}}
CYPRESS_grepTags: ${{steps.set-tag-for-tests.outputs.result}}
with:
install: false
parallel: true
group: "UI - Electron"
record: true
tag: ${{github.event.client_payload.project}}, ${{github.event.client_payload.environment}}, ${{ needs.get-environment-variables.outputs.url }}
add-review-and-merge-patch:
if: ${{ always() && (needs.run-tests-on-release.outputs.status == 'success' || needs.run-tests-on-release.outputs.status == 'failure') }}
runs-on: ubuntu-22.04
needs: [run-tests-on-release]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
- name: Install dependencies
run: |
cd .github/workflows
npm ci
- name: Add review and merge if patch DASHBOARD
env:
tests_status: ${{ needs.run-tests-on-release.outputs.status }}
version: ${{ github.event.client_payload.version }}
pull_request_number: ${{ github.event.client_payload.pullRequestNumber }}
dashboard_url: ${{ needs.run-tests-on-release.outputs.dashboard_url }}
auto_release: ${{ (github.event.client_payload.autoRelease && '--auto_release') || '' }}
run: |
export GITHUB_TOKEN=$( \
curl --request GET --url ${{ secrets.VAULT_URL}} --header "Authorization: JWT ${{ secrets.VAULT_JWT }}" | jq -r .token \
)
node .github/workflows/cypressTestsHelpers/approveAndMergeReleasePR.js \
--version $version \
--pull_request_number $pull_request_number \
--dashboard_url "$dashboard_url" \
$auto_release
send-slack-notification:
if: ${{ failure() && github.event_name == 'repository_dispatch'}}
runs-on: ubuntu-22.04
needs:
[
get-environment-variables,
run-tests-on-release,
add-review-and-merge-patch,
]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Notify Slack
env:
JOB_DEPLOYMENT_KIND: staging
JOB_STATUS: "Failure"
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_RELEASES_WEBHOOK_URL }}
JOB_TITLE: "Test release workflow - ${{github.event.client_payload.project}} ${{github.event.client_payload.version}}"
JOB_KIND: "release tests"
run: |
python3 ./.github/workflows/notify/notify-slack.py
send-slack-notification-scheduled-and-manually:
if: ${{always() && github.event_name != 'repository_dispatch'}}
defaults:
run:
shell: bash
working-directory: .github/workflows
runs-on: ubuntu-22.04
needs: [run-tests-in-parallel]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
- name: Install dependencies
run: npm ci
- name: Get tests results
id: get-tests-results
env:
tests_status: ${{ needs.run-tests-in-parallel.outputs.status }}
dashboard_url: ${{ needs.run-tests-in-parallel.outputs.dashboard_url }}
run: |
node cypressTestsHelpers/getFailedTests.js \
--dashboard_url "$dashboard_url"
- name: Notify Slack
if: steps.get-tests-results.outputs.testStatus == 'true'
env:
JOB_DEPLOYMENT_KIND: ${{ needs.run-tests-in-parallel.outputs.environment }}
JOB_STATUS: "Failure"
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_SALEOR_QA_WEBHOOK_URL }}
JOB_TITLE: "A lot of tests failed, something is probably broken - ${{ needs.run-tests-in-parallel.outputs.dashboard_url }}"
JOB_KIND: "Tests"
run: |
python3 .github/workflows/notify/notify-slack.py
test-complete:
needs:
[testmo-report-preparation, run-tests-in-parallel, run-tests-on-release]
if: always() && !contains(needs.testmo-report-preparation.result, 'skipped') && !contains(needs.testmo-report-preparation.result, 'failure')
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- run: npm ci
working-directory: .github/workflows
- name: complete testmo report
uses: ./.github/actions/testmo/testmo-finish
with:
testmoUrl: ${{ secrets.TESTMO_URL }}
testmoToken: ${{ secrets.TESTMO_TOKEN }}
testmoRunId: ${{ needs.testmo-report-preparation.outputs.testmo-run-id }}