Feature: Add tags to Cypress tests to enable parallel batch execution in CI without Cy Dashboard #3182
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of the Change
Context
This PR proposes adding
tags
to theCypress
tests to enable selective execution using package@cypress/grep
. The aim is to optimise the CI execution time for the test phase by running two groups of tests based on their historic test execution time.Problem Statement
The job
Cypress - Local
is taking approximately 20m to execute where the test phase is 17m long. The parallel job ofCypress - EP.io
has the similar stats. This increases the wait times for development and reduces dev productivityProposal
Cypress offers out-of-the-box solution for parallel execution of tests in CI as well as without. However, both the solutions require subscription of the Dashboard Service. While Dashboard service has a free tier, it does have a limit in that tier (ref)
The solution in this proposal works around it by introducing
tags
in the tests and using@cypress/grep
to selectively run the tests with desired tags.Using this approach, one can club the tests into multiple batches and run them in parallel using the
matrix
strategy of Github Actions without using the Dashboard Service.Implementation
In this PR, I reviewed the tests to find out the tests which were taking longer than the others and I configured them into multiple batches to carefully optimise in such a fashion that parallelisation can be achieved without creating unbalanced test groups.
The tests which were taking longer than others have been tagged with
@slow
tag and the GitHub workflow file has been updated to run the tests into multiple groups usinggrep
withslow
andinverted grep
with-slow
as per the package documentationResults
A PoC was done with this approach in the repo Automattic/vip-go-mu-plugins by dividing the tests into three groups which brought down the total execution time from an average of 19m to 8m22s.
I attempted to run similarly in this repo as well, however, I think the tests are broken and showing the results of groups may not be correct representation right now. I can see that several "Scheduled E2E" workflow runs have failed due to erroneous tests.
Feedback
I would love to get feedback on this approach and discuss further on the limitations and benefits of this.
How to test the Change
tests/cypress/README.md
to run testsdevelop
branch.npm run cypress:run -- --env grepTags=@slow
andnpm run cypress:run -- --env grepTags=-@slow
develop
branch.Testing in CI:
It can be tested in multiple ways:
workflow_dispatch
events to run the E2E tests workflow in CI for this branchact
to run Github workflows locallypush
event incypress-test.yml
file. Make a commit in that branch to see the E2E running on push event.Changelog Entry
Adds
tags
to theCypress
tests to enable selective execution using package@cypress/grep
. The aim is to optimise the CI execution time for the test phase by running two groups of tests based on their historic test execution time.Checklist: