[8.12] [ci] Add jest retry (#174389) (#174401)

# Backport

This will backport the following commits from `main` to `8.12`:
- [[ci] Add jest retry
(#174389)](https://github.com/elastic/kibana/pull/174389)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT
[{"author":{"name":"Jon","email":"jon@elastic.co"},"sourceCommit":{"committedDate":"2024-01-05T21:25:31Z","message":"[ci]
Add jest retry (#174389)\n\nIf a jest test is flaky, we want to retry a
single step instead of\r\nre-running the entire
pipeline.","sha":"c3983b85a5f83059920aeb0fd0407bcde06664be","branchLabelMapping":{"^v8.13.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Operations","release_note:skip","backport:prev-minor","v8.13.0"],"title":"[ci]
Add jest
retry","number":174389,"url":"https://github.com/elastic/kibana/pull/174389","mergeCommit":{"message":"[ci]
Add jest retry (#174389)\n\nIf a jest test is flaky, we want to retry a
single step instead of\r\nre-running the entire
pipeline.","sha":"c3983b85a5f83059920aeb0fd0407bcde06664be"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.13.0","branchLabelMappingKey":"^v8.13.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/174389","number":174389,"mergeCommit":{"message":"[ci]
Add jest retry (#174389)\n\nIf a jest test is flaky, we want to retry a
single step instead of\r\nre-running the entire
pipeline.","sha":"c3983b85a5f83059920aeb0fd0407bcde06664be"}}]}]
BACKPORT-->

Co-authored-by: Jon <jon@elastic.co>
This commit is contained in:
Kibana Machine 2024-01-05 17:35:21 -05:00 committed by GitHub
parent 4a511ae5b7
commit 254be486a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -218,6 +218,12 @@ export async function pickTestGroupRunOrder() {
if (Number.isNaN(FTR_CONFIGS_RETRY_COUNT)) {
throw new Error(`invalid FTR_CONFIGS_RETRY_COUNT: ${process.env.FTR_CONFIGS_RETRY_COUNT}`);
}
const JEST_CONFIGS_RETRY_COUNT = process.env.JEST_CONFIGS_RETRY_COUNT
? parseInt(process.env.JEST_CONFIGS_RETRY_COUNT, 10)
: 1;
if (Number.isNaN(JEST_CONFIGS_RETRY_COUNT)) {
throw new Error(`invalid JEST_CONFIGS_RETRY_COUNT: ${process.env.JEST_CONFIGS_RETRY_COUNT}`);
}
const FTR_CONFIGS_DEPS =
process.env.FTR_CONFIGS_DEPS !== undefined
@ -417,10 +423,10 @@ export async function pickTestGroupRunOrder() {
},
retry: {
automatic: [
{
exit_status: '-1',
limit: 3,
},
{ exit_status: '-1', limit: 3 },
...(JEST_CONFIGS_RETRY_COUNT > 0
? [{ exit_status: '*', limit: JEST_CONFIGS_RETRY_COUNT }]
: []),
],
},
}
@ -437,10 +443,10 @@ export async function pickTestGroupRunOrder() {
},
retry: {
automatic: [
{
exit_status: '-1',
limit: 3,
},
{ exit_status: '-1', limit: 3 },
...(JEST_CONFIGS_RETRY_COUNT > 0
? [{ exit_status: '*', limit: JEST_CONFIGS_RETRY_COUNT }]
: []),
],
},
}