|
| 1 | +# Contributing to IxJS |
| 2 | + |
| 3 | +[Read and abide by the Code of Conduct](CODE_OF_CONDUCT.md)! Even if you don't read it, |
| 4 | +it still applies to you. Ignorance is not an exemption. |
| 5 | + |
| 6 | +Contents |
| 7 | + |
| 8 | +<!-- START doctoc generated TOC please keep comment here to allow auto update --> |
| 9 | +<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> |
| 10 | + |
| 11 | + |
| 12 | +- [Submitting a Pull Request (PR)](#submitting-a-pull-request-pr) |
| 13 | + - [After your pull request is merged](#after-your-pull-request-is-merged) |
| 14 | +- [Coding Style Guidelines](#coding-style-guidelines) |
| 15 | +- [Unit Tests](#unit-tests) |
| 16 | + - [CI Tests](#ci-tests) |
| 17 | +- [Commit Message Guidelines](#commit-message-guidelines) |
| 18 | + - [Commit Message Format](#commit-message-format) |
| 19 | + - [Revert](#revert) |
| 20 | + - [Type](#type) |
| 21 | + - [Scope](#scope) |
| 22 | + - [Subject](#subject) |
| 23 | + - [Body](#body) |
| 24 | + - [Footer](#footer) |
| 25 | + |
| 26 | +<!-- END doctoc generated TOC please keep comment here to allow auto update --> |
| 27 | + |
| 28 | +(This document is a work and progress and is subject to change) |
| 29 | + |
| 30 | +## Submitting a Pull Request (PR) |
| 31 | +Before you submit your Pull Request (PR) consider the following guidelines: |
| 32 | + |
| 33 | +* Search [GitHub](https://github.com/ReactiveX/IxJS/pulls) for an open or closed PR |
| 34 | + that relates to your submission. You don't want to duplicate effort. |
| 35 | +* Make your changes in a new git branch: |
| 36 | + |
| 37 | + ```shell |
| 38 | + git checkout -b my-fix-branch master |
| 39 | + ``` |
| 40 | + |
| 41 | +* Create your patch, following [code style guidelines](#coding-style-guidelines), and **including appropriate test cases**. |
| 42 | +* Run the full test suite and ensure that all tests pass. |
| 43 | +* Run the micro and macro performance tests against your feature branch and compare against master |
| 44 | + to ensure performance wasn't changed for the worse. |
| 45 | +* Commit your changes using a descriptive commit message that follows our |
| 46 | + [commit message guidelines](#commit-message-guidelines). Adherence to these conventions |
| 47 | + is necessary because release notes are automatically generated from these messages. |
| 48 | +
|
| 49 | + ```shell |
| 50 | + git commit -a |
| 51 | + ``` |
| 52 | + Note: the optional commit `-a` command line option will automatically "add" and "rm" edited files. |
| 53 | +
|
| 54 | +* Push your branch to GitHub: |
| 55 | +
|
| 56 | + ```shell |
| 57 | + git push origin my-fix-branch |
| 58 | + ``` |
| 59 | +
|
| 60 | +* In GitHub, send a pull request to `IxJS:master`. |
| 61 | +* If we suggest changes then: |
| 62 | + * Make the required updates. |
| 63 | + * Re-run the test suites to ensure tests are still passing. |
| 64 | + * Re-run performance tests to make sure your changes didn't hurt performance. |
| 65 | + * Rebase your branch and force push to your GitHub repository (this will update your Pull Request): |
| 66 | + |
| 67 | + ```shell |
| 68 | + git rebase master -i |
| 69 | + git push -f |
| 70 | + ``` |
| 71 | + |
| 72 | +That's it! Thank you for your contribution! |
| 73 | +
|
| 74 | +
|
| 75 | +### After your pull request is merged |
| 76 | +
|
| 77 | +After your pull request is merged, you can safely delete your branch and pull the changes |
| 78 | +from the main (upstream) repository: |
| 79 | +
|
| 80 | +* Delete the remote branch on GitHub either through the GitHub web UI or your local shell as follows: |
| 81 | +
|
| 82 | + ```shell |
| 83 | + git push origin --delete my-fix-branch |
| 84 | + ``` |
| 85 | +
|
| 86 | +* Check out the master branch: |
| 87 | +
|
| 88 | + ```shell |
| 89 | + git checkout master -f |
| 90 | + ``` |
| 91 | +
|
| 92 | +* Delete the local branch: |
| 93 | +
|
| 94 | + ```shell |
| 95 | + git branch -D my-fix-branch |
| 96 | + ``` |
| 97 | +
|
| 98 | +* Update your master with the latest upstream version: |
| 99 | +
|
| 100 | + ```shell |
| 101 | + git pull --ff upstream master |
| 102 | + ``` |
| 103 | +
|
| 104 | +## Coding Style Guidelines |
| 105 | +
|
| 106 | +- Please use proper types and generics throughout your code. |
| 107 | +- 2 space indentation only |
| 108 | +- favor readability over terseness |
| 109 | +
|
| 110 | +(TBD): For now try to follow the style that exists elsewhere in the source, and use your best judgment. |
| 111 | +
|
| 112 | +
|
| 113 | +## Unit Tests |
| 114 | +
|
| 115 | +Unit tests are located under the [spec directory](/spec). Unit tests are written using [tape](https://github.com/substack/tape) |
| 116 | +
|
| 117 | +Each operator under test must be in its own file to cover the following cases: |
| 118 | +
|
| 119 | +- Never |
| 120 | +- Empty |
| 121 | +- Single/Multiple Values |
| 122 | +- Error in the sequence |
| 123 | +
|
| 124 | +If the operator accepts a function as an argument from the user/developer (for example `filter(fn)` or `zip(a, fn)`), |
| 125 | +then it must cover the following cases: |
| 126 | +
|
| 127 | +- Success with all values in the callback |
| 128 | +- Success with the context, if any allowed in the operator signature |
| 129 | +- If an error is thrown |
| 130 | +
|
| 131 | +### CI Tests |
| 132 | +
|
| 133 | +- Using [Travis](https://travis-ci.org/) on your forked version of IxJS will allow running CI tests on that fork before submitting a PR to master |
| 134 | + - Simply create a `Travis` account and add your fork as a new project |
| 135 | +- As master runs both of these tests per each check in, it'd be welcome to setup those test before creating your PR |
| 136 | + |
| 137 | +## Commit Message Guidelines |
| 138 | + |
| 139 | +We have very precise rules over how our git commit messages can be formatted. This leads to **more |
| 140 | +readable messages** that are easy to follow when looking through the **project history**. But also, |
| 141 | +we use the git commit messages to **generate the IxJS change log**. Helper script `npm run commit` |
| 142 | +provides command line based wizard to format commit message easily. |
| 143 | + |
| 144 | +### Commit Message Format |
| 145 | +Each commit message consists of a **header**, a **body** and a **footer**. The header has a special |
| 146 | +format that includes a **type**, a **scope** and a **subject**: |
| 147 | + |
| 148 | +``` |
| 149 | +<type>(<scope>): <subject> |
| 150 | +<BLANK LINE> |
| 151 | +<body> |
| 152 | +<BLANK LINE> |
| 153 | +<footer> |
| 154 | +``` |
| 155 | + |
| 156 | +The **header** is mandatory and the **scope** of the header is optional. |
| 157 | + |
| 158 | +Any line of the commit message cannot be longer than 100 characters! This allows the message to be easier |
| 159 | +to read on GitHub as well as in various git tools. |
| 160 | + |
| 161 | +### Revert |
| 162 | +If the commit reverts a previous commit, it should begin with `revert: `, followed by the header of the reverted commit. In the body it should say: `This reverts commit <hash>.`, where the hash is the SHA of the commit being reverted. |
| 163 | + |
| 164 | +### Type |
| 165 | +Must be one of the following: |
| 166 | + |
| 167 | +* **feat**: A new feature |
| 168 | +* **fix**: A bug fix |
| 169 | +* **docs**: Documentation only changes |
| 170 | +* **style**: Changes that do not affect the meaning of the code (white-space, formatting, missing |
| 171 | + semi-colons, etc) |
| 172 | +* **refactor**: A code change that neither fixes a bug nor adds a feature |
| 173 | +* **perf**: A code change that improves performance |
| 174 | +* **test**: Adding missing tests |
| 175 | +* **chore**: Changes to the build process or auxiliary tools and libraries such as documentation |
| 176 | + generation |
| 177 | + |
| 178 | +### Scope |
| 179 | +The scope could be anything specifying place of the commit change. For example |
| 180 | +`Observable`, `Subject`, `switchMap`, etc. |
| 181 | + |
| 182 | +### Subject |
| 183 | +The subject contains succinct description of the change: |
| 184 | + |
| 185 | +* use the imperative, present tense: "change" not "changed" nor "changes" |
| 186 | +* don't capitalize first letter |
| 187 | +* no dot (.) at the end |
| 188 | +
|
| 189 | +### Body |
| 190 | +Just as in the **subject**, use the imperative, present tense: "change" not "changed" nor "changes". |
| 191 | +The body should include the motivation for the change and contrast this with previous behavior. |
| 192 | +
|
| 193 | +### Footer |
| 194 | +The footer should contain any information about **Breaking Changes** and is also the place to |
| 195 | +reference GitHub issues that this commit **Closes**. |
| 196 | +
|
| 197 | +**Breaking Changes** should start with the word `BREAKING CHANGE:` with a space or two newlines. The rest of the commit message is then used for this. |
0 commit comments