Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43323
This fixes a seemingly pre-existent misconfiguration within our `test_ios_template` E2E test setup in CircleCI.
**Background**
We call `npx react-native-community/cli init` with the `--skip-install` flag, as part of the bootstrapping logic in `scripts/e2e/init-template-e2e.js`. This is necessary because we later want to explicitly call `npm install` with a custom `--registry` for our locally mirrored packages (via Verdaccio).
For some reason, we were observing unexpected differences when this was run under CircleCI:
1. Runs `yarn init`
2. Runs a `yarn add` (unknown pkg)
{F1464781818}
https://app.circleci.com/pipelines/github/facebook/react-native/42725/workflows/f648468b-e916-4501-887d-ad293aa6fccf/jobs/1398950
This is causing a Yarn-based install ahead of where we want — ignoring the `--skip-install` flag.
*I'm still unsure on the exact LOC cause in CLI* (but most likely, it's around the Yarn v3 move).
**Impact of this fix**
- The above meant that, when we were bootstrapping `test_ios_template` previously, packages weren't being read from Verdaccio, but **instead from npm** — using the `"0.74.0"` versions from the *previous branch cut* ❌.
- After D54006327, this behaviour became breaking 💀 — since for the 0.74 -> 0.75 cut, we no longer physically published `"0.75.0-main"` (new format) packages to npm.
**This change**
I'm passing `--pm npm` to `npx react-native-community/cli init` to skip around any Yarn behaviour. This appears to have removed the erroneous `yarn` invocations ✅.
Changelog: [Internal]
bypass-github-export-checks
Reviewed By: cortinico, cipolleschi
Differential Revision: D54536848
fbshipit-source-id: 473b11924955f5787c82a6c81d4527d77b810aa5
Summary:
Addresses a gap when using the `set-version` script to update all packages on `main` (i.e. post branch cut):
- Package versions were not being set consistently. It is safe to version all workspace packages, including `"private"`.
- Our publishing workflow is independent from this, and only considers public packages for submission to npm.
- We also need to update the root `package.json`, which includes `devDependencies` referencing workspace dependencies.
Unblocks https://github.com/facebook/react-native/pull/43132.
Changelog: [Internal]
Reviewed By: lunaleaps
Differential Revision: D54419456
fbshipit-source-id: 93eee669c5cf7c2f16b68a2bf41e9a8ace5521bf
Summary:
Make the snapshot output of this test terser (since `set-version` is a superset of the fully tested `set-rn-version` script). Notably, this removes any instances of `generated` from the snapshot file, which would hide the diff in PRs.
Changelog: [Internal]
Reviewed By: lunaleaps
Differential Revision: D54420338
fbshipit-source-id: e4a94b1fda34efaedf1b309496954be35acd5f98
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43133
I noticed inconsistent handling of terminating newlines in D54006327@V1, and had also been noticing `yarn build` reformatting unrelated sections of `package.json` files.
For now, this logic isn't moved to a shared util, since there will likely be a higher level abstraction for the release scripts in the next batch of improvements.
Changelog: [Internal]
Reviewed By: lunaleaps, cipolleschi
Differential Revision: D54007565
fbshipit-source-id: 74d58362a85be4fae2f9e058b6c6622a026ff0a0
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43130
Various fixes/tweaks to the `test-e2e-local` script, impacted by recent changes, found during the release process:
- Fix typo in variable name for `circleciToken` arg.
- Relocate erroneously positioned `process.exit` call (a force exit around Verdaccio, which we will remove in future).
- Add notice on exit around Verdaccio server not being killed successfully (to do in T179377112).
- Switch from Yarn to npm for test project installation — Yarn 3 is not respecting `npmRegistryServer`, see https://github.com/yarnpkg/yarn/issues/2508.
Changelog: [Internal]
Reviewed By: cipolleschi
Differential Revision: D53951606
fbshipit-source-id: f6e29ef6c9ab33ebf60124757576fcb54219f339
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43053
- Relocate under `scripts/e2e/` (also move util used only by this cript).
- Type as Flow (to catch trivial errors). Some cleanup of `log()` calls as errors.
Changelog: [Internal]
Reviewed By: lunaleaps
Differential Revision: D53813023
fbshipit-source-id: 05caf415ec0bf3739a6f7fec3afd385a195f42e9
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43001
More understandable name: ~"React Native init, for E2E testing". Also relocates Verdaccio config and storage location under `scripts/e2e/` (resolving TODO comment).
The intent is for the `scripts/e2e/` dir to also group the existing E2E testing-related scripts — although I will stop here for the current release-related work.
Changelog: [Internal]
Reviewed By: lunaleaps
Differential Revision: D53609332
fbshipit-source-id: fb2f6502a18c4a4ac2368b46af1e3ee42edbadd6
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42899
Updates the `test-e2e-local` script to bootstrap `/tmp/RNTestProject/` using the currently checked out repository as the source of truth for all monorepo packages (previously we only did this for the `react-native` package).
This enables release testers to validate a release **before** physically publishing new dependency versions via `yarn bump-all-updated-packages`.
We are able to reuse the `scripts/template/initialize.js` script that is currently used for E2E validation in CI. This sets up a local Verdaccio server during project install.
NOTE: The time taken for `Build packages` + Verdaccio isn't ideal, I may explore a way to reuse the published package state in a future diff. Until then, this extra time (~1 min) will still be much less pain than the `bump-all-updated-packages` + commit process loop.
Changelog:
[Internal] - Update test-e2e-local to use source monorepo packages for RNTestProject
Reviewed By: lunaleaps
Differential Revision: D53484510
fbshipit-source-id: 600a8a3257a4947d7738ab9d908d6549c38545e6
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43039
Changelog: [Internal] - `publish-npm.js` is a [script we call in our CI](https://www.internalfb.com/code/fbsource/[c0b8566ac0d66c2c0282eeb597bfb54bedf757c6]/xplat/js/react-native-github/.circleci/configurations/jobs.yml?lines=1243) to publish the react-native package and others.
Currently, the script leverages `exit/process.exit` to terminate early in a couple of places which makes the code hard to test because our tests don't truly early exit when `exit/process.exit` is called.
This change removes any explicit `exit` calls and instead leverages the uncaught error to terminate the process and set the non-zero exit code. This makes our tests more accurate to the real control flow of the script.
I've also updated the tests to better capture what we're actually testing by mocking at a higher level.
Reviewed By: cipolleschi
Differential Revision: D53792754
fbshipit-source-id: 9293bb9a95430c50052db36c0e6f6c1ba348107f
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42941
I noticed that programatically running `npm set registry <value>` would fail within the repo root dir (intended run location) (`node` version `18.18.2`).
```
npm ERR! This command does not support workspaces.
```
It turns out this is no longer supported from npm 9.x: https://github.com/npm/cli/issues/6099. **Note**: The workaround discussed in this thread is incompatible/nontrivial with `npx`, so I've opted to remove this behaviour.
**Changes**
- Remove `npm set registry http://localhost:4873` call.
- This is non-breaking due to the [explicit `--registry` arg already present in `run-e2e-ci-tests.js`](b366b4b42e/scripts/run-ci-e2e-tests.js (L102)). The previous `.npmrc` config value is unnecessary, and probably was being ignored (will be validated for this PR in CircleCI run).
- Add comment against remaining `.npmrc` write, convert to `fs` call.
- Remove unused params on `setupVerdaccio` (moved to constants which will be exported and referenced in the next diff).
Changelog: [Internal]
Reviewed By: cipolleschi
Differential Revision: D53609308
fbshipit-source-id: 77d3666b42963cd61f6d3fd0be00cdc19bbb1ec8
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43035
Changelog: [Internal] - We early-exited because of poor copy-pasta and the fact that our tests don't properly emulate the behavior of mock `exit`
Will try and clean this up in next diff but want to quickly fix so it unbreaks nightlies
Reviewed By: yungsters
Differential Revision: D53779109
fbshipit-source-id: ff56e498344fcb4851729d98625b6c7010c73795
Summary:
Changelog: [Internal] - `get-and-update-packages` was deleted in D53487874 also actually published the monorepo packages.
Update publish-npm to publish the updated nightly monorepo packages
Reviewed By: cipolleschi
Differential Revision: D53697621
fbshipit-source-id: 21facb49739ba64c43b921117356715be3d8868a
Summary:
Changelog: [Internal] - We still use the `dry-run` build variant in template tests on CircleCI
Previous diff migrated `set-rn-version` to `set-version` for dry-run, prealpha, and nightly build types. I didn't realize that template test flow used `dry-run` builds. I thought it was just for commitlies (which are deprecated).
To properly migrate this site, I need to fix the template test flow to accept monorepo packages at the same version as the dry-run react-native version (1000-<commithash>)
For now, let's just make this change more precise, and only update the nightly flow
See this error: {F1455663616}
Template test flow doesn't fake publish the monorepo packages at this version -- they're still using the versions off of main
Reviewed By: mdvacca
Differential Revision: D53688238
fbshipit-source-id: 6b64baca7eac842f2207fe13a3046b18459228da
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42958
Changelog: [Internal] - Add support to `set-version` that we can bump the monorepo packages on main
This should be used after we cut a release branch. The release crew should then run
`yarn set-version 0.next.0-main --skip-react-native-version`
This makes sure we don't update `react-native` on main branch and keep it at 1000.0.0
This essentially replaces:
`yarn bump-all-updated-packages --release-branch-cutoff`
in this step: https://reactnative.dev/contributing/release-branch-cut-and-rc0#12-bump-minor-version-of-all-monorepo-packages-in-main
The reason for this change is to consolidate all the places where we update the version to one place, set-version.
Currently we do this in many fragmented places
* bump-all-updated-packages
* set-rn-version
* get-and-update-packages (deleted in the prev diff)
In the future, I want to get rid of `skip-react-native-version` but we'll need to remove the `1000.0.0` nomenclature. This unblocks us to just use this script for now.
bypass-github-export-checks
Reviewed By: huntie
Differential Revision: D53648688
fbshipit-source-id: 4f76366f8d340ec5aeaba1d3a26eba8b18a0166c
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42903
Changelog: [Internal] - Update publish-npm to use `set-version` for nightly builds
Now that `set-version` basically does what `set-rn-version` does, this diff uses this logic for nightlies only (as dry-run/pre-alpha variants are non-functional right now)
This does not change the flow of build-type `'release'` -- that will still use `set-rn-version` via CircleCI ([job](https://fburl.com/code/6xo3ijwg), [script](https://fburl.com/code/bo8np0tb)) We will eventually replace that too but that will be later.
This allows us to delete `get-and-update-packages.js` which was a helper written specifically for updating monorepo packages for nightlies.
The purpose of this is to eventually conform all version updates to use `set-version` in all types of releases (nightlies, stable)
bypass-github-export-checks
Reviewed By: cipolleschi
Differential Revision: D53487874
fbshipit-source-id: 734b528ef5bd095ac68f86701ae105daa30c7d68
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42964
We've seen npm publishes fail occasionally in CI as part of this script, most recently in S391653. This change adds a single retry, per package, during the execution of this script, in an attempt to reduce the chance of manual interventions after a broken pipeline.
Changelog: [Internal]
Reviewed By: cipolleschi
Differential Revision: D53607808
fbshipit-source-id: 526d9c33d51ec57702efba3c199bad313c1bf2d4
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42944
Updates `find-and-publish-all-bumped-packages` to use the npm registry as the source of truth, similar to tools like Lerna (`lerna publish from-package`). **This enables safe reruns of the publish script**, and replaces the previous Git-diff-detection implementation.
Changelog: [Internal]
Reviewed By: lunaleaps
Differential Revision: D53607807
fbshipit-source-id: 135808b7ce36cf463c9f53a8059500b83f8b6679
Summary:
This adds `react-native/metro-config` to the monorepo build tool and emits the missing typescript declarations.
Right now, we do have typescript declarations on `metro-config`, but not `react-native/metro-config`. Which makes everything a bit harder extend from "[the default React Native metro config](https://github.com/facebook/react-native/pull/36502)" in Expo.
> Note, I also added the same `exports` block from `react-native/dev-middleware` for conformity.
One open question here is, why aren't we exporting _all_ helper functions from `metro-config`? To me, its a bit weird that we need both `metro-config` _and_ `react-native/metro-config` as `loadConfig` isn't exported.
## Changelog:
[INTERNAL] [FIXED] - Emit typescript declaration files for `react-native/metro-config`
Pull Request resolved: https://github.com/facebook/react-native/pull/41836
Test Plan:
Run the build tool, and check if the typescript declarations are emitted for `react-native/metro-config`.
```
yarn build metro-config
```
Reviewed By: hoxyq
Differential Revision: D51943453
Pulled By: huntie
fbshipit-source-id: cfaffe5660053fc9a9fcbe3dacf7f6ccc2bde01b
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42897
Changelog: [Internal] - Update nightly flow to use set-version
This change fixes `set-version` to update the `packages/react-native` native source and build files (as `set-rn-version` does) -- this was an oversight but not an issue as `set-version` isn't actually used anywhere right now.
Reviewed By: huntie
Differential Revision: D53463414
fbshipit-source-id: d0d9e4bbe246cccb8643a6ebf9794122bc343433
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42906
Makes way to relocate repo E2E testing + Verdaccio logic under `scripts/e2e/`. The contents of this script are minimal and are better located with `rn-tester-e2e`.
Changelog: [Internal]
Reviewed By: cipolleschi
Differential Revision: D53516117
fbshipit-source-id: e7e50af0383788f2219da190bf921ea93a6455eb
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42783
This change will fix the publishing of Nightlies for React Native with the right version
## Changelog:
[Internal] - Update the package.json of react native correctly.
Reviewed By: cortinico, huntie
Differential Revision: D53309082
fbshipit-source-id: 2fa4d4fdf4f984603c6b3d3690fa3c464ee6d030
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42774
Reorganise release scripts so that command entry points are grouped based on execution context, which also reflects dependencies between scripts.
Also:
- Document the current behaviours of these scripts.
- Relocate utils out of the root contents.
- Replace `exec` call to `set-rn-version` script with function import.
NOTE: `yarn trigger-react-native-release` (documented command in release process) is unchanged, since this is aliased from `package.json`.
```
├── releases
│ ├── templates/
│ ├── utils/
│ ├── remove-new-arch-flags.js
│ ├── set-rn-version.js
│ └── update-template-package.js
├── releases-ci
│ ├── prepare-package-for-release.js
│ └── publish-npm.js
└── releases-local
└── trigger-react-native-release.js
```
Changelog: [Internal]
Reviewed By: cipolleschi
Differential Revision: D53274341
fbshipit-source-id: eec2befc43e7a47fd821b2e2bcc818ddffbb6cf7
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42776
Changelog: [Internal] set all monorepo packages (including react-native) to one version and update all inter-dependencies (including the template)
Reviewed By: huntie
Differential Revision: D53251917
fbshipit-source-id: 95330ca66dcb7234a3f09752ecc3ed9087ced4bf
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42740
Follow-up to a CircleCI breakage introduced by D53001971.
This was missed by both the typechecker (no Flow in file) and CI (no PR-time jobs covering this script).
Changelog: [Internal]
Reviewed By: cortinico, GijsWeterings, cipolleschi
Differential Revision: D53228096
fbshipit-source-id: fbbe1538ee52b8452399d86489239434d3a068be
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42730
Reviewing and modernising this script as part of simplifying our release publish workflow.
- Drop unused `--dependency-versions` arg from CLI entry point
- Simplify templating approach
- Type as Flow
- Drop dependencies on `shelljs` and `yargs`
- Relocate under `scripts/releases/`
- Rewrite tests as snapshot tests
Changelog: [Internal]
Reviewed By: NickGerleman
Differential Revision: D53001971
fbshipit-source-id: e55a71a0bb37e3e18ba1e582a5c46ddd58823d81
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42681
CI failures in Windows JS tests recently (https://github.com/facebook/react-native/pull/41463) were caused by the triggering of Babel registration during tests, due to an import of `packages/dev-middleware` (index), breaking subsequent transformation of other tests.
## Root cause
Example of a problematic import:
a5d8ea4579/packages/dev-middleware/src/__tests__/ServerUtils.js (L15)
..which triggers a Babel registration:
a5d8ea4579/packages/dev-middleware/src/index.js (L16-L18)
That registration behaves differently on Windows due to the `ignore: [/\/node_modules\/\]`, which doesn't match against Windows path separators - Babel matches against system separators.
In particular, this changed whether `node_modules/flow-parser` was transformed when loading the RN Babel transformer. Transforming this file causes a `console.warn` from Babel due to its size:
> [BABEL] Note: The code generator has deoptimised the styling of /Users/robhogan/workspace/react-native/node_modules/flow-parser/flow_parser.js as it exceeds the max of 500KB.
This throws due to our setup:
a5d8ea4579/packages/react-native/jest/local-setup.js (L27)
This all manifests as the first test following a Babel registration (within the same Jest worker) that requires the RN Babel transformer throwing during script transformation.
## This change
This is the minimally disruptive change that makes Babel registration behaviour consistent between Windows and other platforms. The more durable solution here would be *not* to rely on any Babel registration for Jest, which has its own `ScriptTransformer` mechanism for running code from source. Given the fragile way our internal+OSS Babel set up hangs together that's a higher-risk change, so I'll follow up separately.
Changelog: [Internal]
Reviewed By: huntie
Differential Revision: D53124578
fbshipit-source-id: 074a8e139e506a5dceec13f07d412599fb292d92
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42678
Changelog: [internal]
This is a re-application of https://github.com/facebook/react-native/pull/42430, which had to be reverted because of crashes in optimized builds on Android:
```
Abort Reason: terminating due to uncaught exception of type facebook::jni::JniException: java.lang.ClassNotFoundException: com.facebook.react.internal.featureflags.ReactNativeFeatureFlagsProvider
```
The root cause of that was that that class was removed because it wasn't statically referenced from Kotlin/Java, but it was dynamically referenced from C++ (in `ReactNativeFeatureFlagsProviderHolder.cpp`).
This applies the same changes + adds `DoNotStrip` annotations for the affected class and all its methods.
Reviewed By: huntie
Differential Revision: D53122992
fbshipit-source-id: efc4d5636a3f2d39b86e9c098bff408b6688b80b
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42430
This PR creates a new internal feature flags system for React Native. This is only meant to be used internally within the framework, but we might expose it externally in some form in the future to allow customizing specific feature flags in frameworks and applications.
Features:
* 2 types of flags:
* Common: can be overridden from native and are accessible from all layers of the stack (Objective-C/Swift, Java/Kotlin, C++ and JavaScript).
* JS-only: flags that can only be defined and accessed from JS (to allow things like hot reloading without a native build).
* 1 source of truth for each flag.
* Feature flags are application/process scoped (using C++ singletons).
See the `README.md` file in this PR for additional information.
This also adds modifies `run-ci-javascript-tests` to run a new check to make sure that the generate files are in sync with the JSON file that contains the definitions.
Changelog: [internal]
Reviewed By: huntie
Differential Revision: D52806730
fbshipit-source-id: 0ba95803f61ec2f05266ee535921321bf6d3dc6a
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42638
Enables these modules to be covered by `public-api-test`.
- Standardise as CommonJS modules, fixing compatibility with [`flow-api-translator`](https://www.npmjs.com/package/flow-api-translator).
- Use explicit object type in generated file template.
Changelog: [Internal]
Reviewed By: NickGerleman
Differential Revision: D52963967
fbshipit-source-id: c9f3e35f70859c1b99b7297228ee2498f91d9041