Skip to content

Commit aeb1b12

Browse files
kelsetcortinicoSimek
authored
Update the contributing section docs (#3221)
Co-authored-by: Nicola Corti <[email protected]> Co-authored-by: Bartosz Kaszubowski <[email protected]>
1 parent 4030f7c commit aeb1b12

14 files changed

+313
-213
lines changed

website/contributing/contributing-overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ Whenever you are ready to contribute code, check out our [step-by-step guide to
123123

124124
### Tests
125125

126-
Tests help us prevent regressions from being introduced to the codebase. The GitHub repository is continuously tested using CircleCI and Appveyor, the results of which are available through the Checks functionality on [commits](https://github.com/facebook/react-native/commits/HEAD) and pull requests.
126+
Tests help us prevent regressions from being introduced to the codebase. The GitHub repository is continuously tested using CircleCI, the results of which are available through the Checks functionality on [commits](https://github.com/facebook/react-native/commits/HEAD) and pull requests.
127127

128128
You can learn more about running and writing tests on the [How to Run and Write Tests](/contributing/how-to-run-and-write-tests) page.
129129

website/contributing/how-to-build-from-source.md

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ Assuming you have the Android SDK installed, run `android` to open the Android S
1212

1313
Make sure you have the following installed:
1414

15-
1. Android SDK version 30 (`compileSdkVersion` in [`build.gradle`](https://github.com/facebook/react-native/blob/main/ReactAndroid/build.gradle)).
16-
2. Android NDK 21.4.7075529 (from in [`gradle.properties`](https://github.com/facebook/react-native/blob/b1120c6a6513ec24568abc6bbe60dd57ef1dec96/gradle.properties#L7), download links and installation instructions below).
15+
1. Android SDK (find the specific version in the `compileSdkVersion` in [`build.gradle`](https://github.com/facebook/react-native/blob/main/ReactAndroid/build.gradle#L253)).
16+
2. Android NDK
1717

1818
#### Point Gradle to your Android SDK
1919

@@ -45,13 +45,7 @@ ndk.dir=/Users/your_unix_name/android-ndk/android-ndk-r20b
4545

4646
#### Download links for Android NDK
4747

48-
1. [macOS (64-bit)](https://dl.google.com/android/repository/android-ndk-r20b-darwin-x86_64.zip)
49-
2. [Linux (64-bit)](https://dl.google.com/android/repository/android-ndk-r20b-linux-x86_64.zip)
50-
3. [Windows (64-bit)](https://dl.google.com/android/repository/android-ndk-r20b-windows-x86_64.zip)
51-
4. [Windows (32-bit)](https://dl.google.com/android/repository/android-ndk-r20b-windows-x86.zip)
52-
53-
You can find further instructions on the [official page](https://developer.android.com/ndk/index.html).
54-
Or follow instructions to [download appropriate NDK from SDK manager](https://developer.android.com/studio/projects/install-ndk#specific-version).
48+
You can find the instructions to install the NDK on the [official Android NDK website](https://developer.android.com/studio/projects/install-ndk).
5549

5650
### Building the source
5751

@@ -149,9 +143,9 @@ You should be able to use the _Run_ button to run your app on a device. Android
149143

150144
### Additional notes
151145

152-
Building from source can take a long time, especially for the first build, as it needs to download ~200 MB of artifacts and compile the native code.
146+
Building from source can take a long time, especially for the first build, as it needs to download ~200 MB of artifacts and compile the native code.
153147

154-
Every time you update the `react-native` version from your repo, the build directory may get deleted, and all the files are re-downloaded.
148+
Every time you update the `react-native` version from your repo, the build directory may get deleted, and all the files are re-downloaded.
155149
To avoid this, you might want to change your build directory path by editing the `~/.gradle/init.gradle` file:
156150

157151
```groovy
@@ -192,7 +186,7 @@ Install it in your app project package.json.
192186

193187
## Rationale
194188

195-
The recommended approach to working with React Native is to always update to the latest version. No support is provided on older versions and if you run into issues the contributors will always ask you to upgrade to the latest version before even looking at your particular issue.
189+
The recommended approach to working with React Native is to always update to the latest version. No support is provided on older versions and if you run into issues the contributors will always ask you to upgrade to the latest version before even looking at your particular issue.
196190

197191
Sometimes, though, you are temporarily stuck on an older React Native version, but you require some changes from newer versions urgently (bugfixes) without having to do a full upgrade right now. This situation should be short lived by definition and once you have the time, the real solution is to upgrade to the latest version.
198192

@@ -226,9 +220,9 @@ Upload the binaries from the `android` folder to maven and point your Android ap
226220

227221
Instead of uploading to Maven/Nexus, you can add the binaries built in the previous steps to git, by changing the .gitignore and committing the binaries to your forked branch. This allows you to make your fork into a functioning git dependency for React Native app projects.
228222

229-
If you have changes that you want to actually merge to React Native, make them on another branch first and open a PR.
223+
If you have changes that you want to actually merge to React Native, make them on another branch first and open a PR.
230224

231-
To start making your dependency branch, make sure you are on a `release/my-forked-release` branch, then merge any commits that you need from yourself or others into this branch.
225+
To start making your dependency branch, make sure you are on a `release/my-forked-release` branch, then merge any commits that you need from yourself or others into this branch.
232226

233227
:::warning
234228
This release branch should never be merged into any other branch.

website/contributing/how-to-contribute-code.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Then, you can run several commands:
3535

3636
Tests help us prevent regressions from being introduced to the codebase. We recommend running `yarn test` or the platform-specific scripts above to make sure you don't introduce any regressions as you work on your change.
3737

38-
The GitHub repository is [continuously tested](/contributing/how-to-run-and-write-tests#continuous-testing) using CircleCI and Appveyor, the results of which are available through the Checks functionality on [commits](https://github.com/facebook/react-native/commits/main) and pull requests.
38+
The GitHub repository is [continuously tested](/contributing/how-to-run-and-write-tests#continuous-testing) using CircleCI, the results of which are available through the Checks functionality on [commits](https://github.com/facebook/react-native/commits/main) and pull requests.
3939

4040
You can learn more about running and writing tests on the [How to Run and Write Tests](/contributing/how-to-run-and-write-tests) page.
4141

website/contributing/how-to-run-and-write-tests.md

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,7 @@ Finally, make sure end-to-end tests run successfully by executing the following
7777
./scripts/test-manual-e2e.sh
7878
```
7979

80-
End-to-end tests written in [Detox](https://github.com/wix/Detox) confirm that React Native components and APIs function correctly in the context of a running app. They run the RNTester app in the simulator and simulate a user interacting with the app.
81-
82-
You can run Detox end-to-end tests locally by [installing the Detox CLI](https://github.com/wix/Detox/blob/master/docs/Introduction.GettingStarted.md#step-1-install-dependencies) on macOS, then running the following in the command line:
83-
84-
```bash
85-
yarn run build-ios-e2e
86-
yarn run test-ios-e2e
87-
```
88-
89-
If you work on a component or API that isn't covered by a Detox test, please consider adding one. Detox tests are stored under [`RNTester/e2e/__tests__`](https://github.com/facebook/react-native/tree/main/RNTester/e2e/__tests__).
80+
This script will make you select to run the RNTester app (that lives within `packages/rn-tester`) or it will generate a fresh new project in `/tmp/RNTestProject`. Follow the step-by-step instructions from the script to test successfully if your changes.
9081

9182
## Writing Tests
9283

@@ -101,11 +92,11 @@ The JavaScript tests can be found inside `__test__` directories, colocated next
10192

10293
### iOS Integration Tests
10394

104-
React Native provides facilities to make it easier to test integrated components that require both native and JS components to communicate across the bridge.
95+
React Native provides facilities to make it easier to test integrated components that require both native and JS components to communicate across the bridge.
10596

10697
The two main components are `RCTTestRunner` and `RCTTestModule`. `RCTTestRunner` sets up the React Native environment and provides facilities to run the tests as `XCTestCase`s in Xcode (`runTest:module` is the simplest method). `RCTTestModule` is exported to JavaScript as `NativeModules.TestModule`.
10798

108-
The tests themselves are written in JS, and must call `TestModule.markTestCompleted()` when they are done, otherwise the test will timeout and fail.
99+
The tests themselves are written in JS, and must call `TestModule.markTestCompleted()` when they are done, otherwise the test will timeout and fail.
109100

110101
Test failures are primarily indicated by throwing a JS exception. It is also possible to test error conditions with `runTest:module:initialProps:expectErrorRegex:` or `runTest:module:initialProps:expectErrorBlock:` which will expect an error to be thrown and verify the error matches the provided criteria.
111102

@@ -123,11 +114,11 @@ See the following for example usage and integration points:
123114

124115
A common type of integration test is the snapshot test. These tests render a component, and verify snapshots of the screen against reference images using `TestModule.verifySnapshot()`, using the [`FBSnapshotTestCase`](https://github.com/facebook/ios-snapshot-test-case) library behind the scenes. Reference images are recorded by setting `recordMode = YES` on the `RCTTestRunner`, then running the tests.
125116

126-
Snapshots will differ slightly between 32 and 64 bit, and various OS versions, so it's recommended that you enforce tests are run with the [correct configuration](https://github.com/facebook/react-native/blob/main/scripts/.tests.env).
117+
Snapshots will differ slightly between 32 and 64 bit, and various OS versions, so it's recommended that you enforce tests are run with the [correct configuration](https://github.com/facebook/react-native/blob/main/scripts/.tests.env).
127118

128119
It's also highly recommended that all network data be mocked out, along with other potentially troublesome dependencies. See [`SimpleSnapshotTest`](https://github.com/facebook/react-native/blob/main/IntegrationTests/SimpleSnapshotTest.js) for a basic example.
129120

130-
If you make a change that affects a snapshot test in a pull request, such as adding a new example case to one of the examples that is snapshotted, you'll need to re-record the snapshot reference image.
121+
If you make a change that affects a snapshot test in a pull request, such as adding a new example case to one of the examples that is snapshotted, you'll need to re-record the snapshot reference image.
131122

132123
To do this, change `recordMode` flag to `_runner.recordMode = YES;` in [RNTester/RNTesterSnapshotTests.m](https://github.com/facebook/react-native/blob/136666e2e7d2bb8d3d51d599fc1384a2f68c43d3/RNTester/RNTesterIntegrationTests/RNTesterSnapshotTests.m#L29), re-run the failing tests, then flip record back to `NO` and submit/update your pull request and wait to see if the CircleCI build passes.
133124

@@ -141,29 +132,28 @@ It's a good idea to add an Android integration test whenever you are working on
141132

142133
## Continuous Testing
143134

144-
We use [Appveyor][config-appveyor] and [CircleCI][config-circleci] to automatically run our open source tests. Appveyor and CircleCI will run these tests whenever a commit is added to a pull request, as a way to help maintainers understand whether a code change introduces a regression. The tests also run on commits to the `main` and `*-stable` branches in order to keep track of the health of these branches.
135+
We use [CircleCI][config-circleci] to automatically run our open source tests. CircleCI will run these tests whenever a commit is added to a pull request, as a way to help maintainers understand whether a code change introduces a regression. The tests also run on commits to the `main` and `*-stable` branches in order to keep track of the health of these branches.
145136

146-
[config-appveyor]: https://github.com/facebook/react-native/blob/main/.appveyor/config.yml
147137
[config-circleci]: https://github.com/facebook/react-native/blob/main/.circleci/config.yml
148138

149-
There's another set of tests that run within Meta's internal test infrastructure. Some of these tests are integration tests defined by internal consumers of React Native (e.g. unit tests for a React Native surface in the Facebook app).
139+
There's another set of tests that run within Meta's internal test infrastructure. Some of these tests are integration tests defined by internal consumers of React Native (e.g. unit tests for a React Native surface in the Facebook app).
150140

151141
These tests run on every commit to the copy of React Native hosted on Facebook's source control. They also run when a pull request is imported to Facebook's source control.
152142

153143
If one of these tests fail, you'll need someone at Meta to take a look. Since pull requests can only be imported by Meta employees, whoever imported the pull request should be able to facilitate any details.
154144

155145
:::note
156146
**Running CI tests locally:**
157-
Most open source collaborators rely on CircleCI and Appveyor to see the results of these tests. If you'd rather verify your changes locally using the same configuration as CircleCI, CircleCI provides a [command line interface](https://circleci.com/docs/2.0/local-cli/) with the ability to run jobs locally.
147+
Most open source collaborators rely on CircleCI to see the results of these tests. If you'd rather verify your changes locally using the same configuration as CircleCI, CircleCI provides a [command line interface](https://circleci.com/docs/local-cli) with the ability to run jobs locally.
158148
:::
159149

160150
### F.A.Q.
161151

162152
#### How do I upgrade the Xcode version used in CI tests?
163153

164-
When upgrading to a new version of Xcode, first make sure it is [supported by CircleCI](https://circleci.com/docs/2.0/testing-ios/#supported-xcode-versions).
154+
When upgrading to a new version of Xcode, first make sure it is [supported by CircleCI](https://circleci.com/docs/testing-ios#supported-xcode-versions).
165155

166-
You will also need to update the test environment config to make sure tests run on an iOS Simulator that comes installed in the CircleCI machine.
156+
You will also need to update the test environment config to make sure tests run on an iOS Simulator that comes installed in the CircleCI machine.
167157

168158
This can also be found in [CircleCI's Xcode version reference](https://circleci.com/docs/2.0/testing-ios/#supported-xcode-versions) by clicking the desired version and looking under Runtimes.
169159

0 commit comments

Comments
 (0)