Skip to content

Commit e68e153

Browse files
authored
chore(docs): Update contributing docs
1 parent 227e70c commit e68e153

File tree

2 files changed

+125
-22
lines changed

2 files changed

+125
-22
lines changed

docs/contributing.md

+125-22
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,29 @@ Thanks for contributing, you rock!
99

1010
When it comes to open source, there are many different kinds of contributions that can be made, all of which are valuable. Here are a few guidelines that should help you as you prepare your contribution.
1111

12+
## Setup
13+
14+
Before you can contribute to the codebase, you will need to fork the repo. This will look a bit different depending on what type of contribution you are making:
15+
16+
- All new features, bug-fixes, or **anything that touches `react-router` code** should be branched off of and merged into the `dev` branch
17+
- Changes that only touch documentation can be branched off of and merged into the `main` branch
18+
19+
The following steps will get you setup to contribute changes to this repo:
20+
21+
1. Fork the repo (click the <kbd>Fork</kbd> button at the top right of [this page](https://github.com/remix-run/react-router))
22+
2. Clone your fork locally
23+
24+
```bash
25+
# in a terminal, cd to parent directory where you want your clone to be, then
26+
git clone https://github.com/<your_github_username>/react-router.git
27+
cd react-router
28+
29+
# if you are making *any* code changes, make sure to checkout the dev branch
30+
git checkout dev
31+
```
32+
33+
3. Install dependencies and build. React Router uses [`yarn` (version 1)](https://classic.yarnpkg.com/lang/en/docs/install), so you should too. If you install using `npm`, unnecessary `package-lock.json` files will be generated.
34+
1235
## Think You Found a Bug?
1336

1437
Please conform to the issue template and provide a clear path to reproduction with a code example. Best is a pull request with a failing test. Next best is a link to CodeSandbox or repository that illustrates the bug.
@@ -23,11 +46,13 @@ We have learned by experience that small APIs are usually better, so we may be a
2346

2447
If you need a bug fixed and nobody is fixing it, your best bet is to provide a fix for it and make a [pull request](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request). Open source code belongs to all of us, and it's all of our responsibility to push it forward.
2548

26-
Issues with no activity for 60 days will be automatically closed, with a warning 7 days before closing.
27-
2849
## Making a Pull Request?
2950

30-
Pull requests need only the :+1: of two or more collaborators to be merged; when the PR author is a collaborator, that counts as one.
51+
Pull requests need only the approval of two or more collaborators to be merged; when the PR author is a collaborator, that counts as one.
52+
53+
> **Important:** When creating the PR in GitHub, make sure that you set the base to the correct branch. If you are submitting a PR that touches any code, this should be the `dev` branch. You set the base in GitHub when authoring the PR with the dropdown below the "Compare changes" heading:
54+
>
55+
> <img src="../static/base-branch.png" alt="" width="460" height="350" />
3156
3257
### Tests
3358

@@ -39,37 +64,115 @@ All commits that fix bugs or add features need a test.
3964

4065
All commits that change or add to the API must be done in a pull request that also updates all relevant examples and docs.
4166

42-
## Setup
67+
## Development
4368

44-
The following steps will get you setup to contribute changes to this repo:
69+
### Packages
70+
71+
React Router uses a monorepo to host code for multiple packages. These packages live in the `packages` directory.
4572

46-
1. Fork the repo (click the <kbd>Fork</kbd> button at the top right of [this
47-
page](https://github.com/remix-run/react-router))
73+
We use [Yarn workspaces](https://classic.yarnpkg.com/en/docs/workspaces/) to manage installation of dependencies and running various scripts. To get everything installed, make sure you have [Yarn (version 1) installed](https://classic.yarnpkg.com/lang/en/docs/install), and then run `yarn` or `yarn install` from the repo root.
4874

49-
2. Clone your fork locally
75+
### Building
76+
77+
Calling `yarn build` from the root directory will run the build, which should take only a few seconds. It's important to build all the packages together because `react-router-dom` and `react-router-native` both use `react-router` as a dependency.
78+
79+
### Testing
80+
81+
Before running the tests, you need to run a build. After you build, running `yarn test` from the root directory will run **every** package's tests. If you want to run tests for a specific package, use `yarn test --projects packages/<package-name>`:
5082

5183
```bash
52-
# in a terminal, cd to parent directory where you want your clone to be, then
53-
git clone https://github.com/<your_github_username>/react-router.git
54-
cd react-router
84+
# Test all packages
85+
yarn test
86+
87+
# Test only react-router-dom
88+
yarn test --projects packages/react-router-dom
5589
```
5690

57-
3. Install dependencies and build. React Router uses `yarn` (version 1), so you
58-
should too. If you install using `npm`, unnecessary `package-lock.json` files
59-
will be generated.
91+
## Repository Branching
6092

61-
## Development
93+
This repo maintains separate branches for different purposes. They will look something like this:
6294

63-
### Packages
95+
```
96+
- main > the most recent release and current docs
97+
- dev > code under active development between stable releases
98+
- v5 > the most recent code for a specific major release
99+
```
64100

65-
React Router uses a monorepo to host code for multiple packages. These packages live in the `packages` directory.
101+
There may be other branches for various features and experimentation, but all of the magic happens from these branches.
66102

67-
We use [Yarn workspaces](https://legacy.yarnpkg.com/en/docs/workspaces/) to manage installation of dependencies and running various scripts. To get everything installed, just run `yarn` or `yarn install` from the repo root.
103+
## New Releases
68104

69-
### Building
105+
When it's time to cut a new release, we follow a process based on our branching strategy depending on the type of release.
70106

71-
Calling `yarn build` from the root directory will run the build, which should take only a few seconds. It's important to build all the packages together because `react-router-dom` and `react-router-native` both use `react-router` as a dependency.
107+
### `react-router@next` Releases
72108

73-
### Testing
109+
We create experimental releases from the current state of the `dev` branch. They can be installed by using the `@next` tag:
110+
111+
```bash
112+
yarn add react-router-dom@next
113+
# or
114+
npm install react-router-dom@next
115+
```
116+
117+
These releases will be automated as PRs are merged into the `dev` branch.
118+
119+
### Latest Major Releases
120+
121+
```bash
122+
# Start from the dev branch.
123+
git checkout dev
74124

75-
Before running the tests, you need to run a build. After you build, running `yarn test` from the root directory will run **every** package's tests. If you want to run tests for a specific package, use e.g. `jest --projects package/react-router`.
125+
# Merge the main branch into dev to ensure that any hotfixes and
126+
# docs updates are available in the release.
127+
git merge main
128+
129+
# Create a new release branch from dev.
130+
git checkout -b release/v6.1.0
131+
132+
# Create a new tag and update version references throughout the
133+
# codebase.
134+
yarn run version minor # | "patch" | "major"
135+
136+
# Push the release branch along with the new release tag.
137+
git push origin release/v6.1.0 --follow-tags
138+
139+
# Wait for GitHub actions to run all tests. If the tests pass, the
140+
# release is ready to go! Merge the release branch into main and dev.
141+
git checkout main
142+
git merge release/v6.1.0
143+
git checkout dev
144+
git merge release/v6.1.0
145+
146+
# The release branch can now be deleted.
147+
git branch -D release/v6.1.0
148+
git push origin --delete release/v6.1.0
149+
150+
# Now go to GitHub and create the release from the new tag. Let
151+
# GitHub Actions take care of the rest!
152+
```
153+
154+
### Hot-fix Releases
155+
156+
Sometimes we have a crucial bug that needs to be patched right away. If the bug affects the latest release, we can create a new version directly from `main` (or the relevant major release branch where the bug exists):
157+
158+
```bash
159+
# From the main branch, make sure to run the build and all tests
160+
# before creating a new release.
161+
yarn && yarn build && yarn test
162+
163+
# Assuming the tests pass, create the release tag and update
164+
# version references throughout the codebase.
165+
yarn run version patch
166+
167+
# Push changes along with the new release tag.
168+
git push origin main --follow-tags
169+
170+
# In GitHub, create the release from the new tag and it will be
171+
# published via GitHub actions
172+
173+
# When the hot-fix is done, merge the changes into dev and clean
174+
# up conflicts as needed.
175+
git checkout dev
176+
git merge main
177+
git push origin dev
178+
```

static/base-branch.png

62.9 KB
Loading

0 commit comments

Comments
 (0)