github-action icon indicating copy to clipboard operation
github-action copied to clipboard

Re-run only failed tests (jobs) for Cloud parallel recording

Open MikeMcC399 opened this issue 1 year ago • 4 comments

  • follows on from and replaces https://github.com/cypress-io/github-action/issues/531

What would you like?

Scenario

A GitHub Actions workflow contains a job using the parallel option of cypress-io/github-action recording to Cypress Cloud which runs Cypress tests in multiple containers.

One or more Cypress tests fail.

GitHub Actions offers the option Re-run failed jobs

image

Enhancement

GitHub Actions and Cypress Cloud should work together so that selecting Re-run failed jobs only re-runs failed jobs using a frozen set of load-balanced Cypress test specs, so that each failed job runs with the same test specs it used in its previous run. The Cypress tests which were distributed to other jobs, and which were previously successful, should not be re-run.

Why is this needed?

Reduce the overhead of re-running flaky tests without also running tests which were previously successful.

Other

The README > parallel documentation section currently states:

If you use the GitHub Actions facility for Re-running workflows and jobs, note that Re-running failed jobs in a workflow is not suited for use with parallel recording into Cypress Cloud. Re-running failed jobs in this situation does not simply re-run failed Cypress tests. Instead it re-runs all Cypress tests, load-balanced over the containers with failed jobs.

To optimize runs when there are failing tests present, refer to optional Cypress Cloud Smart Orchestration Premium features:

  • See previous issue #531 for extensive historical and background reading on this issue.

MikeMcC399 avatar Oct 31 '24 11:10 MikeMcC399

@MikeMcC399 I would like to investigate this issue. Can you confirm if a deep knowledge of Cypress Cloud's "inner workings" (how the parallelization works, etc.) is required?

theomelo avatar Oct 31 '24 18:10 theomelo

@theomelo

Can you confirm if a deep knowledge of Cypress Cloud's "inner workings" (how the parallelization works, etc.) is required?

I can't help you with your question. https://docs.cypress.io/cloud/features/smart-orchestration/parallelization describes the parallel load-sharing process. Although the Cypress code on https://github.com/cypress-io/cypress is open source and online viewable, the Cypress Cloud code, which implements load-sharing, is proprietary to Cypress.io and not shared online. I don't have access to the Cypress Cloud code myself and so I can't say how much you would need to know about it.

MikeMcC399 avatar Nov 01 '24 06:11 MikeMcC399

More than 3 years knowing about this, dozens of messages on the original issue, and no support from Cypress Cloud? That alone, to me, is making me look for e2e browser-based test support elsewhere. That even affects CCTs if you want to run them in parallel... that is, if any flaky test fails either on CCTs or e2e, you literally have to run your entire GHA test suite (all the checks) again.

Anyway, all good, the company probably has a good-ish (in their opinion) reason not address this issue for GHA and Cypress Cloud customers.

brunokrebs avatar Jun 11 '25 21:06 brunokrebs

This issue is not resolvable by changing anything in this repo. It was opened and is left open for the possibility that the Cypress Cloud team might want to respond to it here, although the official route for Cypress Cloud support according to information on the Cypress Help Center page is through Cypress Cloud tickets for customers on a paid plan (Team, Business or Enterprise), and through Discord commmunity support for those using the free tier "Starter" plan.

If parallel recording steps using cypress-io/github-action in a GitHub Actions workflow are replaced with steps that use the Cypress CLI cypress run command instead, then the same issue remains, that the Re-run failed jobs button re-runs all Cypress test specs.

For example, if the steps section in the following snippet using cypress-io/github-action, is replaced:

env:
  CYPRESS_PROJECT_ID: ${{ secrets.EXAMPLE_PROJECT_ID }}
  CYPRESS_RECORD_KEY: ${{ secrets.EXAMPLE_RECORDING_KEY }}
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Using cypress-io/github-action
parallel:
    runs-on: ubuntu-24.04
    strategy:
      fail-fast: false
      matrix:
        containers: [1, 2, 3]
    steps:
      - uses: actions/checkout@v4
      - uses: cypress-io/github-action@v6
        with:
          record: true
          parallel: true

using instead the Cypress CLI:

    steps:
      - uses: actions/checkout@v4
      - run: npm ci
      - run: npx cypress run --record --parallel

then the same problem occurs if Cypress test failures occur, but not in all the containers. The GitHub Actions button Re-run failed jobs re-runs only the failing containers, and Cypress Cloud load-balances all Cypress test-specs across the container sub-set. This indicates that the issue is not coming from cypress-io/github-action.

Even though this isn't the right place for the issue, because it concerns Cypress Cloud software which is not part of this repo, I'm not aware of any alternate place to view open issues that are specific to Cypress Cloud, so at this time I intend to leave it open here.

MikeMcC399 avatar Jun 13 '25 07:06 MikeMcC399