diff --git a/.github/workflows/cypress-repeat.yml b/.github/workflows/cypress-repeat.yml new file mode 100644 index 000000000..b7b58b4bf --- /dev/null +++ b/.github/workflows/cypress-repeat.yml @@ -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}} \ No newline at end of file diff --git a/cypress/support/cypress-grep/plugin.js b/cypress/support/cypress-grep/plugin.js index 20f34ebd4..45254fab1 100644 --- a/cypress/support/cypress-grep/plugin.js +++ b/cypress/support/cypress-grep/plugin.js @@ -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"); @@ -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);