|
2 | 2 |
|
3 | 3 | :+1::tada: First off, thanks for taking the time to contribute! :tada::+1:
|
4 | 4 |
|
5 |
| -Following you will see some guidelines about how to contribute with |
6 |
| -JavaScript SDK. |
| 5 | +We welcome contributions from the community! Please take some time to become |
| 6 | +acquainted with the process before submitting a pull request. |
7 | 7 |
|
8 |
| -## Branch Management |
| 8 | +## Pull Requests |
9 | 9 |
|
10 |
| -We use Gitflow to manage our branches and that's ok when `develop` branch is |
11 |
| -ahead of `master`. |
| 10 | +When creating a pull request, first fork this repository and clone it to your |
| 11 | +local development environment. Then add this repository as the upstream. |
12 | 12 |
|
13 |
| -- [Gitflow](https://nvie.com/posts/a-successful-git-branching-model/) by @nvie |
| 13 | +```console |
| 14 | +git clone https://github.com/mygithuborg/sdk-javascript.git |
| 15 | +cd sdk-javascript |
| 16 | +git remote add upstream https://github.com/cloudevents/sdk-javascript.git |
| 17 | +``` |
14 | 18 |
|
15 |
| -## Changelog |
| 19 | +Typically a pull request should relate to an existing issue. If you have |
| 20 | +found a bug, want to add an improvement, or suggest an API change, please |
| 21 | +create an issue before proceeding with a pull request. For very minor changes |
| 22 | +such as typos in the documentation this isn't really necessary. |
| 23 | + |
| 24 | +Create a branch for your work. If you are submitting a pull request that |
| 25 | +fixes or relates to an existing GitHub issue, you can use this in your |
| 26 | +branch name to keep things organized. For example, if you were to create |
| 27 | +a pull request to fix |
| 28 | +[this error with `httpAgent`](https://github.com/cloudevents/sdk-javascript/issues/48) |
| 29 | +you might create a branch named `48-fix-http-agent-error`. |
| 30 | + |
| 31 | +```console |
| 32 | +git fetch upstream |
| 33 | +git reset --hard upstream/master |
| 34 | +git checkout -b 48-fix-http-agent-error |
| 35 | +``` |
16 | 36 |
|
17 |
| -The [CHANGELOG.md](./CHANGELOG.md) will be updated with your commits if you format |
18 |
| -your commit messages following the |
19 |
| -[Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/#summary). |
20 |
| -If you are unsure what prefix to use for a commit, you can consult the |
21 |
| -[package.json](https://github.com/cloudevents/sdk-javascript/blob/master/package.json) file |
22 |
| -in this repository. In the `standard-version.types` section, you can see all of the commit |
23 |
| -types that will be committed to the changelog based on the prefix in the first line of |
24 |
| -your commit message. For example, the commit message: |
| 37 | +As you are working on your branch, changes may happen on `master`. Before |
| 38 | +submitting your pull request, be sure that your branch has been updated |
| 39 | +with the latest commits on `master`. |
25 | 40 |
|
26 |
| -```log |
27 |
| -fix: removed a bug that was causing the rotation of the earth to change |
| 41 | +```console |
| 42 | +git rebase upstream/master |
28 | 43 | ```
|
29 | 44 |
|
30 |
| -will show up in the "Bug Fixes" section of the changelog for a given release. |
| 45 | +This may cause conflicts if the files you are changing on your branch are |
| 46 | +also changed on master. Follow the `git` error messages to resolve these. |
| 47 | +If you've already pushed some changes to your `origin` fork, you'll |
| 48 | +need to force push these changes. |
31 | 49 |
|
32 |
| -## Pull Requests |
| 50 | +```console |
| 51 | +git push -f origin 48-fix-http-agent-error |
| 52 | +``` |
| 53 | + |
| 54 | +Once you have submitted your pull request, `master` may continue to evolve |
| 55 | +before your pull request has landed. If there are any commits on `master` |
| 56 | +that conflict with your changes, you may need to update your branch with |
| 57 | +these changes before the pull request can land. |
| 58 | + |
| 59 | +```console |
| 60 | +git fetch upstream |
| 61 | +git rebase upstream/master |
| 62 | +# fix any potential conflicts |
| 63 | +git push -f origin 48-fix-http-agent-error |
| 64 | +``` |
33 | 65 |
|
34 |
| -Guidelines about how to perform pull requests. |
| 66 | +This will cause the pull request to be updated with your changes, and |
| 67 | +CI will rerun. |
35 | 68 |
|
36 |
| -- before submit the PR, open an issue and link them |
| 69 | +### Updating Your Pull Request |
| 70 | + |
| 71 | +A maintainer may ask you to make changes to your pull request. Sometimes these |
| 72 | +changes are minor and shouldn't appear in the commit log. For example, you may |
| 73 | +have a typo in one of your code comments that should be fixed before merge. |
| 74 | +You can prevent this from adding noise to the commit log with an interactive |
| 75 | +rebase. See the [git documentation](https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History) |
| 76 | +for details. |
| 77 | + |
| 78 | +```console |
| 79 | +git commit -m "fixup: fix typo" |
| 80 | +git rebase -i upstream/master # follow git instructions |
| 81 | +``` |
| 82 | + |
| 83 | +Once you have rebased your commits, you can force push to your fork as before. |
| 84 | +In most cases, there should only be a single commit in a pull request. |
| 85 | + |
| 86 | +**NB: Be sure you have run all tests before submitting your pull request.** |
37 | 87 |
|
38 | 88 | ### Commit Messages
|
39 | 89 |
|
40 |
| -Please follow the Conventional Commits specification noted above. the first line of |
41 |
| -your commit should be prefixed with a type, be a single sentence with no period, and |
42 |
| -succinctly indicate what this commit changes. |
| 90 | +Please follow the |
| 91 | +[Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/#summary). |
| 92 | +The first line of your commit should be prefixed with a type, be a single |
| 93 | +sentence with no period, and succinctly indicate what this commit changes. |
43 | 94 |
|
44 | 95 | All commit message lines should be kept to fewer than 80 characters if possible.
|
45 | 96 |
|
46 |
| -### PR to `develop` |
| 97 | +An example of a good commit message. |
47 | 98 |
|
48 |
| -- fixes in the documentation (readme, contributors) |
49 |
| -- propose new files for the documentation |
50 |
| -- implementation of new features |
| 99 | +```log |
| 100 | +docs: remove 0.1, 0.2 spec support from README |
| 101 | +``` |
51 | 102 |
|
52 |
| -### PR to `master` |
| 103 | +## Style Guide |
53 | 104 |
|
54 |
| -- hot fixes |
| 105 | +Code style for this module is maintained using [`eslint`](https://www.npmjs.com/package/eslint). |
| 106 | +When you run tests with `npm test` linting is performed first. If you want to |
| 107 | +check your code style for linting errors without running tests, you can just |
| 108 | +run `npm run lint`. If there are errors, you can usually fix them automatically |
| 109 | +by running `npm run fix`. |
55 | 110 |
|
56 |
| -## Style Guide |
| 111 | +Linting rules are declared in [.eslintrc](https://github.com/cloudevents/sdk-javascript/blob/master/.eslintrc). |
| 112 | + |
| 113 | +## Branch Management |
| 114 | + |
| 115 | +The `master` branch is is the bleeding edge. New major versions of the module |
| 116 | +are cut from this branch and tagged. If you intend to submit a pull request |
| 117 | +you should use `master HEAD` as your starting point. |
| 118 | + |
| 119 | +Each major release will result in a new branch and tag. For example, the |
| 120 | +release of version 1.0.0 of the module will result in a `v1.0.0` tag on the |
| 121 | +release commit, and a new branch `v1.x.y` for subsequent minor and patch |
| 122 | +level releases of that major version. However, development will continue |
| 123 | +apace on `master` for the next major version - e.g. 2.0.0. Version branches |
| 124 | +are only created for each major version. Minor and patch level releases |
| 125 | +are simply tagged on the major version branch. |
| 126 | + |
| 127 | +If there is a change on `master` that should be backported to a previous version, |
| 128 | +the pull request for that change should be labeled with the `v1.x.y-backport` |
| 129 | +label. When it comes time to release a minor or patch level version of a |
| 130 | +previous release, the commits in these labeled pull requests will be cherry |
| 131 | +picked and backported to the `v1.x.y` branch, for example, and a new tag is |
| 132 | +applied, e.g. `v1.1.0`. |
| 133 | + |
| 134 | +**NB Most of these tasks are handled by maintainers. Community contributors |
| 135 | +will typically not need to worry about all of this.** |
| 136 | + |
| 137 | +## Changelog |
| 138 | + |
| 139 | +The [CHANGELOG.md](./CHANGELOG.md) will be updated with your commits if you format |
| 140 | +your commit messages following the |
| 141 | +[Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/#summary). |
| 142 | +If you are unsure what prefix to use for a commit, you can consult the |
| 143 | +[package.json](https://github.com/cloudevents/sdk-javascript/blob/master/package.json) file |
| 144 | +in this repository. In the `standard-version.types` section, you can see all of the commit |
| 145 | +types that will be committed to the changelog based on the prefix in the first line of |
| 146 | +your commit message. For example, the commit message: |
| 147 | + |
| 148 | +```log |
| 149 | +fix: removed a bug that was causing the rotation of the earth to change |
| 150 | +``` |
| 151 | + |
| 152 | +will show up in the "Bug Fixes" section of the changelog for a given release. |
57 | 153 |
|
58 |
| -_TODO_ |
| 154 | +## Maintainer's Guide |
59 | 155 |
|
60 |
| -### JavaScript Style Guide |
| 156 | +Here are a few tips for repository maintainers. |
61 | 157 |
|
62 |
| -_TODO_ |
| 158 | +* Stay on top of your pull requests. PRs that languish for too long can become difficult to merge. |
| 159 | +* Work from your own fork. As you are making contributions to the project, you should be working from your own fork just as outside contributors do. This keeps the branches in github to a minimum and reduces unnecessary CI runs. |
| 160 | +* Try to proactively label issues with backport labels if it's obvious that a change should be backported to previous releases. |
| 161 | +* When landing pull requests, if there is more than one commit, try to squash into a single commit. |
0 commit comments