forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mitigate flakiness in iOS (facebook#38894)
Summary: Pull Request resolved: facebook#38894 This diff introduces a script `run_with_retry` that we can apply to single commands in order to mitigate the flakiness. This can be useful when networking is involved, to retry installing some dependencies, or for example with some e2e/integration tests. The diff applies this rerun to the iOS tests so we mitigate failures in CI. ## Changelog: [Internal] - Add script to retry CI steps and mitigate iOS flakyness. Reviewed By: cortinico Differential Revision: D48189365 fbshipit-source-id: a0e115754bcdb8f8353bb5f070163f8cf8f7c9cf
- Loading branch information
1 parent
c5ce508
commit ad18f81
Showing
3 changed files
with
41 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @format | ||
*/ | ||
|
||
const {spawnSync} = require('child_process'); | ||
|
||
function retryCommand(maxRetries, command) { | ||
for (let i = 1; i <= maxRetries; i++) { | ||
console.log(`Attempt ${i}: ${command}`); | ||
const result = spawnSync(command, {shell: true, stdio: 'inherit'}); | ||
|
||
if (result.status === 0) { | ||
console.log(`Command succeeded on attempt ${i}`); | ||
process.exit(0); | ||
} else { | ||
console.log(`Command failed on attempt ${i}`); | ||
if (i < maxRetries) { | ||
console.log('Retrying...'); | ||
} else { | ||
console.log('Maximum retries reached. Exiting.'); | ||
process.exit(1); | ||
} | ||
} | ||
} | ||
} | ||
|
||
const maxRetries = process.argv[2]; | ||
const command = process.argv.slice(3).join(' '); | ||
|
||
if (!maxRetries || !command) { | ||
console.log('Usage: node retry_script.js <max_retries> <command>'); | ||
process.exit(1); | ||
} | ||
|
||
retryCommand(maxRetries, command); |
This file was deleted.
Oops, something went wrong.