Skip to content

Commit 4a7b137

Browse files
committed
Add 10-step guide to contributing
1 parent 8bcce66 commit 4a7b137

File tree

1 file changed

+148
-11
lines changed

1 file changed

+148
-11
lines changed

CONTRIBUTING.md

Lines changed: 148 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ __Before__ contributing, read the [Code of Conduct][stdlib-code-of-conduct], whi
1919

2020
When filing new issues and commenting on existing issues on this repository, please ensure that discussions are related to concrete technical issues. For general questions and help, consult the [FAQ][stdlib-faq] and visit the [Gitter][stdlib-gitter] channel.
2121

22-
Before filing a potential bug report,
22+
__Before__ filing a potential bug report,
2323

2424
* Search for existing issues and pull requests.
2525
* Try some debugging techniques to help isolate the problem, including logging inputs and outputs.
2626

27-
If the source of the problem is a third party package, file a bug report with the relevant package author, rather than here.
27+
If the source of the problem is a third party package, file a bug report with the relevant package author, rather than on this repository.
2828

2929
When filing an issue, provide the following, where possible:
3030

@@ -41,23 +41,73 @@ When pasting code blocks or output, use triple backticks to enable proper format
4141
Be aware that the `@` symbol tags users on GitHub, so __always__ surround package names with backticks (e.g., `@stdlib/utils/copy`).
4242

4343

44-
## Code
44+
### Code
4545

46-
Before contributing code, be sure to
46+
__Before__ contributing code, be sure to
4747

4848
* read and understand the [licensing terms][stdlib-license].
4949
* read and understand the [style guides][stdlib-style-guides].
5050

5151
For instructions on how to setup and configure your environment, be sure to
5252

53-
* read the [development guide][stdlib-development].
53+
* read and follow the [development guide][stdlib-development].
5454

55-
If you want to contribute a new package to stdlib, be sure to
55+
If you want to contribute a new feature or a breaking change to stdlib, be sure to
5656

57-
* read the [package development guide][stdlib-docs].
57+
* consult the [Gitter][stdlib-gitter] channel to discuss ideas and to gather feedback as to whether a feature would be better developed as an external package.
58+
* write an RFC (request for comments) detailing the proposed change.
59+
* wait for RFC approval.
60+
* adhere to the guidance set forth in the RFC.
61+
62+
If you want to contribute a new package, be sure to
63+
64+
* read and follow the [package development guide][stdlib-docs].
65+
66+
If you are unfamiliar with [git][git], the version control system used by GitHub and this project,
67+
68+
* see the [git][git] docs.
69+
* try a tutorial, such as the [tutorial][github-git-tutorial] provided by GitHub.
5870

5971
Next, take a look around the project, noting the style and organization of documentation, tests, examples, benchmarks, and source implementations. Consistency is highly __prioritized__ within stdlib. Thus, the more you are able to match and adhere to project conventions and style, the more likely your contribution will be accepted. While we have done our best to automate linting and style guidelines, such automation is not perfect and cannot adequately capture the inevitable exceptions and nuance to many rules. In short, the more you study existing practice, the better prepared you will be to contribute to stdlib.
6072

73+
74+
#### Step 1: Fork
75+
76+
[Fork][github-fork] the repository on GitHub and clone the repository to your local machine.
77+
78+
``` bash
79+
$ git clone https://github.com/<username>/stdlib.git
80+
```
81+
82+
where `<username>` is your GitHub username (assuming you are using GitHub to manage public repositories). The repository has a large commit history, leading to slow download times. If you are not interested in code archeology, you can reduce the download time by limiting the clone [depth][git-clone-depth].
83+
84+
``` bash
85+
$ git clone --depth=<depth> https://github.com/<username>/stdlib.git
86+
```
87+
88+
where `<depth>` refers to the number of commits you want to download (as few as `1` and as many as the entire project history).
89+
90+
If you are behind a firewall, you may need to use the `https` protocol, rather than the `git` protocol.
91+
92+
``` bash
93+
$ git config --global url."https://".insteadOf git://
94+
```
95+
96+
Once you have finished cloning the repository into the destination directory, you should see the folder `stdlib`. To proceed with configuring your environment, navigate to the project folder.
97+
98+
``` bash
99+
$ cd stdlib
100+
```
101+
102+
And finally, add an `upstream` [remote][git-remotes] to allow syncing changes between this repository and your local version.
103+
104+
``` bash
105+
$ git remote add upstream git://github.com/stdlib-js/stdlib.git
106+
```
107+
108+
109+
#### Step 2: Branch
110+
61111
For modifications intended to be included in stdlib, create a new local branch.
62112

