Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit c0d3394

Browse files
authored
Fix GA tests pipelines (#2394)
1 parent 9f903a9 commit c0d3394

File tree

5 files changed

+41
-37
lines changed

5 files changed

+41
-37
lines changed

.github/workflows/react-native-code-push-ci.yml

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,16 @@ jobs:
1717
uses: actions/checkout@v3
1818
- name: Start adb server
1919
run: adb devices
20+
- name: Gradle cache
21+
uses: gradle/gradle-build-action@v2
2022
- name: Download system image "android-${{ matrix.api-level }}"
2123
run: $ANDROID_HOME/tools/bin/sdkmanager "system-images;android-${{ matrix.api-level }};google_apis;x86"
2224
- name: Create android emulator
2325
run: $ANDROID_HOME/tools/bin/avdmanager create avd --force --name TestEmulator --abi google_apis/x86 --package 'system-images;android-${{ matrix.api-level }};google_apis;x86' --device "Nexus 6P"
2426
- name: Start android emulator
2527
run: $ANDROID_HOME/emulator/emulator -avd TestEmulator -noaudio -no-window -no-snapshot-save -no-boot-anim -memory 6144 &
26-
- run: sleep 120
28+
- name: Wait for emulator to boot
29+
run: $ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed | tr -d '\r') ]]; do sleep 1; done'
2730
- run: adb shell settings put global window_animation_scale 0.0
2831
- run: adb shell settings put global transition_animation_scale 0.0
2932
- run: adb shell settings put global animator_duration_scale 0.0
@@ -32,34 +35,34 @@ jobs:
3235
with:
3336
distribution: 'microsoft'
3437
java-version: '11'
38+
- name: Setup Ruby
39+
uses: ruby/setup-ruby@v1
40+
with:
41+
ruby-version: '2.7.4'
42+
bundler-cache: true
3543
- name: Package Installation
36-
run: npm i
37-
- name: Install react-native
38-
run: npm install -g react-native
44+
run: npm install
3945
- name: Setup Android tests
4046
run: npm run build:tests && npm run test:setup:android
41-
- name: Remove react-native
42-
run: npm remove -g react-native
43-
- name: Install react-native-cli
44-
run: npm install -g react-native-cli
4547
- name: Run Android test
4648
run: npm run test:fast:android
4749

4850
test-iOS:
4951
name: Test iOS app
5052
runs-on: macos-latest
53+
env:
54+
NO_FLIPPER: ${{ secrets.NO_FLIPPER }}
5155
steps:
5256
- name: Checkout
5357
uses: actions/checkout@v2
54-
- name: Install dependecies
58+
- name: Setup Ruby
59+
uses: ruby/setup-ruby@v1
60+
with:
61+
ruby-version: '2.7.4'
62+
bundler-cache: true
63+
- name: Install dependencies
5564
run: npm install
56-
- name: Install react-native-cli
57-
run: npm install react-native-cli
58-
- name: Install reacti-native
59-
run: npm install react-native
60-
- name: Build tests
61-
run: npm run build:tests
62-
- name: Setup tests
63-
run: npm run test:setup:ios
65+
- name: Setup iOS tests
66+
run: npm run build:tests && npm run test:setup:ios
6467
- name: Run tests
6568
run: npm run test:fast:ios

