feat(release-tests): prepare setup script for automated app builds - #4474
feat(release-tests): prepare setup script for automated app builds#4474Loloekk wants to merge 72 commits into
Conversation
| } | ||
|
|
||
| // remove this helper when we drop support for 0.84. | ||
| function canRequireKconv(appPath, { runCommand, logPath }) { |
There was a problem hiding this comment.
| function canRequireKconv(appPath, { runCommand, logPath }) { | |
| function isKconvAvailable(appPath, { runCommand, logPath }) { |
| const gemfile = fs.readFileSync(gemfilePath, 'utf8'); | ||
|
|
||
| if (gemfileHasGem(gemfile, 'nkf')) { | ||
| // if the gemfile has the gem name, return |
There was a problem hiding this comment.
this comment doesn't add any value, should be removed
| } | ||
|
|
||
| if (canRequireKconv(appPath, { runCommand, logPath })) { | ||
| // if the gem can require kconv, return |
There was a problem hiding this comment.
this comment doesn't add any value, should be removed
| `\n⚠️ Gemfile is missing 'nkf' (required to load kconv). Adding it...`, | ||
| ); | ||
| runCommand('bundle', ['add', 'nkf'], appPath, logPath); | ||
| // `bundle add nkf` deafult make bundle install, so we don't need to run it again |
There was a problem hiding this comment.
I'd put it above the line it touches; in this form, it can cause some confusion about whether there was some content below that comment at some point
| ['exec', 'ruby', '-e', "require 'kconv'"], | ||
| appPath, | ||
| logPath, | ||
| true, |
There was a problem hiding this comment.
not sure about that, because it will produce an error in the output for which we make recovery internally. putting some log before that's indicating that this command might fail is good enough for me.
| `\n⚠️ Gemfile is missing 'nkf' (required to load kconv). Adding it...`, | ||
| ); | ||
| runCommand('bundle', ['add', 'nkf'], appPath, logPath); | ||
| // `bundle add nkf` deafult make bundle install, so we don't need to run it again |
| const METRO_PORT = 8081; | ||
|
|
||
| function formatCommand(file, args = []) { | ||
| return [file, ...args].join(' '); |
There was a problem hiding this comment.
The formatting should include quoting
function formatCommand(file, args = []) {
return [file, ...args].join(' ');
}
console.log(formatCommand("file", ["--flag", "some value with spaces"]))
when you'll have some value with spaces and just copy and paste the output to the console, some value with spaces will be treated by the shell as a list of subsequent arguments
|
|
||
| function isMetroRespondingOnPort(port) { | ||
| try { | ||
| const response = execSync( |
| } | ||
|
|
||
| function sleepSync(ms) { | ||
| Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms); |
There was a problem hiding this comment.
these exceptions https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/wait#exceptions aren't problematic in our case, right?
There was a problem hiding this comment.
Yes. It may throw if we use it incorrectly, or if the current thread cannot be blocked. In our case we use it correctly, and the thread our script runs on can always be blocked because it is run by Node.
cff6821 to
6b004a5
Compare
6b004a5 to
544ab1a
Compare
|
I decided to force the user to use a reference type every time, instead of the current option. The script also does not try to fetch from origin if the target is absent locally. To fetch the target from origin, --force-fetch is required. Fetch only if -f is used: e78b08e |
Description
Adds a
release_testssetup script that creates a fresh React Native app and builds it against a chosen React Native version andreact-native-screensversion. This makes release verification faster and more repeatable without manually wiring each playground app.Usage
node release_tests/create_playground.js node release_tests/create_playground.js -h # full helpSetup options
-r/--rn-version)-s/--screens-version) — use the current worktree (current), or a branch, tag, or commit from the local/remote react-native-screens repository. By default the script take a local ref.-o/--from-origin) — take RNS from the remote repository-e/--example-app) — one of the examples:tabsAndStack— Stack v5 (RNS 5.x)tabsAndStack4.x— legacy Stack v4 + Tabsempty— keep the default RN app-a/--app-name) sets the name of the created app-h/--help) — explains all flagsRunning the app
After setup, the script can build and launch the app with
--run. Run-related flags are only allowed when--runis set.-v) —debugorrelease-p) —ios,android, orboth--ios-simulator,--ios-device,--ios-udid,--android-device). At most one device can be selected per platform.Notes
kconvlibrary. Older RN versions (e.g. around 0.84) don’t pull it in automatically. Ruby < 3.4 provides it via the stdlib; on Ruby 3.4+ with those RN versions, setup fails without it. The script detects this and adds thenkfgem (which includeskconv).8081.--android-deviceexpects an adb id fromadb devices(e.g.emulator-5554), not the AVD name. If the emulator is not running, the build may still succeed but the app will not launch.currentare cloned into a temporary folder and prepared there.App.tsxandsrc/(if present) are copied.npx @react-native-community/cli@latest init ${appName} --version ${rnVersion} --skip-installsetup.log.Test plan
1. Conflicting / invalid flags
node release_tests/create_playground.js -s current -onode release_tests/create_playground.js -v releasenode release_tests/create_playground.js -p iosnode release_tests/create_playground.js --ios-simulator "iPhone 17"node release_tests/create_playground.js --run --ios-simulator "iPhone 17" --ios-device "Karol"node release_tests/create_playground.js --run -p ios --android-device "emulator-5554"node release_tests/create_playground.js --run -p android --ios-simulator "iPhone 17"2. Happy paths
Setup only (current worktree, default example):
Check
setup.log: init + copytabsAndStack+ pack/install current screens; no native build.Setup + run both platforms:
Check log: Metro 8081 freed, Android/iOS launch, Ruby 3.4
nkfhandling if needed, navigation works.Legacy 4.x + force-fetch:
node release_tests/create_playground.js -r 0.84.0 -s branch:4.26-stable -f -e tabsAndStack4.x -a SmokeLegacy --run -p ios --ios-simulator "iPhone 17"Check log: remote clone (not current pack), app runs.
Commit + release:
node release_tests/create_playground.js -r 0.84.0 -s commit:886754c6e0387c9a486c8c6f601abf7957557763 -f -a SmokeGamma --run -v release -p ios --ios-simulator "iPhone 17" -e tabsAndStack4.xCheck log:
--mode Release, app runs.Empty example, Android only:
node release_tests/create_playground.js -e empty -s tag:4.27.0 -f -a SmokeEmpty --run -p android --android-device "emulator-5554"Check log: no example copy, no iOS steps, Android launches.
Checklist