63113
``` bash
@@ -66,14 +116,59 @@ $ git checkout -b <branch>
66116

67117
where `<branch>` is the branch name. Both the `master` and `develop` branches for the main stdlib project are protected, and direct modifications to these branches will __not__ be accepted. Instead, all contributions should be made on non-master and non-develop local branches, including documentation changes and other non-code modifications.
68118

69-
During development, to incorporate recent changes from the upstream repository, you should [rebase][git-rebase] your local branch, reapplying your local commits on top of the current upstream `HEAD`. This procedure is in contrast to performing a standard [merge][git-merge], which may interleave development histories. The rationale is twofold:
119+
120+
#### Step 3: Write
121+
122+
Start making your changes and/or implementing the new feature. Any text you write should follow the [text style guide][stdlib-style-guides], including comments and API documentation.
123+
124+
125+
#### Step 4: Commit
126+
127+
Ensure that you have configured [git][git] to know your name and email address.
128+
129+
``` bash
130+
$ git config --global user.name "Jane Doe"
131+
$ git config --global user.email "jane.doe@example.com"
132+
```
133+
134+
Add changed files and commit.
135+
136+
``` bash
137+
$ git add files/which/changed
138+
$ git commit
139+
```
140+
141+
When writing commit messages, follow the git [style guide][stdlib-style-guides].
142+
143+
144+
#### Step 5: Sync
145+
146+
To incorporate recent changes from the `upstream` repository during development, you should [rebase][git-rebase] your local branch, reapplying your local commits on top of the current upstream `HEAD`. This procedure is in contrast to performing a standard [merge][git-merge], which may interleave development histories. The rationale is twofold:
70147

71148
1. interleaved histories make [squashing][git-rewriting-history] commits more difficult
72149
2. a standard merge increases the risk of incomplete/broken commits appearing in the git history.
73150

74151
An ideal commit history is one in which, at no point in time, is the project in a broken state. While not always possible (mistakes happen), striving for this ideal facilitates time travel and software archeology.
75152

76-
Before opening a [pull request][github-pull-request] on the upstream repository, run project tests to ensure that the changes introduced have not left the repository in a broken state.
153+
``` bash
154+
$ git fetch upstream
155+
$ git rebase upstream/develop
156+
```
157+
158+
159+
#### Step 6: Test
160+
161+
Tests should accompany __all__ bug fixes and features. For guidance on how to write tests, consult existing tests within the project.
162+
163+
__Before__ submitting a [pull request][github-pull-request] to the `upstream` repository, ensure that all tests pass, including linting. If git hooks have been enabled,
164+
165+
``` bash
166+
$ make init
167+
```
168+
169+
linting should be automatically triggered prior to each commit. Any [pull requests][github-pull-request] which include failing tests and/or lint errors will __not__ be accepted.
170+
171+
To run project tests,
77172

78173
``` bash
79174
$ make test
@@ -83,11 +178,48 @@ $ make benchmark
83178

84179
Note that each of the above tasks can take considerable time (>30 minutes per task).
85180

86-
Once your contribution is ready to be incorporated in the upstream repository, open a [pull request][github-pull-request] against the `develop` branch. A project contributor will review the contribution, provide feedback, and potentially request changes. After any changes have been resolved and continuous integration tests have passed, a contributor will approve a [pull request][github-pull-request] for inclusion in the project.
181+
182+
#### Step 7: Push
183+
184+
Push your changes to your remote GitHub repository.
185+
186+
``` bash
187+
$ git push origin <branch>
188+
```
189+
190+
where `<branch>` is the name of your branch.
191+
192+
193+
#### Step 8: Pull Request
194+
195+
Once your contribution is ready to be incorporated in the `upstream` repository, open a [pull request][github-pull-request] against the `develop` branch. A project contributor will review the contribution, provide feedback, and potentially request changes.
196+
197+
> Receiving feedback is the most __important__, and often the most __valuable__, part of the submission process. Don't get disheartened!
198+
199+
To make changes to your [pull request][github-pull-request], make changes to your branch. Each time you push changes to your forked repository, GitHub will automatically update the [pull request][github-pull-request].
200+
201+
``` bash
202+
$ git add files/which/changed
203+
$ git commit
204+
$ git push origin <branch>
205+
```
87206

88207
Note that, once a [pull request][github-pull-request] has been made (i.e., your local repository commits have been pushed to a remote server), you should __not__ perform any further [rewriting][git-rewriting-history] of git history. If the history needs modification, a contributor will modify the history during the merge process. The rationale for __not__ rewriting public history is that doing so invalidates the commit history for anyone else who has pulled your changes, thus imposing additional burdens on collaborators to ensure that their local versions match the modified history.
89208

90-
Once merged, __congratulations__! You are an official contributor to stdlib!
209+
210+
#### Step 9: Land
211+
212+
After any changes have been resolved and continuous integration tests have passed, a contributor will approve a [pull request][github-pull-request] for inclusion in the project. Once merged, the [pull request][github-pull-request] will be updated with the merge commit, and the [pull request][github-pull-request] will be closed.
213+
214+
Note that, during the merge process, multiple commits will often be [squashed][git-rewriting-history].
215+
216+
217+
#### Step 10: Celebrate
218+
219+
__Congratulations__! You are an official contributor to stdlib! Thank you for your hard work and patience!
220+
221+
222+
### Notes
91223

92224
Phew. While the above may be a lot to remember, even for what seem like minor changes, eventually it becomes routine and part of the normal development flow. Part of the motivation for enforcing process is to ensure that all code contributions meet a certain quality threshold, thus helping reviewers focus less on non-substantive issues like style and failing tests and more on substantive issues such as contribution content and merit. Know that your patience, hard work, time, and effort are greatly appreciated!
93225

@@ -108,7 +240,12 @@ Phew. While the above may be a lot to remember, even for what seem like minor ch
108240
[github-pull-request]: https://help.github.com/articles/creating-a-pull-request/
109241
[github-gist]: https://gist.github.com/
110242
[github-markdown-guide]: https://guides.github.com/features/mastering-markdown/
243+
[github-fork]: https://help.github.com/articles/fork-a-repo/
244+
[github-git-tutorial]: http://try.github.io/levels/1/challenges/1
111245

246+
[git]: http://git-scm.com/
247+
[git-clone-depth]: https://git-scm.com/docs/git-clone#git-clone---depthltdepthgt
248+
[git-remotes]: https://git-scm.com/book/en/v2/Git-Basics-Working-with-Remotes
112249
[git-rebase]: https://git-scm.com/docs/git-rebase
113250
[git-merge]: https://git-scm.com/docs/git-merge
114251
[git-rewriting-history]: https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History

0 commit comments

Comments
 (0)