Skip to content

Commit

Permalink
Move e2e test steps from workflows into composite action (#4171)
Browse files Browse the repository at this point in the history
* Fix sending empty attribute

* Add changeset

* Fix tests

* merging reports

* combining mocha, screnshots, videos from artifacts

* combining mocha, screnshots, videos from artifacts v2

* install dependencies and cache

* install dependencies and cache 2

* renamed report artifact, changed path to html, retention day bumped

* remove videos when tests passes

* reports merging  from artifacts should pass always

* reports merging  from artifacts should pass always

* wip - paths fix

* wip - video and screenshots path fix

* remove videos from reports

* remove fake fail

* wip - change cypress cloud provider to gha

* wip 2

* wip 3

* wip 4

* wip 5

* wip 6

* cr fixes

* move partially steps which triggers e2e test into composite action

* fix could not find action

* fix could not find action 2

* fix could not find action 3

* fix could not find action 4

* fix could not find action 5

* wip

* wip

* wip - fix absolute path

* wip - fix absolute path 2

* wip - fix absolute path 3

* wip

* wip 5

* wip 5

* testmo steps packed as composite actions

* testmo steps packed as composite actions 2

* moved checkout from composite action to main workflow

* outputs run id from composite action

* wip

* wip 2

* wip 3

* wip 4

* switch e2e trigger to use composite action in nightly workflow

* base url fix

* experiment

* experiment 2

* experiment 2

* fix needs in nightly and test-env-deploy

* remove setting job as passed when test fails by adding ! cancelled()

* notification trigger

* scheduled test to run mon,wed,fri; created new action to gather reports and combine them, fix slack notifications

* wip

* wip 2

* wip 3

* wip

* remove fail trigger

* bump actions/cache@v2 -> actions/cache@v3

* removed unused githubToken from e2e, ymal syntax fix in notification workflow, fix path to notification script

---------

Co-authored-by: Paweł Chyła <[email protected]>
  • Loading branch information
wojteknowacki and poulch authored Sep 27, 2023
1 parent f97d75c commit 2139077
Show file tree
Hide file tree
Showing 10 changed files with 422 additions and 244 deletions.
51 changes: 51 additions & 0 deletions .github/actions/combineReportsFromE2E/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: combine-e2e-results
description: "Combines reports from matrix and upload them as one"
runs:
using: "composite"
steps:
- uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
cache: npm
- 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 Dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
shell: bash
run: NODE_OPTIONS=--max_old_space_size=4096 npm ci
- run: npm ci
shell: bash
working-directory: .github/workflows
- name: Download reports artifacts
uses: actions/download-artifact@v3
with:
path: ./cypress/reports
- name: Create reports dir
shell: bash
continue-on-error: true
run: npm run qa:create-artifacts-dirs
- name: Merge report files
shell: bash
continue-on-error: true
run: npm run qa:generate-html-report
- name: Move artifacts screenshots into reports dir
shell: bash
continue-on-error: true
run: npm run qa:artifact-move-screenshots
- name: Upload reports
uses: actions/upload-artifact@v3
if: always()
with:
name: combined-report
path: ./cypress/reports
retention-days: 5
if-no-files-found: ignore
92 changes: 92 additions & 0 deletions .github/actions/e2e/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: e2e-parallel
description: "Trigger e2e tests and create reports"
inputs:
apiUrl:
description: "API URL from PR or staging"
required: true
baseUrl:
description: "FE URL from PR or staging"
required: true
commitInfoMessage:
description: "Info displayed in commit"
required: false
cypressGrepTags:
description: "Passed tags that should be executed"
required: true
split:
description: "E2E tests containers number"
required: true
splitIndex:
description: "E2E tests container index"
required: true
install:
description: "Triggers cypress installation"
required: false
browser:
description: "Browser which e2e should test"
required: false
appMountUri:
description: "URL for Apps"
required: true
userName:
description: "Name of user which e2e uses"
required: true
secondUserName:
description: "Name of the second user which e2e uses"
required: true
userPassword:
description: "User password for e2e"
required: true
permissionsUserPassword:
description: "User with limited permissions password"
required: true
mailpitUrl:
description: "Mail provider URL"
required: true
stripeSecretKey:
description: "Payments providers secret"
required: false
stripePublicKey:
description: "Payments providers secret"
required: false
runs:
using: "composite"
steps:
- name: e2e with reports
uses: cypress-io/github-action@v5
with:
install: ${{inputs.install}}
browser: ${{inputs.browser}}
env:
API_URI: ${{inputs.apiUrl}}
APP_MOUNT_URI: ${{ inputs.appMountUri }}
CYPRESS_baseUrl: ${{inputs.baseUrl}}
CYPRESS_USER_NAME: ${{ inputs.userName }}
CYPRESS_SECOND_USER_NAME: ${{ inputs.secondUserName }}
CYPRESS_USER_PASSWORD: ${{ inputs.userPassword }}
CYPRESS_PERMISSIONS_USERS_PASSWORD: ${{ inputs.permissionsUserPassword }}
CYPRESS_MAILPITURL: ${{ inputs.mailpitUrl }}
CYPRESS_grepTags: ${{ inputs.cypressGrepTags }}
SPLIT: ${{ inputs.split }}
SPLIT_INDEX: ${{ inputs.splitIndex}}
STRIPE_SECRET_KEY: ${{inputs.stripeSecretKey}}
STRIPE_PUBLIC_KEY: ${{inputs.stripePublicKey}}
COMMIT_INFO_MESSAGE: ${{inputs.commitInfoMessage}}
- name: Create reports dir
shell: bash
continue-on-error: true
if: ${{ ! cancelled() }}
run: npm run qa:create-artifacts-dirs
- name: Move screenshots into reports dir
shell: bash
continue-on-error: true
if: ${{ ! cancelled() }}
run: npm run qa:move-screenshots
- name: Upload reports
uses: actions/upload-artifact@v3
if: always()
with:
name: report-${{ strategy.job-index }}
path: ./cypress/reports
retention-days: 5
if-no-files-found: ignore
31 changes: 31 additions & 0 deletions .github/actions/testmo/testmo-finish/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: complete-testmo
description: "Completes testmo reports"
inputs:
testmoUrl:
description: "Testmo project URL"
required: true
testmoToken:
description: "Testmo token"
required: true
testmoRunId:
description: "Parallelized job Testmo run id"
required: true
runs:
using: composite
steps:
- name: Install dependencies
if: ${{ ! cancelled() }}
working-directory: .github/workflows
shell: bash
run: npm ci
- name: complete testmo report
working-directory: .github/workflows
shell: bash
run: |
npx testmo automation:run:complete \
--instance "$TESTMO_URL" \
--run-id "$TESTMO_RUN_ID"
env:
TESTMO_URL: ${{ inputs.testmoUrl }}
TESTMO_TOKEN: ${{ inputs.testmoToken }}
TESTMO_RUN_ID: ${{ inputs.testmoRunId }}
38 changes: 38 additions & 0 deletions .github/actions/testmo/testmo-init/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: init-testmo
description: "Inits testmo reports"
inputs:
testmoUrl:
description: "Testmo project URL"
required: true
testmoToken:
description: "Testmo token"
required: true
outputs:
testmo-run-id:
description: "Testmo run id"
value: ${{ steps.run-tests.outputs.TESTMO_RUN_ID }}
runs:
using: composite
steps:
- uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
cache: npm
- name: install dependencies
working-directory: .github/workflows
shell: bash
run: npm ci
- name: create testmo run
working-directory: .github/workflows
shell: bash
run: |
ID=$(npx testmo automation:run:create \
--instance "$TESTMO_URL" \
--project-id 1 \
--name "Deployment tests" \
--source frontend-e2e-tests)
echo "TESTMO_RUN_ID=$ID" >> $GITHUB_OUTPUT
env:
TESTMO_URL: ${{ inputs.testmoUrl }}
TESTMO_TOKEN: ${{ inputs.testmoToken }}
id: run-tests
76 changes: 76 additions & 0 deletions .github/actions/testmo/testmo-threads-submit/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: submit-testmo
description: "Submits testmo resports"
inputs:
testmoUrl:
description: "Testmo project URL"
required: true
testmoToken:
description: "Testmo token"
required: true
testmoRunId:
description: "Parallelized job Testmo run id"
required: true
runs:
using: composite
steps:
- uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
cache: npm
- 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 Dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
shell: bash
run: NODE_OPTIONS=--max_old_space_size=4096 npm install
- name: Install dependencies
if: ${{ ! cancelled() }}
working-directory: .github/workflows
shell: bash
run: npm ci
- name: Testmo threads submit
if: github.event.pull_request.head.repo.fork == false && !cancelled()
working-directory: .github/workflows
shell: bash
run: |
npx testmo automation:run:submit-thread \
--instance "$TESTMO_URL" \
--run-id "$TESTMO_RUN_ID" \
--results ../../cypress/reports/junit/*.xml
env:
TESTMO_URL: ${{ inputs.testmoUrl }}
TESTMO_TOKEN: ${{ inputs.testmoToken }}
TESTMO_RUN_ID: ${{ inputs.testmoRunId}}
- name: Download reports artifacts
uses: actions/download-artifact@v3
with:
path: ./cypress/reports
- name: Create reports dir
continue-on-error: true
shell: bash
run: npm run qa:create-artifacts-dirs
- name: Merge report files
continue-on-error: true
shell: bash
run: npm run qa:generate-html-report
- name: Move artifacts screenshots into reports dir
continue-on-error: true
shell: bash
run: npm run qa:artifact-move-screenshots
- name: Upload reports
uses: actions/upload-artifact@v3
if: always()
with:
name: combined-report
path: ./cypress/reports
retention-days: 5
if-no-files-found: ignore
10 changes: 5 additions & 5 deletions .github/workflows/deploy-and-run-cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ on:
inputs:
api_url:
required: true
description: 'Build dashboard and run test with this API url'
description: "Build dashboard and run test with this API url"
type: string
tags:
required: true
description: 'Run tests with typed tags'
description: "Run tests with typed tags"
type: string
default: "@stable"

Expand Down Expand Up @@ -39,7 +39,7 @@ jobs:
node-version-file: ".nvmrc"

- name: Cache node modules
uses: actions/cache@v2
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
Expand Down Expand Up @@ -103,12 +103,12 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
node-version-file: ".nvmrc"

- name: Cypress run critical
uses: cypress-io/github-action@v4
env:
API_URI: ${{github.event.inputs.api_url}}
API_URI: ${{github.event.inputs.api_url}}
APP_MOUNT_URI: ${{ secrets.APP_MOUNT_URI }}
CYPRESS_baseUrl: https://${{needs.deploy.outputs.base_URL}}
CYPRESS_USER_NAME: ${{ secrets.CYPRESS_USER_NAME }}
Expand Down
Loading

0 comments on commit 2139077

Please sign in to comment.