Run cypress in repeat (#2537)

* Run cypress in repeat

* Update .github/workflows/cypress-repeat.yml

Co-authored-by: Anna Szczęch <30683248+szczecha@users.noreply.github.com>

Co-authored-by: Anna Szczęch <30683248+szczecha@users.noreply.github.com>
This commit is contained in:
Karolina Rakoczy 2022-11-09 13:56:50 +01:00 committed by GitHub
parent b0cdfb7545
commit 9d4c198140
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 68 additions and 2 deletions

66
.github/workflows/cypress-repeat.yml vendored Normal file
View file

@ -0,0 +1,66 @@
name: Cypress repeat
on:
workflow_dispatch:
inputs:
spec:
required: false
description: 'Spec to run. Leave empty if you prefer to filter tests using grep'
grep:
required: false
description: 'Run all tests which titles contain text. Leave empty if you prefer to filter tests using spec.'
dashboard_url:
required: true
default: 'https://automation-dashboard.staging.saleor.cloud/dashboard'
description: "Dashboard url"
API_url:
required: true
default: 'https://automation-dashboard.staging.saleor.cloud/graphql/'
description: "API url"
repeat:
required: true
default: "10"
description: "How many times run tests"
jobs:
run-tests:
if: ${{ github.event.inputs.spec }} || ${{ github.event.inputs.grep }} ## Do not run if spec or grep not provided
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16
- name: Install cypress-repeat
run: npm i -D cypress-repeat
- name: Cypress run
id: cypress
uses: cypress-io/github-action@v4
env:
API_URI: ${{ github.event.inputs.API_url}}
APP_MOUNT_URI: ${{ secrets.APP_MOUNT_URI }}
CYPRESS_baseUrl: ${{ github.event.inputs.dashboard_url}}
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 }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CYPRESS_mailHogUrl: ${{ secrets.CYPRESS_MAILHOG }}
COMMIT_INFO_MESSAGE: Cypress repeat with - ${{ github.event.inputs.spec }} ${{ github.event.inputs.grep }} ${{ github.event.inputs.dashboard_url}}
CYPRESS_grep: ${{ github.event.inputs.grep }}
STRIPE_SECRET_KEY: ${{ secrets.STRIPE_SECRET_KEY }}
STRIPE_PUBLIC_KEY: ${{ secrets.STRIPE_PUBLIC_KEY }}
with:
parallel: true
group: 'UI - Chrome'
record: true
tag: Repeat
spec: ${{ github.event.inputs.spec }}
command: npx cypress-repeat -n ${{ github.event.inputs.repeat}}

View file

@ -5,7 +5,6 @@ const debug = require("debug")("cypress-grep");
const globby = require("globby"); const globby = require("globby");
const { getTestNames } = require("find-test-names"); const { getTestNames } = require("find-test-names");
const fs = require("fs"); const fs = require("fs");
const path = require("path");
const { version } = 10; const { version } = 10;
const { resolveConfig, parseGrep, shouldTestRun } = require("./utils"); const { resolveConfig, parseGrep, shouldTestRun } = require("./utils");
@ -117,12 +116,13 @@ function cypressGrepPlugin(config) {
} }
if (greppedSpecs.length) { if (greppedSpecs.length) {
config.specPattern = greppedSpecs; config.specPattern = greppedSpecs;
console.log(config.specPattern);
} else { } else {
// hmm, we filtered out all specs, probably something is wrong // hmm, we filtered out all specs, probably something is wrong
console.warn("grep and/or grepTags has eliminated all specs"); console.warn("grep and/or grepTags has eliminated all specs");
if (grep) { if (grep) {
config.specPattern = "InvalidGrep";
console.warn("grep: %s", grep); console.warn("grep: %s", grep);
console.error("Invalid grep, tests won't be executed");
} }
if (grepTags) { if (grepTags) {
console.warn("grepTags: %s", grepTags); console.warn("grepTags: %s", grepTags);