From 0e3446c932c11b4e9f94dc859c02038588e9d07e Mon Sep 17 00:00:00 2001 From: Karolina Rakoczy Date: Wed, 15 Jan 2025 14:19:26 +0100 Subject: [PATCH] Separate sources for playwright and cypress (#5328) * Separate sources for playwright and cypress * add needs to job * test release workflow after changes * add needs to job * fix sources * remove changes for testing if changes works --------- Co-authored-by: M.Graczyk --- .changeset/swift-planets-try.md | 5 ++++ .github/actions/testmo/testmo-init/action.yml | 6 +++- .github/workflows/pr-automation.yml | 30 +++++++++++++++++-- .github/workflows/run-test-manual.yml | 1 + .github/workflows/run-tests-on-release.yml | 17 ++++++----- 5 files changed, 49 insertions(+), 10 deletions(-) create mode 100644 .changeset/swift-planets-try.md diff --git a/.changeset/swift-planets-try.md b/.changeset/swift-planets-try.md new file mode 100644 index 00000000000..783745794d7 --- /dev/null +++ b/.changeset/swift-planets-try.md @@ -0,0 +1,5 @@ +--- +"saleor-dashboard": patch +--- + +This Pr is separating sources in testmo for playwright and cypress tests, and adding results for runs on PR to testmo diff --git a/.github/actions/testmo/testmo-init/action.yml b/.github/actions/testmo/testmo-init/action.yml index 121046a921e..04fe383d685 100644 --- a/.github/actions/testmo/testmo-init/action.yml +++ b/.github/actions/testmo/testmo-init/action.yml @@ -10,6 +10,9 @@ inputs: testmoRunName: description: "Displayed name in testmo" required: true + source: + description: "Source for tests" + required: true outputs: testmo-run-id: @@ -34,10 +37,11 @@ runs: --instance "$TESTMO_URL" \ --project-id 1 \ --name "$RUN_NAME" \ - --source frontend-e2e-tests) + --source "$SOURCE") echo "TESTMO_RUN_ID=$ID" >> $GITHUB_OUTPUT env: TESTMO_URL: ${{ inputs.testmoUrl }} TESTMO_TOKEN: ${{ inputs.testmoToken }} RUN_NAME: ${{inputs.testmoRunName}} + SOURCE: ${{inputs.source}} id: run-tests diff --git a/.github/workflows/pr-automation.yml b/.github/workflows/pr-automation.yml index 484228d5d86..8e0b2d0f6d7 100644 --- a/.github/workflows/pr-automation.yml +++ b/.github/workflows/pr-automation.yml @@ -73,6 +73,7 @@ jobs: if: github.event.pull_request.head.repo.full_name == 'saleor/saleor-dashboard' outputs: ACCOUNTS: ${{ steps.accounts.outputs.ACCOUNTS }} + TESTMO_RUN_ID: ${{ steps.init-testmo.outputs.testmo-run-id }} runs-on: ubuntu-22.04 needs: initialize-cloud permissions: @@ -154,7 +155,17 @@ jobs: deployment_id: ${{ steps.deployment.outputs.deployment_id }} env: ${{ needs.initialize-cloud.outputs.POOL_NAME }} + - uses: ./.github/actions/testmo/testmo-init + if: ${{ contains(github.event.pull_request.labels.*.name, 'run pw-e2e') }} + with: + testmoUrl: ${{ secrets.TESTMO_URL }} + testmoToken: ${{ secrets.TESTMO_TOKEN }} + testmoRunName: "Playwright run ${{github.ref_name}}" + source: "Playwright-tests" + id: init-testmo + - name: Prepare accounts + if: ${{ contains(github.event.pull_request.labels.*.name, 'run pw-e2e') }} id: accounts uses: ./.github/actions/prepare-accounts with: @@ -192,13 +203,28 @@ jobs: ACCOUNTS: ${{ needs.deploy-dashboard.outputs.ACCOUNTS }} E2E_ENCODE_PASS: ${{ secrets.E2E_ENCODE_PASS }} + - name: submit-results-to-testmo + if: always() + uses: ./.github/actions/testmo/testmo-threads-submit-playwright + with: + testmoUrl: ${{ secrets.TESTMO_URL }} + testmoToken: ${{ secrets.TESTMO_TOKEN }} + testmoRunId: ${{ needs.deploy-dashboard.outputs.TESTMO_RUN_ID }} + merge-reports: if: "!cancelled() && contains(github.event.pull_request.labels.*.name, 'run pw-e2e')" - needs: run-tests + needs: [run-tests, deploy-dashboard] runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 - name: Merge playwright reports - uses: ./.github/actions/merge-pw-reports \ No newline at end of file + uses: ./.github/actions/merge-pw-reports + + - name: complete testmo report + uses: ./.github/actions/testmo/testmo-finish + with: + testmoUrl: ${{ secrets.TESTMO_URL }} + testmoToken: ${{ secrets.TESTMO_TOKEN }} + testmoRunId: ${{ needs.deploy-dashboard.outputs.TESTMO_RUN_ID }} \ No newline at end of file diff --git a/.github/workflows/run-test-manual.yml b/.github/workflows/run-test-manual.yml index dbd318a1c24..15adbb239cb 100644 --- a/.github/workflows/run-test-manual.yml +++ b/.github/workflows/run-test-manual.yml @@ -94,6 +94,7 @@ jobs: testmoUrl: ${{ secrets.TESTMO_URL }} testmoToken: ${{ secrets.TESTMO_TOKEN }} testmoRunName: "Playwright run ${{github.ref_name}}" + source: "Playwright-tests" id: init-testmo run-tests: diff --git a/.github/workflows/run-tests-on-release.yml b/.github/workflows/run-tests-on-release.yml index 9a5757dfc90..566f8de1942 100644 --- a/.github/workflows/run-tests-on-release.yml +++ b/.github/workflows/run-tests-on-release.yml @@ -1,5 +1,6 @@ name: Run automation tests on release on: + workflow_call: inputs: VERSION: @@ -93,13 +94,14 @@ jobs: env: VERSION: "${{inputs.VERSION}}" with: + result-encoding: string script: | const { VERSION } = process.env const versionWithoutDot = VERSION.replaceAll(/\./g, "") if(versionWithoutDot >= 319){ - return "playwright" + return "Playwright-tests" }else{ - return "cypress" + return "Cypress-tests" } - name: Create check if release PR exists @@ -137,6 +139,7 @@ jobs: testmoUrl: ${{ secrets.TESTMO_URL }} testmoToken: ${{ secrets.TESTMO_TOKEN }} testmoRunName: "${{ steps.check-framework.outputs.result }} run ${{ env.CUSTOM_VERSION }}" + source: ${{ steps.check-framework.outputs.result }} id: init-testmo - name: get environment variables @@ -163,7 +166,7 @@ jobs: E2E_PERMISSIONS_USERS_PASSWORD: ${{ secrets.E2E_PERMISSIONS_USERS_PASSWORD }} run-cy-tests: - if: needs.add-check-and-prepare-instance.outputs.FRAMEWORK == '"cypress"' + if: needs.add-check-and-prepare-instance.outputs.FRAMEWORK == 'Cypress-tests' needs: add-check-and-prepare-instance runs-on: ubuntu-22.04 timeout-minutes: 30 @@ -227,7 +230,7 @@ jobs: runs-on: ubuntu-22.04 needs: "add-check-and-prepare-instance" timeout-minutes: 30 - if: needs.add-check-and-prepare-instance.outputs.FRAMEWORK == '"playwright"' + if: needs.add-check-and-prepare-instance.outputs.FRAMEWORK == 'Playwright-tests' strategy: fail-fast: false matrix: @@ -283,11 +286,11 @@ jobs: run: npm ci - name: Merge playwright reports - if: needs.add-check-and-prepare-instance.outputs.FRAMEWORK == '"playwright"' + if: needs.add-check-and-prepare-instance.outputs.FRAMEWORK == 'Playwright-tests' uses: ./.github/actions/merge-pw-reports - name: Merge cypress reports - if: needs.add-check-and-prepare-instance.outputs.FRAMEWORK == '"cypress"' + if: needs.add-check-and-prepare-instance.outputs.FRAMEWORK == 'Cypress-tests' uses: ./.github/actions/combineReportsFromE2E - name: complete testmo report @@ -336,7 +339,7 @@ jobs: if: | always() && (needs.tests-complete != 'success' && cancelled()) && - needs.add-check-and-prepare-instance.outputs.FRAMEWORK == '"playwright"' + needs.add-check-and-prepare-instance.outputs.FRAMEWORK == 'Playwright-tests' steps: - uses: actions/checkout@v4