Skip to content

Commit cd3d1e8

Browse files
committed
docs: add instructions and details to contributors guide
Signed-off-by: Lance Ball <[email protected]>
1 parent e83db29 commit cd3d1e8

File tree

1 file changed

+132
-34
lines changed

1 file changed

+132
-34
lines changed

CONTRIBUTING.md

Lines changed: 132 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,61 +2,159 @@
22

33
:+1::tada: First off, thanks for taking the time to contribute! :tada::+1:
44

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.
77

8-
## Branch Management
8+
## Pull Requests
99

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.
1212

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+
git remote add upstream https://github.com/cloudevents/sdk-javascript.git
16+
```
1417

15-
## Changelog
18+
Typically a pull request should relate to an existing issue. If you have
19+
found a bug, want to add an improvement, or suggest an API change, please
20+
create an issue before proceeding with a pull request. For very minor changes
21+
such as typos in the documentation this isn't really necessary.
22+
23+
Create a branch for your work. If you are submitting a pull request that
24+
fixes or relates to an existing GitHub issue, you can use this in your
25+
branch name to keep things organized. For example, if you were to create
26+
a pull request to fix
27+
[this error with `httpAgent`](https://github.com/cloudevents/sdk-javascript/issues/48)
28+
you might create a branch named `48-fix-http-agent-error`.
29+
30+
```console
31+
git fetch upstream
32+
git reset --hard upstream/master
33+
git co -b 48-fix-http-agent-error
34+
```
1635

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:
36+
As you are working on your branch, changes may happen on `master`. Before
37+
submitting your pull request, be sure that your branch has been updated
38+
with the latest commits on `master`.
2539

26-
```log
27-
fix: removed a bug that was causing the rotation of the earth to change
40+
```console
41+
git rebase upstream/master
2842
```
2943

30-
will show up in the "Bug Fixes" section of the changelog for a given release.
44+
This may cause conflicts if the files you are changing on your branch are
45+
also changed on master. Follow the `git` error messages to resolve these.
46+
If you've already pushed some changes to your `origin` fork, you'll
47+
need to force push these changes.
3148

32-
## Pull Requests
49+
```console
50+
git push -f origin 48-fix-http-agent-error
51+
```
52+
53+
Once you have submitted your pull request, `master` may continue to evolve
54+
before your pull request has landed. If there are any commits on `master`
55+
that conflict with your changes, you may need to update your branch with
56+
these changes before the pull request can land.
57+
58+
```console
59+
git fetch upstream
60+
git rebase upstream/master
61+
# fix any potential conflicts
62+
git push -f origin 48-fix-http-agent-error
63+
```
3364

34-
Guidelines about how to perform pull requests.
65+
This will cause the pull request to be updated with your changes, and
66+
CI will rerun.
3567

36-
- before submit the PR, open an issue and link them
68+
### Updating Your Pull Request
69+
70+
A maintainer may ask you to make changes to your pull request. Sometimes these
71+
changes are minor and shouldn't appear in the commit log. For example, you may
72+
have a typo in one of your code comments that should be fixed before merge.
73+
You can prevent this from adding noise to the commit log with an interactive
74+
rebase. See the [git documentation](https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History)
75+
for details.
76+
77+
```console
78+
git commit -m "fixup: fix typo"
79+
git rebase -i upstream/master # follow git instructions
80+
```
81+
82+
Once you have rebased your commits, you can force push to your fork as before.
83+
In most cases, there should only be a single commit in a pull request.
84+
85+
**NB: Be sure you have run all tests before submitting your pull request.**
3786

3887
### Commit Messages
3988

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.
89+
Please follow the
90+
[Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/#summary).
91+
The first line of your commit should be prefixed with a type, be a single
92+
sentence with no period, and succinctly indicate what this commit changes.
4393

4494
All commit message lines should be kept to fewer than 80 characters if possible.
4595

46-
### PR to `develop`
96+
An example of a good commit message.
4797

48-
- fixes in the documentation (readme, contributors)
49-
- propose new files for the documentation
50-
- implementation of new features
98+
```log
99+
docs: remove 0.1, 0.2 spec support from README
100+
```
51101

52-
### PR to `master`
102+
## Style Guide
53103

54-
- hot fixes
104+
Code style for this module is maintained using [`eslint`](https://www.npmjs.com/package/eslint).
105+
When you run tests with `npm test` linting is performed first. If you want to
106+
check your code style for linting errors without running tests, you can just
107+
run `npm run lint`. If there are errors, you can usually fix them automatically
108+
by running `npm run fix`.
55109

56-
## Style Guide
110+
Linting rules are declared in [.eslintrc](https://github.com/cloudevents/sdk-javascript/blob/master/.eslintrc).
111+
112+
## Branch Management
113+
114+
The `master` branch is is the bleeding edge. New major versions of the module
115+
are cut from this branch and tagged. If you intend to submit a pull request
116+
you should use `master HEAD` as your starting point.
117+
118+
Each major release will result in a new branch and tag. For example, the
119+
release of version 1.0.0 of the module will result in a `v1.0.0` tag on the
120+
release commit, and a new branch `v1.x.y` for subsequent minor and patch
121+
level releases of that major version. However, development will continue
122+
apace on `master` for the next major version - e.g. 2.0.0. Version branches
123+
are only created for each major version. Minor and patch level releases
124+
are simply tagged on the major version branch.
125+
126+
If there is a change on `master` that should be backported to a previous version,
127+
the pull request for that change should be labeled with the `v1.x.y-backport`
128+
label. When it comes time to release a minor or patch level version of a
129+
previous release, the commits in these labeled pull requests will be cherry
130+
picked and backported to the `v1.x.y` branch, for example, and a new tag is
131+
applied, e.g. `v1.1.0`.
132+
133+
**NB Most of these tasks are handled by maintainers. Community contributors
134+
will typically not need to worry about all of this.**
135+
136+
## Changelog
137+
138+
The [CHANGELOG.md](./CHANGELOG.md) will be updated with your commits if you format
139+
your commit messages following the
140+
[Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/#summary).
141+
If you are unsure what prefix to use for a commit, you can consult the
142+
[package.json](https://github.com/cloudevents/sdk-javascript/blob/master/package.json) file
143+
in this repository. In the `standard-version.types` section, you can see all of the commit
144+
types that will be committed to the changelog based on the prefix in the first line of
145+
your commit message. For example, the commit message:
146+
147+
```log
148+
fix: removed a bug that was causing the rotation of the earth to change
149+
```
150+
151+
will show up in the "Bug Fixes" section of the changelog for a given release.
57152

58-
_TODO_
153+
## Maintainer's Guide
59154

60-
### JavaScript Style Guide
155+
Here are a few tips for repository maintainers.
61156

62-
_TODO_
157+
* Stay on top of your pull requests. PRs that languish for too long can become difficult to merge.
158+
* 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.
159+
* Try to proactively label issues with backport labels if it's obvious that a change should be backported to previous releases.
160+
* When landing pull requests, if there is more than one commit, try to squash into a single commit.

0 commit comments

Comments
 (0)