Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run cypress in repeat #2537

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions .github/workflows/cypress-repeat.yml
Original file line number Diff line number Diff line change
@@ -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
Comment on lines +34 to +37
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI they want to switch to v18 at #2533 - you may need to change the CI if it's merged before your PR


- 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}}
4 changes: 2 additions & 2 deletions cypress/support/cypress-grep/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const debug = require("debug")("cypress-grep");
const globby = require("globby");
const { getTestNames } = require("find-test-names");
const fs = require("fs");
const path = require("path");
const { version } = 10;
const { resolveConfig, parseGrep, shouldTestRun } = require("./utils");

Expand Down Expand Up @@ -117,12 +116,13 @@ function cypressGrepPlugin(config) {
}
if (greppedSpecs.length) {
config.specPattern = greppedSpecs;
console.log(config.specPattern);
} else {
// hmm, we filtered out all specs, probably something is wrong
console.warn("grep and/or grepTags has eliminated all specs");
if (grep) {
config.specPattern = "InvalidGrep";
console.warn("grep: %s", grep);
console.error("Invalid grep, tests won't be executed");
}
if (grepTags) {
console.warn("grepTags: %s", grepTags);
Expand Down