code-push-plugin-testing-framework/script/platform.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,11 @@ function bootEmulatorInternal(platformName, restartEmulators, targetEmulator, ch
113113
var checkDeferred = Q.defer();
114114
console.log("Checking if " + platformName + " emulator is ready yet...");
115115
// Dummy command that succeeds if emulator is ready and fails otherwise.
116-
checkEmulator()
116+
checkEmulator(targetEmulator)
117117
.then(function () {
118118
checkDeferred.resolve(undefined);
119119
}, function (error) {
120+
console.info(error);
120121
console.log(platformName + " emulator is not ready yet!");
121122
checkDeferred.reject(error);
122123
});
@@ -198,7 +199,7 @@ var AndroidEmulatorManager = (function () {
198199
* Boots the target emulator.
199200
*/
200201
AndroidEmulatorManager.prototype.bootEmulator = function (restartEmulators) {
201-
function checkAndroidEmulator() {
202+
function checkAndroidEmulator(androidEmulatorName) {
202203
// A command that does nothing but only succeeds if the emulator is running.
203204
// List all of the packages on the device.
204205
return testUtil_1.TestUtil.getProcessOutput("adb shell pm list packages", { noLogCommand: true, noLogStdOut: true, noLogStdErr: true }).then(function () { return null; });
@@ -300,9 +301,9 @@ var IOSEmulatorManager = (function () {
300301
testUtil_1.TestUtil.getProcessOutput("xcrun simctl list", { noLogCommand: true, noLogStdOut: true, noLogStdErr: true })
301302
.then((listOfDevicesWithDevicePairs) => {
302303
let listOfDevices = listOfDevicesWithDevicePairs.slice(listOfDevicesWithDevicePairs.indexOf("-- iOS"), listOfDevicesWithDevicePairs.indexOf("-- tvOS"));
303-
let phoneDevice = /iPhone (\S* )*(\(([0-9A-Z-]*)\))/g;
304-
let match = listOfDevices.match(phoneDevice);
305-
deferred.resolve(match[match.length - 1]);
304+
let phoneDevice = /iPhone\ \S*\ ?.*?\(([0-9A-Z-]*)\)/g;
305+
let match = phoneDevice.exec(listOfDevices);
306+
deferred.resolve(match[1]);
306307
}, (error) => {
307308
deferred.reject(error);
308309
});
@@ -323,17 +324,18 @@ var IOSEmulatorManager = (function () {
323324
* Boots the target emulator.
324325
*/
325326
IOSEmulatorManager.prototype.bootEmulator = function (restartEmulators) {
326-
function checkIOSEmulator() {
327+
function checkIOSEmulator(iOSEmulatorId) {
327328
// A command that does nothing but only succeeds if the emulator is running.
328-
// Get the environment variable with the name "asdf" (return null, not an error, if not initialized).
329-
return testUtil_1.TestUtil.getProcessOutput("xcrun simctl getenv booted asdf", { noLogCommand: true, noLogStdOut: true, noLogStdErr: true }).then(function () { return null; });
329+
return testUtil_1.TestUtil.getProcessOutput("xcrun simctl getenv booted SIMULATOR_UDID", { noLogCommand: true, noLogStdOut: true, noLogStdErr: true }).then(function (simUdid) {
330+
return simUdid.trim() == iOSEmulatorId.trim() ? true : Promise.reject(new Error('Waiting for device to boot'));
331+
});
330332
}
331-
function startIOSEmulator(iOSEmulatorName) {
332-
return testUtil_1.TestUtil.getProcessOutput("xcrun instruments -w \"" + iOSEmulatorName + "\"", { noLogStdErr: true })
333+
function startIOSEmulator(iOSEmulatorId) {
334+
return testUtil_1.TestUtil.getProcessOutput("xcrun simctl boot " + iOSEmulatorId, { noLogStdErr: true })
333335
.catch(function (error) { return undefined; /* Always fails because we do not specify a template, which is not necessary to just start the emulator */ }).then(function () { return null; });
334336
}
335337
function killIOSEmulator() {
336-
return testUtil_1.TestUtil.getProcessOutput("killall Simulator").then(function () { return null; });
338+
return testUtil_1.TestUtil.getProcessOutput("xcrun simctl shutdown all").then(function () { return null; });
337339
}
338340
return this.getTargetEmulator()
339341
.then(function (targetEmulator) {

code-push-plugin-testing-framework/script/testConfig.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ exports.TestAppName = "TestCodePush";
1818
exports.TestNamespace = "com.testcodepush";
1919
exports.AcquisitionSDKPluginName = "code-push";
2020
exports.templatePath = path.join(__dirname, "../../test/template");
21-
exports.thisPluginInstallString = TestUtil_1.TestUtil.resolveBooleanVariables(process.env.NPM) ? `npm install ${NPM_PLUGIN_PATH}` : `npm pack ${DEFAULT_PLUGIN_PATH} && npm install ${DEFAULT_PLUGIN_TGZ_NAME}`;
21+
exports.thisPluginInstallString = TestUtil_1.TestUtil.resolveBooleanVariables(process.env.NPM) ? `npm install ${NPM_PLUGIN_PATH}` : `npm pack ${DEFAULT_PLUGIN_PATH} && npm install ${DEFAULT_PLUGIN_TGZ_NAME} && npm link`;
2222
exports.testRunDirectory = process.env.RUN_DIR ? process.env.RUN_DIR: DEFAULT_TEST_RUN_DIRECTORY;
2323
exports.updatesDirectory = process.env.UPDATE_DIR ? process.env.UPDATE_DIR : DEFAULT_UPDATES_DIRECTORY;
2424
exports.onlyRunCoreTests = TestUtil_1.TestUtil.resolveBooleanVariables(process.env.CORE);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"archiver": "latest",
5353
"body-parser": "latest",
5454
"code-push-plugin-testing-framework": "file:./code-push-plugin-testing-framework",
55-
"del": "latest",
55+
"del": "v6.0.0",
5656
"express": "latest",
5757
"mkdirp": "latest",
5858
"mocha": "^9.2.0",

test/test.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ class RNIOS extends Platform.IOS implements RNPlatform {
180180
const infoPlistPath: string = path.join(iOSProject, TestConfig.TestAppName, "Info.plist");
181181
const appDelegatePath: string = path.join(iOSProject, TestConfig.TestAppName, "AppDelegate.m");
182182

183+
183184
// Install the Podfile
184185
return TestUtil.getProcessOutput("pod install", { cwd: iOSProject })
185186
// Put the IOS deployment key in the Info.plist
@@ -229,15 +230,13 @@ class RNIOS extends Platform.IOS implements RNPlatform {
229230

230231
return this.getEmulatorManager().getTargetEmulator()
231232
.then((targetEmulator: string) => {
232-
const hashRegEx = /[(][0-9A-Z-]*[)]/g;
233-
const hashWithParen = targetEmulator.match(hashRegEx)[0];
234-
const hash = hashWithParen.substr(1, hashWithParen.length - 2);
235233
return TestUtil.getProcessOutput("xcodebuild -workspace " + path.join(iOSProject, TestConfig.TestAppName) + ".xcworkspace -scheme " + TestConfig.TestAppName +
236-
" -configuration Release -destination \"platform=iOS Simulator,id=" + hash + "\" -derivedDataPath build EXCLUDED_ARCHS=arm64", { cwd: iOSProject, maxBuffer: 1024 * 1024 * 500, noLogStdOut: true });
234+
" -configuration Release -destination \"platform=iOS Simulator,id=" + targetEmulator + "\" -derivedDataPath build EXCLUDED_ARCHS=arm64", { cwd: iOSProject, timeout: 30 * 60 * 1000, maxBuffer: 1024 * 1024 * 5000, noLogStdOut: true });
237235
})
238236
.then<void>(
239237
() => { return null; },
240-
() => {
238+
(error: any) => {
239+
console.info(error);
241240
// The first time an iOS project is built, it fails because it does not finish building libReact.a before it builds the test app.
242241
// Simply build again to fix the issue.
243242
if (!RNIOS.iosFirstBuild[projectDirectory]) {
@@ -308,7 +307,7 @@ class RNProjectManager extends ProjectManager {
308307
}
309308
mkdirp.sync(projectDirectory);
310309

311-
return TestUtil.getProcessOutput("npx react-native init " + appName, { cwd: projectDirectory, timeout: 30 * 60 * 1000 })
310+
return TestUtil.getProcessOutput("npx react-native init " + appName + " --version 0.67.1", { cwd: projectDirectory, timeout: 30 * 60 * 1000 })
312311
.then((e) => { console.log(`"npx react-native init ${appName}" success. cwd=${projectDirectory}`); return e; })
313312
.then(this.copyTemplate.bind(this, templatePath, projectDirectory))
314313
.then<void>(TestUtil.getProcessOutput.bind(undefined, TestConfig.thisPluginInstallString, { cwd: path.join(projectDirectory, TestConfig.TestAppName) }))
@@ -378,7 +377,7 @@ class RNProjectManager extends ProjectManager {
378377
deferred.resolve(undefined);
379378
});
380379
return deferred.promise
381-
.then(TestUtil.getProcessOutput.bind(undefined, "react-native bundle --platform " + targetPlatform.getName() + " --entry-file index." + targetPlatform.getName() + ".js --bundle-output " + bundlePath + " --assets-dest " + bundleFolder + " --dev false",
380+
.then(TestUtil.getProcessOutput.bind(undefined, "npx react-native bundle --platform " + targetPlatform.getName() + " --entry-file index." + targetPlatform.getName() + ".js --bundle-output " + bundlePath + " --assets-dest " + bundleFolder + " --dev false",
382381
{ cwd: path.join(projectDirectory, TestConfig.TestAppName) }))
383382
.then<string>(TestUtil.archiveFolder.bind(undefined, bundleFolder, "", path.join(projectDirectory, TestConfig.TestAppName, "update.zip"), isDiff));
384383
}

0 commit comments

Comments
 (0)