From 16297593632a9418a7bdd04369981c6d5016a443 Mon Sep 17 00:00:00 2001 From: Andrew Goldis Date: Sat, 31 Aug 2024 13:13:45 -0700 Subject: [PATCH] feat: add retries for hard failures (#211) * feat: add retries for hard failures * chore: use default 0 for currentsConfig.retry.hardFailureMaxRetries * chore: add retries to README --- .github/README.md | 7 +++++-- packages/cypress-cloud/lib/cypress/cypress.ts | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/README.md b/.github/README.md index 918d1a8..739d40d 100644 --- a/.github/README.md +++ b/.github/README.md @@ -118,7 +118,7 @@ module.exports = { // Additional headers for network requests, undefined by default networkHeaders: { "User-Agent": "Custom", - "x-ms-blob-type": "BlockBlob" + "x-ms-blob-type": "BlockBlob", }, e2e: { batchSize: 3, // orchestration batch size for e2e tests (Currents only, read below) @@ -126,6 +126,9 @@ module.exports = { component: { batchSize: 5, // orchestration batch size for component tests (Currents only, read below) }, + retry: { + hardFailureMaxRetries: 2, // max retries for hard Cypress failures, a hard failure is when Cyrpess crashes and doesn't report back any results (see https://docs.cypress.io/guides/guides/module-api#Handling-errors) + }, }; ``` @@ -162,7 +165,7 @@ The configuration variables will resolve as follows: ## Batched Orchestration -This package uses its own orchestration and reporting protocol that is independent of cypress native implementation. The new [orchestration protocol]([https://currents.dev/readme/integration-with-cypress/cypress-cloud#batched-orchestration](https://currents.dev/readme/integration-with-cypress/cypress-cloud/batched-orchestration)) uses cypress in "offline" mode and allows batching multiple spec files for better efficiency. You can adjust the batching configuration in `currents.config.js` and use different values for e2e and component tests. +This package uses its own orchestration and reporting protocol that is independent of cypress native implementation. The new [orchestration protocol](<[https://currents.dev/readme/integration-with-cypress/cypress-cloud#batched-orchestration](https://currents.dev/readme/integration-with-cypress/cypress-cloud/batched-orchestration)>) uses cypress in "offline" mode and allows batching multiple spec files for better efficiency. You can adjust the batching configuration in `currents.config.js` and use different values for e2e and component tests. ## API diff --git a/packages/cypress-cloud/lib/cypress/cypress.ts b/packages/cypress-cloud/lib/cypress/cypress.ts index 24a1819..c9dfce9 100644 --- a/packages/cypress-cloud/lib/cypress/cypress.ts +++ b/packages/cypress-cloud/lib/cypress/cypress.ts @@ -59,9 +59,10 @@ export async function runSpecFile( let retries = 0; const currentsConfig = await getCurrentsConfig(); + while ( currentsConfig.retry && - retries < currentsConfig.retry.hardFailureMaxRetries && + retries < (currentsConfig.retry.hardFailureMaxRetries ?? 0) && result.status === "failed" ) { warn("Cypress runner failed with message: %s", result.message);