chore(ci): Set retryOnFailure for RNTester iOS Unit and Integration tests (#44642)

Summary:
On React Native macOS (I am not sure with the current state of React Native), the Xcode Unit and Integration tests are a bit flaky. Rather than set "retry on failure up to 3 times" through the pipeline config (in our case, Azure Pipelines), I realized my earlier PR to use Xcode test plans (https://github.com/facebook/react-native/pull/36443) means we can have Xcode retry the test. This should be faster than retrying it on the pipeline, because it retries just the failing test, not the entire "test" step. I did this on React Native macOS, so I'm doing it upstream so we can remove a diff.

## Changelog:

[INTERNAL] [CHANGED] - Set `retryOnFailure` for Xcode Unit and Integration tests

Pull Request resolved: https://github.com/facebook/react-native/pull/44642

Test Plan: CI should pass (faster)

Reviewed By: cortinico

Differential Revision: D57662523

Pulled By: cipolleschi

fbshipit-source-id: 8de2ab0ea15ba4d38c3b5bf96108c0c7ff5e9f32
This commit is contained in:
Saad Najmi 2024-05-30 07:24:35 -07:00 committed by Facebook GitHub Bot
parent e91a577262
commit c67dfbbe42
4 changed files with 3 additions and 34 deletions

View File

@ -559,7 +559,7 @@ commands:
steps:
- run:
name: "Run Tests: iOS Unit and Integration Tests"
command: node ./scripts/circleci/run_with_retry.js 3 yarn test-ios
command: yarn test-ios
- run:
name: Zip Derived data folder
when: always

View File

@ -127,7 +127,7 @@ runs:
- name: "Run Tests: iOS Unit and Integration Tests"
if: ${{ inputs.run-unit-tests == true }}
shell: bash
run: node ./scripts/circleci/run_with_retry.js 3 yarn test-ios
run: yarn test-ios
- name: Zip Derived data folder
if: ${{ inputs.run-unit-tests == true }}
shell: bash

View File

@ -24,6 +24,7 @@
"identifier" : "13B07F861A680F5B00A75B9A",
"name" : "RNTester"
},
"testRepetitionMode" : "retryOnFailure",
"undefinedBehaviorSanitizerEnabled" : true
},
"testTargets" : [

View File

@ -1,32 +0,0 @@
/**
* 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 {retry} = require('./retry');
async function retryCommand(maxRetries, command) {
const success = await retry(
command,
{shell: true, stdio: 'inherit'},
maxRetries,
0,
);
if (!success) {
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);