Commit Graph

1000 Commits

Author SHA1 Message Date
Alex Hunt
a4d6be8908 Update set-version to reuse set-rn-version (#43109)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43109

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D53940616

fbshipit-source-id: 8ce85437ab5164dae81a9956706c517880ee1f74
2024-02-20 05:06:03 -08:00
Alex Hunt
cffb69a12b Fix path in trigger-react-native-release (#43107)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43107

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D53940161

fbshipit-source-id: 0de7887ff117db6f876420c1b609924bfc237847
2024-02-20 04:22:55 -08:00
Alex Hunt
1b504382c1 Fix import in bump-all-updated-packages, add Flow (#43106)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43106

Missed import in untyped, untested script during recent file move.

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D53940160

fbshipit-source-id: ec86c5881a2f34d992538c713f808c8d5634ba16
2024-02-20 04:22:55 -08:00
Luna Wei
8ff05b5a18 Remove release-branch-cutoff from yarn bump-all-updated-packages (#43040)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43040

Changelog: [Internal] Remove release-branch-cutoff option as its been replaced by `yarn set-version --skip-react-native-version`

Reviewed By: huntie

Differential Revision: D53742450

fbshipit-source-id: 726479698ec4f4f61d9a1ddde95e246e033f864c
2024-02-16 15:57:37 -08:00
Alex Hunt
98ea5ea29b Refactor set-version to use new getPackages util (#43072)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43072

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D53851089

fbshipit-source-id: 6305f7404a43a8da8bfe84137921437423be7985
2024-02-16 10:41:04 -08:00
Alex Hunt
80ec096e7c Create shared consts module for scripts
Summary:
Tidy up, removes risk of breakage when relocating inner modules.

Changelog: [Internal]

Reviewed By: lunaleaps

Differential Revision: D53813025

fbshipit-source-id: 43dc4a57191363546d6858cff311e260d416192f
2024-02-16 03:21:25 -08:00
Alex Hunt
a80674fc7c Relocate run-ci-e2e-tests script, add Flow (#43053)
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
2024-02-15 14:51:48 -08:00
Alex Hunt
fb446598f9 Rename E2E template init script, relocate Verdaccio config + storage (#43001)
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
2024-02-15 14:51:48 -08:00
Alex Hunt
e4135e9be5 Update test-e2e-local to use source monorepo packages for RNTestProject (#42899)
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
2024-02-15 13:04:00 -08:00
Luna Wei
d6a440ee8b Remove process.exit calls from publish-npm and throw errors instead (#43039)
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
2024-02-15 11:18:05 -08:00
Alex Hunt
24f7bd7445 Remove .npmrc write from setupVerdaccio util (#42941)
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
2024-02-15 09:06:44 -08:00
Alex Hunt
afc61ab643 Fix test-e2e-local when building artifacts locally (#43043)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43043

Restores behaviour of `yarn test-e2e-local` when we are not using `--circleciToken`. The `npm pack` logic (necessary for the subsequent `updateTemplatePackage` call before initing `RNTestProject`) was deleted in https://github.com/facebook/react-native/pull/41172 / D50651448.

4eed12b7df (diff-56f57bf0eac99b0fda1b2938aceb8d9b663db82c07cb405bd53a01c8689710ffL224-L240)

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D53806191

fbshipit-source-id: 918306d5dea90266292728cda9c0e243e5c37eba
2024-02-15 09:06:44 -08:00
Luna Wei
b8ad91732f fix nightlies dont exit early (#43035)
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
2024-02-14 14:32:21 -08:00
Alex Hunt
a68ae2e2cc Rename and document monorepo publish script (#42989)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42989

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D53607805

fbshipit-source-id: 8bbf82c02b54b20404de834800ae49d3fa43baee
2024-02-14 02:57:36 -08:00
Luna Wei
23a66444f7 Fix nightly publish
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
2024-02-13 12:21:20 -08:00
Alex Hunt
d243cd9ca9 Add Flow and document template init script, simplify args (#42898)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42898

- Add Flow, switch from `yargs` to `parseArgs` (built-in to Node.js, Flow-safe).
- Document script via `--help` output (relevant ahead of reusing this script for local release testing).
- Relocate and add Flow to `setup-verdaccio.js` util.

Also:
- Remove `--reactNativeRootPath` arg.
- Tweak other arg names.

Changelog: [Internal]

Reviewed By: lunaleaps

Differential Revision: D53484322

fbshipit-source-id: d828e5606bbff032109ecccca9c8f8e337d78626
2024-02-13 02:32:21 -08:00
Luna Wei
8a94bf0dba Fix CircleCI template tests by excluding dry-run build types
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
2024-02-12 18:42:26 -08:00
Luna Wei
2090fe5cf8 Add support for bumping packages on main after release cut (#42958)
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
2024-02-12 12:07:51 -08:00
Luna Wei
34abd79475 Use set-version for nightly publishes (#42903)
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
2024-02-12 12:07:51 -08:00
Alex Hunt
d190ccafd3 Add retry to monorepo publish script (#42964)
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
2024-02-12 10:43:48 -08:00
Alex Hunt
273a5177e0 Use npm as source of truth for updated packages (make publish script rerunnable) (#42944)
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
2024-02-12 10:43:48 -08:00
Alex Hunt
b41a33ede9 Move metro-config package into monorepo build, enable TS generation (#41836)
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
2024-02-12 05:20:38 -08:00
Alex Hunt
49c3c3412a Refactor package discovery in publish script (#42938)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42938

Substitutes the `forEachPackage` util with a replacement async `getPackages` function. This will be used further in the next diff.

The new function aims to be more erganomic/versatile than `forEachPackage` by returning a package mapping (see updated test mock). The API aligns roughly with `yarn workspaces list` and [Lerna's `detectProjects`](https://lerna.js.org/docs/api-reference/utilities#detectprojects).

This also aligns with / replaces similar attempts in our existing scripts:
- [`getPackagesToPublish`](2ca7bec0c2/scripts/monorepo/get-and-update-packages.js (L56))
- [`getPublicPackages`](2ca7bec0c2/scripts/releases/set-version/index.js (L19))

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D53607806

fbshipit-source-id: 00ec34edadab863dc8f2f0c7852f6e835a5dddf5
2024-02-12 04:42:27 -08:00
Alex Hunt
56f483ccad Update exit cases for monorepo publish script (#42937)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42937

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D53607810

fbshipit-source-id: 18e79f23060ee70e96bd8ac6e9995b0a8ba300b3
2024-02-12 04:42:27 -08:00
Alex Hunt
b25be6687e Add Flow, add positive test case for monorepo publish step (#42936)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42936

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D53607809

fbshipit-source-id: 990826fda5538af9a13e3f24978295a2f3b0c8c3
2024-02-12 04:42:27 -08:00
Luna Wei
68e6a94538 Fixset-version to also update packages/react-native source (#42897)
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
2024-02-09 21:35:18 -08:00
Alex Hunt
f0d1d9214d Relocate RNTester E2E wrapper script under package (#42906)
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
2024-02-07 08:31:29 -08:00
Alex Hunt
009542f4ee Move release testing scripts into subdirectory (#42900)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42900

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D53471278

fbshipit-source-id: 56b16c20b85c88577e5d899b0e85d078ab8aa51f
2024-02-07 05:40:26 -08:00
Riccardo Cipolleschi
7c5e4262d4 Fix publishing of React Native with the right version (#42783)
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
2024-02-01 07:40:11 -08:00
Alex Hunt
76598de621 Reorganise and document release script entry points (#42774)
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
2024-02-01 06:02:17 -08:00
Luna Wei
ebc2831d5b set unified version (#42776)
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
2024-01-31 19:32:08 -08:00
Alex Hunt
b7b55854fe Enable Flow on misc release scripts (#42736)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42736

- Minimally enable Flow in these scripts. This would have caught outdated imports in D53001971 and D53228096.
- Update `publish-npm` script with async `main()` function.
- Also delete leftover `ReactNativeVersion.js.template` file.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D53225162

fbshipit-source-id: 9521291b7c84728e3e05af510ebf3244a9a189e5
2024-01-31 03:36:02 -08:00
Alex Hunt
2f818b464f Fix import in publish-npm script (#42740)
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
2024-01-30 10:59:02 -08:00
Alex Hunt
e97ba475aa Relocate and refactor set-rn-version script (#42730)
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
2024-01-30 06:46:50 -08:00
Rob Hogan
41b256a776 Babel-ignore node_modules on Windows consistently with others (#42681)
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
2024-01-27 06:49:15 -08:00
Rubén Norte
5e66f41697 Implement new feature flag system (re-land) (#42678)
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
2024-01-26 09:55:27 -08:00
David Vacca
ffaeaba213 Back out "Implement new feature flag system"
Summary:
Original commit changeset: 0ba95803f61e

Original Phabricator Diff: D52806730

bypass-github-export-checks

changelog: [internal] internal

Reviewed By: yungsters

Differential Revision: D53113947

fbshipit-source-id: ace1222a861a739fcd3f4b0e12c135db47a93344
2024-01-25 21:52:59 -08:00
Rubén Norte
705c675d51 Implement new feature flag system (#42430)
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
2024-01-25 13:55:11 -08:00
szymonrybczak
78967b33c0 Bump CLI to 13.5.1 (#42183)
Summary:
Updates CLI to v13.5.1.

## Changelog:

[GENERAL] [CHANGED] - Bump CLI to 13.5.1

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

Test Plan: CI

Reviewed By: christophpurrer

Differential Revision: D52600707

Pulled By: huntie

fbshipit-source-id: f314a405d8d7e9200595b42b62d354e61f0a2964
2024-01-25 02:32:45 -08:00
Alex Hunt
02e7244b3d Improve types, fix translator compatibility for version-related modules (#42638)
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
2024-01-25 02:32:00 -08:00
Luna Wei
f322dc7a84 Typing scripts used for test-e2e-local (#42610)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42610

Changelog: [Internal] Adding more typing to internal scripts used by test-e2e-local

Reviewed By: NickGerleman

Differential Revision: D52988733

fbshipit-source-id: 6e187b7c9560b30def014e8932ab82ed07cf8488
2024-01-24 15:39:06 -08:00
Luna Wei
3d097d46e3 Type circle-ci-artifacts-util (#42608)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42608

Changelog: [Internal] - Type circle-ci-artifacts-util and migrate it to node-fetch

Reviewed By: NickGerleman

Differential Revision: D52932555

fbshipit-source-id: 50e874e23fe8131a9376845006dab3116aed8a04
2024-01-24 15:39:06 -08:00
Nicola Corti
a13d51ff1c Remove dead android scripts (#42612)
Summary:
Those scripts are all dead, and should not be used anymore.
I'm removing them.

## Changelog:

[INTERNAL] - Remove dead android scripts

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

Test Plan: n/a

Reviewed By: cipolleschi

Differential Revision: D52997852

Pulled By: cortinico

fbshipit-source-id: cf57177eedb8bc0f40daf7c6c5fcd1d5ba89ba32
2024-01-23 03:03:08 -08:00
Luna Wei
0851f04353 Flow type some util files (#42372)
Summary:
Changelog: [Internal] Flow comment type some util scripts

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

Reviewed By: NickGerleman

Differential Revision: D52893759

Pulled By: lunaleaps

fbshipit-source-id: 6a3632f2c0b9faa97a451d82ef5a888bb5be81fa
2024-01-22 10:29:54 -08:00
Moti Zilberman
50157310ba Fail run-ci-e2e-tests on package build errors (#42287)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42287

Changelog: [Internal]

`run-ci-e2e-tests.js` currently skips past package build errors and tries to keep going. At best, this fails somewhere downstream of a build error (without any clear diagnostics as to why). At worst, this can miss errors entirely.

Here we extend the script's existing error handling behaviour to cover errors during the build script. It's probably worth following up to make sure all unexpected failures bubble up and stop the script, as opposed to the current error-swallowing default.

Reviewed By: hoxyq

Differential Revision: D52785131

fbshipit-source-id: 08deedfdf5b3d3cb63e77c74b47eb75570a58fbb
2024-01-15 10:07:43 -08:00
Dmitry Rykun
be0c353e18 CocoaPods: simplify iOS build directory cleanup (#42233)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42233

This diff removes the need for providing the `ios_folder` argument to `use_react_native`. We no longer do any manual path tranformations to get the iOS project root.
Instead we use `Pod::Config.instance.installation_root` which always points to the correct directory.

Changelog: [iOS][Breaking] - CocoaPods: remove the `ios_folder` argument from the `use_react_native` function.

Reviewed By: cipolleschi

Differential Revision: D52659429

fbshipit-source-id: 67c79cd9d74a0351ad2c242b74cbd48b6bd2dc94
2024-01-10 08:38:50 -08:00
Luna Wei
fe0306d637 Support specifying dist-tags for monorepo package bumps (#42146)
Summary:
Currently our CI will auto-tag any `npm publish` as `latest` for the monorepo packages. This is because [we do not specify a tag](https://github.com/facebook/react-native/blob/main/scripts/monorepo/find-and-publish-all-bumped-packages.js#L104), so npm will [default to `latest`](https://docs.npmjs.com/cli/v10/commands/npm-dist-tag#description). We encountered a similar issue for `react-native` awhile ago and fixed that with [always specifying a tag](https://github.com/facebook/react-native/blob/main/scripts/npm-utils.js#L84), with the explicit opt-in for `latest`.

yarn and npm will resolve `*` dependencies using `latest`. This will be a problem for any React Native version that uses `*` deps. We have actively tried to remove these `*` versions but older patches may still contain them.

When we do a monorepo package bump, it may be for 0.71 and for a user who is initializing a 0.72 version project (that still has * deps), they will receive monorepo packages of version `0.71.x`, which is not compatible. (React Native monorepo packages do not faithfully follow semver)

This change allows us to specify what tags to use and suggest tags based on what branch you are on and asks for confirmation

```
> branch 0.73-stable
? Select suggested npm tags. (Press <space> to select, <a> to toggle all, <i> to invert selection)
❯◉ "0.73-stable"
 ◉ "latest"
? Confirm these tags for *ALL* packages being bumped: "0.73-stable","latest" (Y/n)

> branch 0.72-stable
? Select suggested npm tags. (Press <space> to select, <a> to toggle all, <i> to invert selection)
❯◉ "0.72-stable"
 ◯ "latest"
? Confirm these tags for *ALL* packages being bumped: "0.72-stable" (Y/n)

> branch main
? Select suggested npm tags. (Press <space> to select, <a> to toggle all, <i> to invert selection)
❯◉ "nightly"
? Confirm these tags for *ALL* packages being bumped: "nightly" (Y/n)
```

## Changelog:

[INTERNAL] [CHANGED] - Support dist-tags in publishing monorepo packages to avoid default "latest" tag.

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

Test Plan: `yarn test scripts/`

Reviewed By: NickGerleman

Differential Revision: D52551769

Pulled By: lunaleaps

fbshipit-source-id: 52f923464387cffdc6ca22c6f0a45425965a3680
2024-01-08 08:38:53 -08:00
Luna Wei
05ec058ac5 Add print-packages as a command (#41959)
Summary:
Working on releases, I'm often looking for the name of our monorepo packages (as sometimes the name doesn't align with the directory) and also getting a list of the versions of everything, as well as if its private/public -- which I've interpreted to mean that we publish it or we don't. I thought this might be convenient to add.

## Changelog:
[Internal] - Add `print-packages` as a command to print our monorepo packages (including react-native)

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

Test Plan:
```
❯ yarn print-packages
yarn run v1.22.19
$ node ./scripts/monorepo/print
┌─────────┬─────────┬─────────────────────────────────────────┬────────────────┐
│ (index) │ Public? │                  Name                   │ Version (main) │
├─────────┼─────────┼─────────────────────────────────────────┼────────────────┤
│    0    │  ''   │     'react-native/assets-registry'     │    '0.74.0'    │
│    1    │  ''   │  'react-native/babel-plugin-codegen'   │    '0.74.0'    │
│    2    │  ''   │  'react-native/community-cli-plugin'   │    '0.74.0'    │
│    3    │  ''   │    'react-native/debugger-frontend'    │    '0.74.0'    │
│    4    │  ''   │     'react-native/dev-middleware'      │    '0.74.0'    │
│    5    │  ''   │      'react-native/eslint-config'      │    '0.74.0'    │
│    6    │  ''   │      'react-native/eslint-plugin'      │    '0.74.0'    │
│    7    │  ''   │   'react-native/eslint-plugin-specs'   │    '0.74.0'    │
│    8    │  ''   │ 'react-native/hermes-inspector-msggen' │    '0.72.0'    │
│    9    │  ''   │      'react-native/metro-config'       │    '0.74.0'    │
│   10    │  ''   │    'react-native/normalize-colors'     │    '0.74.1'    │
│   11    │  ''   │      'react-native/js-polyfills'       │    '0.74.0'    │
│   12    │  ''   │             'react-native'              │   '1000.0.0'   │
│   13    │  ''   │      'react-native/babel-preset'       │    '0.74.0'    │
│   14    │  ''   │ 'react-native/metro-babel-transformer' │    '0.74.0'    │
│   15    │  ''   │          'react-native/bots'           │    '0.0.0'     │
│   16    │  ''   │         'react-native/codegen'         │    '0.74.0'    │
│   17    │  ''   │ 'react-native/codegen-typescript-test' │    '0.0.1'     │
│   18    │  ''   │      'react-native/gradle-plugin'      │    '0.74.0'    │
│   19    │  ''   │         'react-native/tester'          │    '0.0.1'     │
│   20    │  ''   │       'react-native/tester-e2e'        │    '0.0.1'     │
│   21    │  ''   │    'react-native/typescript-config'    │    '0.74.0'    │
│   22    │  ''   │    'react-native/virtualized-lists'    │    '0.74.0'    │
└─────────┴─────────┴─────────────────────────────────────────┴────────────────┘
  Done in 0.55s.
```

Also added filter flag for private/public
```
❯ yarn print-packages --type private
yarn run v1.22.19
$ node ./scripts/monorepo/print --type private
┌─────────┬─────────┬─────────────────────────────────────────┬────────────────┐
│ (index) │ Public? │                  Name                   │ Version (main) │
├─────────┼─────────┼─────────────────────────────────────────┼────────────────┤
│    0    │  ''   │ 'react-native/hermes-inspector-msggen' │    '0.72.0'    │
│    1    │  ''   │          'react-native/bots'           │    '0.0.0'     │
│    2    │  ''   │ 'react-native/codegen-typescript-test' │    '0.0.1'     │
│    3    │  ''   │         'react-native/tester'          │    '0.0.1'     │
│    4    │  ''   │       'react-native/tester-e2e'        │    '0.0.1'     │
└─────────┴─────────┴─────────────────────────────────────────┴────────────────┘
  Done in 0.16s.
```

Also added a npm query where you can see the latest published version of a minor
```
❯ yarn print-packages --type public --minor 72
yarn run v1.22.19
$ node ./scripts/monorepo/print --type public --minor 72
┌─────────┬─────────┬─────────────────────────────────────────┬────────────────┬──────────────────────────────────────┐
│ (index) │ Public? │                  Name                   │ Version (main) │             Version (72)             │
├─────────┼─────────┼─────────────────────────────────────────┼────────────────┼──────────────────────────────────────┤
│    0    │  ''   │     'react-native/assets-registry'     │    '0.74.0'    │               '0.72.0'               │
│    1    │  ''   │  'react-native/babel-plugin-codegen'   │    '0.74.0'    │               '0.72.3'               │
│    2    │  ''   │  'react-native/community-cli-plugin'   │    '0.74.0'    │ 'No match found for version ^0.72.0' │
│    3    │  ''   │    'react-native/debugger-frontend'    │    '0.74.0'    │ 'No match found for version ^0.72.0' │
│    4    │  ''   │     'react-native/dev-middleware'      │    '0.74.0'    │ 'No match found for version ^0.72.0' │
│    5    │  ''   │      'react-native/eslint-config'      │    '0.74.0'    │               '0.72.2'               │
│    6    │  ''   │      'react-native/eslint-plugin'      │    '0.74.0'    │               '0.72.0'               │
│    7    │  ''   │   'react-native/eslint-plugin-specs'   │    '0.74.0'    │               '0.72.4'               │
│    8    │  ''   │      'react-native/metro-config'       │    '0.74.0'    │              '0.72.11'               │
│    9    │  ''   │    'react-native/normalize-colors'     │    '0.74.1'    │               '0.72.0'               │
│   10    │  ''   │      'react-native/js-polyfills'       │    '0.74.0'    │               '0.72.1'               │
│   11    │  ''   │             'react-native'              │   '1000.0.0'   │               '0.72.8'               │
│   12    │  ''   │      'react-native/babel-preset'       │    '0.74.0'    │ 'No match found for version ^0.72.0' │
│   13    │  ''   │ 'react-native/metro-babel-transformer' │    '0.74.0'    │ 'No match found for version ^0.72.0' │
│   14    │  ''   │         'react-native/codegen'         │    '0.74.0'    │               '0.72.8'               │
│   15    │  ''   │      'react-native/gradle-plugin'      │    '0.74.0'    │              '0.72.11'               │
│   16    │  ''   │    'react-native/typescript-config'    │    '0.74.0'    │ 'No match found for version ^0.72.0' │
│   17    │  ''   │    'react-native/virtualized-lists'    │    '0.74.0'    │               '0.72.8'               │
└─────────┴─────────┴─────────────────────────────────────────┴────────────────┴──────────────────────────────────────┘
```

Reviewed By: cortinico

Differential Revision: D52347140

Pulled By: lunaleaps

fbshipit-source-id: 75811730e1afd5aae2d9fba4e437cd0d3d424a90
2024-01-02 11:46:03 -08:00
Nicola Corti
d992abc56d Move legacy tests from OSS to fbandroid/java/com/facebook/fbreact (#41802)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41802

Those tests are not executing at all, they're just compiled.
Our internal infra is still depending on some bits of it though, so I'm moving them to `fbandroid/java/com/facebook/fbreact

Changelog:
[Internal] [Changed] - Move legacy tests from OSS to  fbandroid/java/com/facebook/fbreact

Reviewed By: rshest

Differential Revision: D51805702

fbshipit-source-id: 2c5cec68efa9854184e981220202d8f356ff690a
2023-12-27 17:34:29 -08:00
Alex Hunt
7eed8816a8 Remove exclude for normalize-colors in template test setup (#42033)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42033

Intends to fix failing `test_*_template` jobs in CircleCI, broken after D52337762.

Changelog: [Internal]

Reviewed By: motiz88, cipolleschi

Differential Revision: D52364225

fbshipit-source-id: 0e088f300fc8f38dc439446a29d81f2bec2e5d51
2023-12-21 05:25:06 -08:00
Nicola Corti
f11608da4e Remove the installArchives task (#41832)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41832

I'm removing the `installArchives` task and all the setup to publish
the Maven Local inside the NPM package as we're not using this entirely
and we won't be able to use it anyway (as the Maven Local is too big to fit an NPM package).

Changelog:
[Internal] [Changed] - Remove the installArchives task

Reviewed By: GijsWeterings

Differential Revision: D51890224

fbshipit-source-id: 3ffdc67a9fe931118596f6f74a5a2df0313ca3f2
2023-12-12 10:55:32 -08:00
Oskar Kwaśniewski
7d1a98c43b Lint source files, sort imports, remove unused imports (#41829)
Summary:
This PR lints source files using eslint. I've executed `yarn lint --fix` and also manually fixed some of eslint issues.

Before:

![CleanShot 2023-12-07 at 12 07 10@2x](https://github.com/facebook/react-native/assets/52801365/2b00cf23-e5a0-46b8-802f-adcb67224111)

After:

![CleanShot 2023-12-07 at 12 06 24@2x](https://github.com/facebook/react-native/assets/52801365/bb05b2c0-2b27-4f99-b7b4-cb47a51a3885)

## Changelog:

[GENERAL] [FIXED] - Lint source files, sort imports, remove unused ones

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

Test Plan: CI Green

Reviewed By: christophpurrer

Differential Revision: D51979074

Pulled By: dmytrorykun

fbshipit-source-id: e11b90721e33f5e9949a0833e5f39fe7ba3d1067
2023-12-11 08:54:29 -08:00
Nick Gerleman
1c57e969fb Test against XCode 14.3 and 15 (#41798)
Summary:
Apple will require XCode 15 next year to ship to the app store, and it aligns with how we build and test React Native internally.

XCode 15 and 14.3 add support for a lot of [missing C++ 20 features](https://developer.apple.com/xcode/cpp/#c++20) from earlier versions as well.

Last I was aware, Riccardo was onboard with bumping min supported in 0.74 to XCode 15. This change does a slightly more conservative bump to min 14.3, and main of 15.0 (though we might want to move these before 0.74 comes out).

All of this will get migrated over to GHA soon enough as well, but... formalizing this is the only thing blocking usage of C++ 20 ranges today.

Changelog:
[ios][breaking] - Require XCode >= 14.3

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

Test Plan:
1. CircleCI Passes
2. Can still boot RNTester from XCode with code signing related changes.

Reviewed By: cortinico

Differential Revision: D51840617

Pulled By: NickGerleman

fbshipit-source-id: 58f8951a436eb7c892a00432a8aad0ddd0a49da1
2023-12-05 15:35:05 -08:00
Thibault Malbranche
84b0027028 feat: improve e2e local testing script (#41751)
Summary:
iOS?ios?android?Android?
Always making typos when using the local testing script with the platform argument... No more!

## Changelog:

[INTERNAL][ADDED] - Improved E2E local testing script to be more flexible

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

Reviewed By: cortinico

Differential Revision: D51758529

Pulled By: huntie

fbshipit-source-id: d9e633567a59fcfac1057cf1f21714ccef27ebb2
2023-12-01 10:32:55 -08:00
Gijs Weterings
73411f4e08 Back out "Restore InspectorProxy tests - fix Windows by Babel-ignoring node_modules consistently"
Summary: Changelog: Internal

Reviewed By: gsathya

Differential Revision: D51447333

fbshipit-source-id: 56eb839671ca62269d59d48fd3c83df4f42a5111
2023-11-18 02:04:44 -08:00
Rob Hogan
59a2282b29 Restore InspectorProxy tests - fix Windows by Babel-ignoring node_modules consistently (#41526)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41526

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: D51424802

fbshipit-source-id: 8b733c0c159ee84690aef04abced682d126c6d27
2023-11-17 08:53:14 -08:00
Riccardo Cipolleschi
bb4e940b6d Configure E2E tests to run on a commit that contains #run-e2e-tests (#41308)
Summary:
This change allow our CI to run E2E tests using a specific tag in the commit message

## Changelog:
[Internal] - Allow to run e2e test using a specific tag in the last commit message

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

Test Plan:
CircleCI is green
Tested interacting with the PR/branch

Reviewed By: NickGerleman

Differential Revision: D50975588

Pulled By: cipolleschi

fbshipit-source-id: 6318800d7e86e1cab394af2b320e280304189dd2
2023-11-08 02:03:52 -08:00
Moti Zilberman
0614479042 Silence console logs in individual tests to prevent spam (#41363)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41363

TSIA

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D51070939

fbshipit-source-id: 0d764b1e8a7594b7ee795a00349595d72e071cbf
2023-11-07 11:16:02 -08:00
Moti Zilberman
d6e0bc714a Enable lint/sort-imports everywhere (#41334)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41334

TSIA.

Changelog: [Internal]

Reviewed By: robhogan

Differential Revision: D51025812

fbshipit-source-id: e10d437be775a6b80946483aa96460f34927f870
2023-11-06 12:59:38 -08:00
Riccardo Cipolleschi
d09c02f9e2 Backport e2e script changes to main (#41332)
Summary:
Last week, I modified the e2e script to make sure it was working properly with 0.73.
This change backport those changes in main

## Changelog:
[Internal] - Backport e2e script changes

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

Test Plan: Tested locally

Reviewed By: dmytrorykun

Differential Revision: D51025796

Pulled By: cipolleschi

fbshipit-source-id: 89ecd3701eaac4ba4bdde2c640df45a158329158
2023-11-06 06:05:07 -08:00
Riccardo Cipolleschi
4eed12b7df Fix RNTestProject testing on Android (#41172)
Summary:
While releasing RN 0.73.0-RC3, we relaized that the e2e test script was bugged for Android when used to test RNTestProject with the `-c` option.

There  were 2 problems:
- The downloaded maven-local was not actually used because it doesn't work with a zip. (We were always downloading a version from Maven)
- The versions of React Native between maven-local and the locally packaged React Native were different.

This change fixes the script by:
- Downloading maven-local
- Unzipping maven-local and passing the new folder to the Android app
- Downloading the React Native version that has been packaged in CI

By unzipping maven-local and using the unzipped folder, we make sure that Android is actually using the local repository.
By downloading both the packaged react native and the maven-local from the same CI workflow, we ensure that the versions are aligned.

This also speeds-up further the Android testing.

While running this change, we also moved the `pod install` step inside the `if (iOS)` branch, so we do not install Cocoapods if we need to test
Android.

## Changelog:
[Internal] - Fix Android E2E test script when downloading artefacts from CI

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

Test Plan: Tested locally on both main and 0.73-stable, on both Android and iOS

Reviewed By: cortinico

Differential Revision: D50651448

Pulled By: cipolleschi

fbshipit-source-id: 70a9ed19072119d19c5388e8a4309d7333a08e13
2023-10-27 07:25:02 -07:00
Gijs Weterings
d4ad19c969 Revert D49370200: Migrate codegen to shared build setup, remove package build pre-step from RNTester
Differential Revision:
D49370200

Original commit changeset: 992913155169

Original Phabricator Diff: D49370200

fbshipit-source-id: e8232c97c22065fb54ac940ee2351b2155eb51e0
2023-10-23 12:00:54 -07:00
Alex Hunt
4db31a3110 Migrate codegen to shared build setup, remove package build pre-step from RNTester (#39540)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39540

This simplifies the use of Codegen when creating dev builds of `rn-tester` in the monorepo. It now runs from source for this internal scenario, and this package is now built using the shared monorepo build setup.

Changes:
- Migrate `packages/react-native-codegen` to the shared `yarn build` setup.
    - Update package to use `"exports"` field and wrap entry point modules with `babel-register` (NOTE: This is only required for each entry point internally used in the monorepo).
- Fixup small Flow syntax quirks that fail under `hermes-parser`.
- Remove `BuildCodegenCLITask` task from Android build.
- Remove Codegen `build.sh` call from iOS build, use `require.resolve` for `combine-js-to-schema-cli.js` entry point.

Externally significant FYIs:
- `react-native/codegen` is converted to use the `"exports"` field — it should export all `.js` files, as before.
- `codegenPath` is now ignored and marked as deprecated on `ReactExtensions.kt`.

NOTE: TypeScript auto-generation is not yet enabled on this package, since it uses CommonJS `module.exports` syntax (unsupported by `flow-api-translator`).

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D49370200

fbshipit-source-id: 992913155169912ea1a3cb24cb26efbd3f783058
2023-10-23 08:32:33 -07:00
Riccardo Cipolleschi
6aae713a18 Disable unstable E2E tests (#41153)
Summary:
E2E tests in OSS are expensive and flaky.
They already prevented some broken changes to land on main, but as of today:
- they are always green, so they are not bloking
- nobody is looking at the reporting job
- the reporting job takes a lot of time to run and prevent other useful signals to be available soon
- it is expensive

So we decide to disable them for the time being, while we iterate on those with Callstack and MSFT.

## Changelog:
[Internal] -  Disable E2E tests

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

Test Plan: CircleCI stays green

Reviewed By: cortinico

Differential Revision: D50552818

Pulled By: cipolleschi

fbshipit-source-id: 7160a8074492c3c9a55485d8a17a6883eb4b35b5
2023-10-23 07:15:00 -07:00
Alex Hunt
d4fe550478 Update source repo URL for debugger-frontend, require branch arg (#41118)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41118

Updates the release process and guidance for `debugger-frontend`, now that the source [facebookexperimental/rn-chrome-devtools-frontend](https://github.com/facebookexperimental/rn-chrome-devtools-frontend) repo is published.

The `sync-and-build` script now requires a `--branch` argument, allowing us to match release branches across repos for hotfixes (e.g. `0.73-stable`).

Changelog: [Internal]

Reviewed By: motiz88

Differential Revision: D50496327

fbshipit-source-id: 671fd1581e23032eec0a419a6e50dac6c76feeb0
2023-10-20 12:34:29 -07:00
Gijs Weterings
67c1a806e6 Flow strictify xplat/js/react-native-github where possible (#41051)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41051

Strictifies flow to flow strict-local in files where doing that doesn't cause new flow errors.

Changelog: Internal

Reviewed By: yungsters

Differential Revision: D50369011

fbshipit-source-id: b4a5a26b839b7327a3178e6f5b35246dea365a38
2023-10-18 05:36:33 -07:00
Riccardo Cipolleschi
a2f11895c2 Skip publishing of normalize-colors (#40977)
Summary:
CircleCI is red because verdaccio fails to publish `normalize-colors`.
For some old dependencies, normalize-colors has been published on the official npmjs with the version we needs.

In order to mitigate the RN red ci, we can consume them directly from NPMJS.
As a followup, we created a task to investigate it next week.

## Changelog:
[Internal] - Skip publishing or normalize colors

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

Test Plan:
Tested locally, running verdaccio and simulating CI. It worked.
CircleCI is green

Reviewed By: robhogan

Differential Revision: D50300449

Pulled By: cipolleschi

fbshipit-source-id: 2259b450deff15a117d1de4690bcfe8a9ba7d115
2023-10-14 13:12:46 -07:00
Riccardo Cipolleschi
45285a513d Connect the flag removal script (#40782)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/40782

## Changelog:
[Internal] - Connect the flag removal script

Reviewed By: cortinico

Differential Revision: D50083082

fbshipit-source-id: d7cc1e81debed7a8fa934c8010e5884ad29bd657
2023-10-11 10:09:57 -07:00
Riccardo Cipolleschi
89c9ca0f68 Generalize get-and-update-nightlies (#40786)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/40786

## Changelog:
[Internal] -  Generalize get-and-update-nightlies

Reviewed By: cortinico

Differential Revision: D49956685

fbshipit-source-id: 506b812b93353526a941f3deb136f6bdc74cce35
2023-10-11 10:09:57 -07:00
Riccardo Cipolleschi
2d067568d7 Add double publishing support to set-rn-version (#40784)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/40784

## Changelog
[Internal] Add double publishing support to set-rn-version

Reviewed By: cortinico

Differential Revision: D49955312

fbshipit-source-id: b154fe0c4cc53dbe3cc6319bbf43663307816ee4
2023-10-11 10:09:57 -07:00
Riccardo Cipolleschi
657aea0946 Update version-utils to accept new versions (#40783)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/40783

ignore-github-export-checks
## Changelog:
[Internal] - Update version-utils to accept more versions for double publishing

Reviewed By: cortinico

Differential Revision: D49917128

fbshipit-source-id: 4556e5161986d8b041de464aa6939dfb2dd45e61
2023-10-11 10:09:57 -07:00
Riccardo Cipolleschi
d16793dbe0 Update publishing to Sonatype for double publishing (#40781)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/40781

## Changelog:
[Internal] - Allow Sonatype to double publish SNAPSHOTS

Reviewed By: cortinico

Differential Revision: D49914824

fbshipit-source-id: 830e20eb51ffdf5b7c4452972c436ca0cb4da5a9
2023-10-11 10:09:57 -07:00
Riccardo Cipolleschi
7ebfe7046d Compute the right version (#40780)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/40780

## Changelog:
[Internal] - Compute the right version when publishing

Reviewed By: cortinico

Differential Revision: D49914416

fbshipit-source-id: 9ab5a3323851eec943f759b8be11c3d7d48df83f
2023-10-11 10:09:57 -07:00
Luna Wei
3996cf3546 Fix missing sed import
Summary: Changelog: [Internal] - Fix missing sed import for Hermes flag fix in D49831355

Reviewed By: cipolleschi

Differential Revision: D50016450

fbshipit-source-id: e7cb6e24d962b85ddd465ec4f6dff1d3f5c3f141
2023-10-06 11:02:03 -07:00
Riccardo Cipolleschi
46d541f7b3 Remove flags to turn on/off the new architecture (#39780)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39780

This diff removes flags and setups from the files to turn on and off the new architecture. The script is meant to run only on pre-alpha builds.

## Changelog:
[Internal] - Add script to remove prealpha flags

Reviewed By: cortinico

Differential Revision: D49376471

fbshipit-source-id: 754bf6f9d5b94da77111798200bbaaa3347fb678
2023-10-05 07:40:50 -07:00
Riccardo Cipolleschi
9fee99040d Remove unneeded write to .version file (#39807)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39807

We used to need this file so that we could read the react native version when [creating Hermes artifacts](e4b5d3eec9 (diff-78a8a19706dbd2a4425dd72bdab0502ed7a2cef16365ab7030a5a0588927bf47R1507)). Originally, that change was introduced [here](e4b5d3eec9 (diff-78a8a19706dbd2a4425dd72bdab0502ed7a2cef16365ab7030a5a0588927bf47))

Despite the fact that that approach was wrong, as we already have the right version in the package.json which is guaranteed to be present, a lot has changed since then and we don't need that file anymore.

## Changelog:
[Internal] - Remove lines that write a .version file while releasing on npm

Reviewed By: lunaleaps

Differential Revision: D49909718

fbshipit-source-id: bd23d6d73001d0b58bf6b0321ed6d4ceb3523e7a
2023-10-05 06:29:49 -07:00
Saad Najmi
0a48a72236 Remove deprecated Snapshot tests (#39720)
Summary:
These tests seem to have been deprecated for years, let's just remove them.

## Changelog:

[IOS] [REMOVED] - Remove deprecated Snapshot tests

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

Test Plan: CI should pass

Reviewed By: cipolleschi

Differential Revision: D49809496

Pulled By: NickGerleman

fbshipit-source-id: d79f0a0896b190d071bda1eb837b3efa10dbbf3b
2023-10-03 04:33:53 -07:00
Luna Wei
c03d520e16 Set hermes for Android template project in testing
Summary:
Changelog: [Internal] - Set the hermes value as specified by the test-e2e-local script flag. Right now, the script incorrectly ignores the flag

By default, the template project has `hermesEnabled=true`

Reviewed By: cipolleschi

Differential Revision: D49831355

fbshipit-source-id: 7fb8613fa86f2c6140b7d25b16aeb583e6e26c12
2023-10-02 10:40:28 -07:00
Saad Najmi
036d5072b1 Don't load RCTRootViewIntegrationTestsApp.bundle in objc-test.sh (#39615)
Summary:
https://github.com/facebook/react-native/pull/38871/ removed all the RCTRootViewIntegrationTest stuff. Looks like we missed a line so I'm removing now.

## Changelog:

[INTERNAL] [FIXED] - Don't load RCTRootViewIntegrationTestsApp.bundle in objc-test.sh

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

Test Plan: CI should pass

Reviewed By: cipolleschi

Differential Revision: D49612227

Pulled By: ryancat

fbshipit-source-id: c16dcf7bec0bdfa839d250cfa6eadf83d792ae0d
2023-09-25 16:28:11 -07:00
Riccardo Cipolleschi
52104c6ee3 Update nightlies to bump all the packages in the monorepo and transitive dependencies (#39600)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39600

This change will publish all the packages in the monorepo that are not private as during the nightlies, taking also care of keeping the transitive dependencies aligned.

## Changelog:
[Internal] - Bump packages and transitive dependencies when doing nightlies.

Reviewed By: huntie

Differential Revision: D49502330

fbshipit-source-id: 85e2bde13ed2b5dfe33072c9f99f5aaa2c5063ca
2023-09-22 05:02:43 -07:00
Riccardo Cipolleschi
42d090c94c Fix local e2e script by copying the hermes' ruby files to the right folder (#39580)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39580

While testing other features, I realized that the script to generate a project locally, starting from the template, has a bug for which we were using the outdated `hermes-engine.podspec` coming from the Hermes repo to build hermes.

This change fixes this by moving our files to the right folder.

## Changelog:
[Internal] - Fix local e2e test script copying hermes rubyscript over

Reviewed By: dmytrorykun

Differential Revision: D49497716

fbshipit-source-id: f1d582ec9d9c8007cbd2f9c876c061af12735f83
2023-09-21 07:36:28 -07:00
Riccardo Cipolleschi
780567c727 Refactor publish-npm args to be more safe (#39532)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39532

This change refactors how we handle the parameters of publish-npm so we can only accept the build types we actually support.

## Changelog:
[Internal] - Make publish-npm args stricter

Reviewed By: cortinico

Differential Revision: D49374263

fbshipit-source-id: a17ddecc0ddcb30858dd0baaab8990ae765d304f
2023-09-21 04:35:41 -07:00
Rob Hogan
cda1cf9349 Prevent Babel registration from transforming plugins with arbitrary config (#39429)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39429

Using `require` after `const registerFn = require('babel/register')` but before `registerFn(config)` causes Babel to transform required code with the default configuration (ie, using a nearby `babel.config.js`, if available).

This was causing the Babel plugins loaded by `metro-babel-register` to be (unnecessarily) transformed according to `babel.config.js`, which actually fails if the plugins/presets referenced in `babel.config.js` themselves require transformation.

This ensures no code is loaded in between registering Babel as a side effect of requiring Babel register, and replacing that hook with something explicitly configured.

## React Native
Changelog: [Internal]

## Metro
```
* **[Fix]:** `metro-babel-register` prevent arbitrary transformation of Babel plugins during registration setup
```

Reviewed By: dmytrorykun

Differential Revision: D49238671

fbshipit-source-id: 52a55b1b5dbd127171558c056f16ab04e8fa8232
2023-09-14 03:57:11 -07:00
Moti Zilberman
b27607f853 Add debugger-frontend package and manual build script (#39161)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39161

Changelog: [Internal]

Creates a new stub package named `react-native/debugger-frontend`, which will contain a minimal build of the Chrome DevTools frontend adapted for React Native. Initially, the compiled frontend assets will be checked into the React Native repo, but we intend to replace this with a fully automated build in CI at a later date.

Reviewed By: huntie

Differential Revision: D48680624

fbshipit-source-id: a24c8b019881187963d0be88e773bc0a97a2437d
2023-08-31 08:34:33 -07:00
Sam Zhou
246b5cf414 Remove CI check jobs on .flowconfig.android in react-native (#39158)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39158

.flowconfig.android is the same as .flowconfig now. The check is meaningless. This diff removes it and the flowconfig.

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D48629137

fbshipit-source-id: bc1bee9426eed7bc41dc7a1efe75333e1191e066
2023-08-26 10:00:22 -07:00
Gijs Weterings
e6899326e1 add missing import to find-and-publish-all-bumpted-packages.js after D46131120
Summary: After D46131120 circleci's find_and_publish_bumped_packages job is failing (https://app.circleci.com/pipelines/github/facebook/react-native/30521/workflows/5f896217-b3e2-4ac7-b1ef-ad2e3c30e31f/jobs/984287?invite=true#step-107-304_80). Looks like a missing import

Reviewed By: robhogan

Differential Revision: D48604214

fbshipit-source-id: 352f354a0743f121e4c4fe9fc606c3877e698f07
2023-08-23 08:27:53 -07:00
Alex Hunt
a002fbbd6c Upgrade CLI, restore prev status check value (#39077)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39077

Follow-up to https://github.com/facebook/react-native/pull/38988.

- Upgrade to RN CLI `12.0.0-alpha.11`.
- Restore previous value check against `/status` response in test scripts (restored in above CLI alpha).

Changelog: [Internal]

Reviewed By: motiz88

Differential Revision: D48432629

fbshipit-source-id: 175241ad75676281f4638e179873b2ce32f0ea3e
2023-08-22 12:56:19 -07:00
Alex Hunt
3c943bbe3a Integrate dev-middleware into start command (#39059)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39059

## Context

RFC: Decoupling Flipper from React Native core: https://github.com/react-native-community/discussions-and-proposals/pull/641

## Changes

This change:
- Links the new `react-native/dev-middleware` endpoints into the recently migrated `react-native start` command.
- Adds `react-native/community-cli-plugin` (the migrated [`cli-plugin-metro`](https://github.com/react-native-community/cli/tree/main/packages/cli-plugin-metro)) as a dependency of `react-native`, and hooks in these versions of the `start`, `bundle`, and `ram-bundle` commands via `react-native.config.js`.

Functionally, this means that the new `/open-debugger` endpoint is available on the dev server started by `react-native start` (not yet linked into any UI).

After this PR is merged, the new `community-cli-plugin` package is "linked" and we can remove `cli-plugin-metro` from `react-native-community/cli`: https://github.com/react-native-community/cli/pull/2055.

Changelog: [Internal]

Reviewed By: motiz88

Differential Revision: D47226421

fbshipit-source-id: 123039961f93bd8183a32a2d3f30c447f7c0f132
2023-08-22 08:08:15 -07:00
Moti Zilberman
be469c1b86 Resolve absolute paths of Babel presets/plugins in Node build config (#39079)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39079

Changelog: [Internal]

The Babel config for Node packages in the RN repo, added in D47760330 / D48312463, relies on [name normalization](https://babeljs.io/docs/options#name-normalization) to resolve the Babel presets and plugins that it references. This works for OSS but can cause other integrations to fail to resolve the packages, depending on the details of how they're installed. Here we eagerly resolve the packages when constructing the Babel config.

Reviewed By: huntie

Differential Revision: D48469386

fbshipit-source-id: d9c15883169e30984d93fc6a5d9544752db5d2c8
2023-08-18 07:32:46 -07:00
Riccardo Cipolleschi
641be98b1e Split Config.yml to run jobs selectively (#39042)
Summary:
Right now, every PR runs the whole test suite. For example, a changelog PR, will run all the tests. As of last month, that meant quite a few $s per single run.

With this PR, we are going to leverage dynamic configuration and file filtering to create a config.yml on the flight, depending on the files changed by the commit/pr.

They way it works is the following:
- It starts a setup workflow in CircleCI.
- This workflow fetch the list of files that have been changed in the current commit.
- It executes a bunch of filtering and computation to understand which tests makes sense to run.
- It creates a config on the flight to run those.
- It continue the pipeline on that config.

Currently, the way it works is the following:
- If a `.md` file has been modified => run nothing
- If only files in the `ReactAndroid` folder are modified => run tests for android only
- If only files in the `React` folder are modified or `ruby` files are modified => run only iOS tests
- If only js files, not in the scripts folder are modified => run only JS tests
- if only files in the e2e folder are modified => run only e2e tests
- else => run everything.

Of course, we can play and modify those filters t make sure that they reflect the work and the tests to the best we can.

bypass-github-exports-checks

## Changelog:
[Internal] - Split circleci config and run test selectively.

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

Test Plan:
- [X] Tested on the local branch for general sanity check.
- [X] Import it in fbsource
- [x] Create a stacked diff which changes only a md file => verify that no tests are run.
- [x] Create a stacked diff which changes only files in ReactAndroid => verify that only android tests run.
- [x] Create a stacked diff which changes only files in React => verify that only iOS tests run.
- [x] Create a stacked diff which changes only ruby files => verify that only iOS tests run.
- [x] Create a stacked diff which changes ruby files and file in React => verify that only iOS tests run.
- [x] Create a stacked diff which changes only files JS not in the script folder => verify that JS tests run.
- [x] Create a stacked diff which changes only JS files in the script folder => verify that the whole suite starts.
- [x] Create a stacked diff which changes only files in the E2E folder => verify that only E2E files runs.
- [x] Trigger a nightly pipeline => verify that parameters are passed to the generated config.

Reviewed By: NickGerleman

Differential Revision: D48394437

Pulled By: cipolleschi

fbshipit-source-id: 771f3e68daa8318d2b73dd91ce85a41488110c04
2023-08-18 07:22:22 -07:00
Riccardo Cipolleschi
c326ec0475 Add retry mechanism to test_e2e_android to reduce flakyness (#39068)
Summary:
We figured that android e2e tests are a bit flakier than needed. This change add a retry mechanism to rerun the tests up to 3 times in order to try and reduce the flakyness there.

## Changelog:

[Internal] - Add retry to Android e2e tests

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

Test Plan: CircleCI stays green

Reviewed By: cortinico

Differential Revision: D48463517

Pulled By: cipolleschi

fbshipit-source-id: cdf3dca047dce89cc5d2dccc9b847283b93bbd36
2023-08-18 04:08:56 -07:00
Riccardo Cipolleschi
e7f6f079cb Implement retry mechanism during yarn installation (#39020)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39020

Sometimes yarn fails to intall, we are implementing a retry mechanism

## Changelog:
[Internal] - Add retry mechanism in template jobs.

Reviewed By: cortinico

Differential Revision: D48234860

fbshipit-source-id: ece3c40051ff143837ed79db2390fbb599fa8ae2
2023-08-16 08:31:44 -07:00
Riccardo Cipolleschi
623f44c7ce Revert D48118162: Split CircleCI config
Differential Revision:
D48118162

Original commit changeset: 73c8071a7e80

Original Phabricator Diff: D48118162

fbshipit-source-id: f070601c8631a9b91bb298ce94a9eb7cee13e059
2023-08-16 05:46:52 -07:00
Riccardo Cipolleschi
67f8d4014e Split CircleCI config (#38793)
Summary:
Right now, every PR runs the whole test suite. For example, a changelog PR, will run all the tests. As of last month, that meant quite a few $s per single run.

With this PR, we are going to leverage dynamic configuration and file filtering to create a config.yml on the flight, depending on the files changed by the commit/pr.

They way it works is the following:
- It starts a setup workflow in CircleCI.
- This workflow fetch the list of files that have been changed in the current commit.
- It executes a bunch of filtering and computation to understand which tests makes sense to run.
- It creates a config on the flight to run those.
- It continue the pipeline on that config.

Currently, the way it works is the following:
- If a `.md` file has been modified => run nothing
- If only files in the `ReactAndroid` folder are modified => run tests for android only
- If only files in the `React` folder are modified or `ruby` files are modified => run only iOS tests
- If only js files, not in the scripts folder are modified => run only JS tests
- if only files in the e2e folder are modified => run only e2e tests
- else => run everything.

Of course, we can play and modify those filters t make sure that they reflect the work and the tests to the best we can.

bypass-github-export-checks

## Changelog:

[Internal] - Split circleci config and run test selectively.

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

Test Plan:
- [X] Tested on the local branch for general sanity check.
- [X] Import it in fbsource
- [x] Create a stacked diff which changes only a md file => verify that no tests are run.
- [x] Create a stacked diff which changes only files in ReactAndroid => verify that only android tests run.
- [x] Create a stacked diff which changes only files in React => verify that only iOS tests run.
- [x] Create a stacked diff which changes only ruby files => verify that only iOS tests run.
- [x] Create a stacked diff which changes ruby files and file in React => verify that only iOS tests run.
- [x] Create a stacked diff which changes only files JS not in the script folder => verify that JS tests run.
- [x] Create a stacked diff which changes only JS files in the script folder => verify that the whole suite starts.
- [x] Create a stacked diff which changes only files in the E2E folder => verify that only E2E files runs.
- [x] Trigger a nightly pipeline => verify that parameters are passed to the generated config.

Reviewed By: rshest

Differential Revision: D48118162

Pulled By: cipolleschi

fbshipit-source-id: 73c8071a7e80cd930fe538f77d7bb5de75f22ab7
2023-08-16 04:30:54 -07:00
Riccardo Cipolleschi
e9b565381c Add script poll Maven for Artifacts (#38985)
Summary:
This local change adds a script to poll Maven automatically after the release has happened.
This should allow the Release Crew not to repeatedly and manually refresh Maven urls in order to see whether the artifacts are there or not.
As soon as this job is green, artifacts are out!

Cost wise, we are using a small machine, which costs 5 credits per minute.

## Changelog:
[Internal] -Add script and CI job to poll for maven after a release.

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

Test Plan:
Tested locally, running the JS script.
[Verified that the CI job can execute it.](https://app.circleci.com/pipelines/github/facebook/react-native/29634/workflows/5966d5f9-12ca-40b1-9185-758fe98d3aee/jobs/944107)

We can only test this for real while doing a proper release.

Reviewed By: cortinico

Differential Revision: D48309874

Pulled By: cipolleschi

fbshipit-source-id: 5c38b588c29c1311b1fa4e4ca44785583db0b701
2023-08-15 03:26:58 -07:00
Alex Hunt
fdcb94ad13 Upgrade CLI and Metro, update status check refs (#38988)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38988

- Upgrade to RN CLI `12.0.0-alpha.9`, including Metro bump to `0.78.0`.
- Update test scripts, since this CLI release made a breaking change to the `/status` response.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D48311214

fbshipit-source-id: bb0be3c32edb629355b9fbbd754b28f9878f47ef
2023-08-15 02:33:22 -07:00
Alex Hunt
a978d343a6 Add auto-generation of TypeScript definitions on build (#38990)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38990

This PR adds auto-generation of Typescript definitions from Flow source code for packages using the shared monorepo build setup (https://github.com/facebook/react-native/pull/38718).

Today, these are the following Node.js packages:

- `packages/community-cli-plugin`
- `packages/dev-middleware` (⬅️ `emitTypeScriptDefs` enabled)

This also improves emitted Flow definitions (`.js.flow`), by using [`flow-api-translator`](https://www.npmjs.com/package/flow-api-translator) to strip implementations.

**All changes**

- Include `flow-api-translator` and configure this to emit type definitions as part of `yarn build`.
    - Add translation from Flow source to TypeScript definitions (`.d.ts`) adjacent to each built file.
    - Improve emitted Flow definitions (`.js.flow`), by using `flow-api-translator` to strip implementations (previously, source files were copied). The Flow and TS defs now mirror each other.
-  Add `emitFlowDefs` and `emitTypeScriptDefs` options to build config to configure the above.
- Integrate TypeScript compiler to perform program validation on emitted `.d.ts` files.
     - This is based on this guide: https://github.com/microsoft/TypeScript-wiki/blob/main/Using-the-Compiler-API.md#a-minimal-compiler.
- Throw an exception on the `rewritePackageExports` step if a package does not define an `"exports"` field.
- Add minimal `flow-typed` definitions for `typescript` 😄.

**Notes on [`flow-api-translator`](https://www.npmjs.com/package/flow-api-translator)**

This project is experimental but is in a more mature state than when we evaluated it earlier in 2023.
- It's now possible to run this tool on our new Node.js packages, since they are exclusively authored using `import`/`export` syntax (a requirement of the tool).
- As a safety net, we run the TypeScript compiler against the generated program, which will fail the build.

Changelog: [Internal]

Reviewed By: robhogan

Differential Revision: D48312463

fbshipit-source-id: 817edb35f911f52fa987946f2d8fc1a319078c9d
2023-08-14 12:12:10 -07:00
Nicola Corti
1a765b6d08 Cleanup and scope all the Gradle Properties (#38885)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38885

We do have several Gradle Properties that are used to configure the build.

I've refactored them all and moved them inside the PropertyUtils file:
https://github.com/facebook/react-native/blob/main/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/PropertyUtils.kt

Specifically properties should be 'scoped' under `react.` if public, and `react.internal.` if for internal usage.

Property that I cleaned up are:
- REACT_NATIVE_MAVEN_LOCAL_REPO becomes react.internal.mavenLocalRepo
- REACT_WINDOWS_BASH becomes react.internal.windowsBashPath
- GROUP becomes react.internal.publishingGroup

I've also added support for scoping for public properties with backward compat (so both the scoped and unscoped properties are accepted):
- react.newArchEnabled
- react.hermesEnabled
- react.nativeArchitectures

Changelog:
[Android] [Changed] - Cleanup and scope all the Gradle Properties

Reviewed By: mdvacca

Differential Revision: D48188310

fbshipit-source-id: 1a92d31105270a4c2f80029b7d36bcb33916d0fb
2023-08-13 23:11:29 -07:00
Rob Hogan
86968c1104 Use modern timers in monorepo Jest tests (#38955)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38955

Jest introduced "modern" timers based on `sinon/fake-timers` in Jest 26 ([release announcement](https://jestjs.io/blog/2020/05/05/jest-26#new-fake-timers)), and they became the default in Jest 27, in May 2021.

Modern timers have more capabilities - they were introduced with support for `queueMicrotask`, mocking `Date`, etc., and they've continued to receive more attention from the Jest team since - they're now much more comprehensive and more configurable than legacy timers.

Importantly, because they're not based on Jest mocks, they're not affected in surprising ways by eg `jest.resetAllMocks()` (a particularly confusing side-effect when fake timers are enabled globally, as in our setup).

This migrates RN's own tests and config to modern fake timers, or real timers where that's more appropriate.

NOTE: In cases where non-trivial changes to the tests are required, four test files are individually opted-in to `legacyFakeTimers` with a `TODO(legacy-fake-timers)`. I'll open these up for community contributions to fix.

Changelog: [Internal]

Reviewed By: motiz88

Differential Revision: D48189907

fbshipit-source-id: 2e7ce74cc60e80679d81d7c16d599ad1bbe2c921
2023-08-11 11:01:06 -07:00
Alex Hunt
e1998806b7 Migrate cli-plugin-metro into repo (#38795)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38795

## Context

RFC: Decoupling Flipper from React Native core: https://github.com/react-native-community/discussions-and-proposals/pull/641

## Changes

Inits new package `react-native/community-cli-plugin`. This migrates [`react-native-community/cli-plugin-metro`](https://github.com/react-native-community/cli/tree/main/packages/cli-plugin-metro) into the React Native repo, to enable faster iteration by the React Native core team. Specifically:

- This package contains several `metro` dependencies, which when removed from CLI will no longer require us to ship new CLI releases to get Metro patches and features to users.
- This package contains the `start`, `bundle`, and `ram-bundle` commands (central to the React Native development experience), for which we have incoming debugging-related changes.
- This package now **only** exports commands to be attached via a RN CLI plugin. With this move, we're aiming to **internalise** the default implementations of these dev commands within React Native — other RN CLI plugins can continue to override these, but must do so wholesale. (See also the recent fix for this: https://github.com/react-native-community/cli/pull/1999.)

In V15:
- (Microsoft feedback) Re-export  `unstable_buildBundleWithConfig`, marking as unstable. This gives us a time buffer to consider how we repackage this functionality in future.

The package source has been converted from TypeScript to Flow, with a number of new `flow-typed/` defs added to meet type coverage requirements.

## To dos

- For now, we aren't removing the existing [`react-native-community/cli-plugin-metro`](https://github.com/react-native-community/cli/tree/main/packages/cli-plugin-metro) source — until later PRs consolidate this move by changing dependencies in the `react-native` package.
- **Exported API is reduced!**: I'm working with szymonrybczak to decouple references from RN CLI packages https://github.com/react-native-community/cli/pull/2021.

Changelog: [Internal]

Reviewed By: motiz88

Differential Revision: D46801501

fbshipit-source-id: 7f6b72941a69f487fb437768cdba125a9aa3418d
2023-08-10 11:34:36 -07:00