Skip to content

Commit ac64744

Browse files
author
Matthew Fisher
committed
Merge pull request #680 from opdemand/add-contributing
docs(standards): add commit style guide
2 parents 8c0af54 + 6833b28 commit ac64744

2 files changed

Lines changed: 297 additions & 15 deletions

File tree

CONTRIBUTING.md

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# How to Contribute
2+
3+
The Deis project is Apache 2.0 licensed and accepts contributions via Github pull
4+
requests. This document outlines some of the conventions on commit message formatting,
5+
contact points for developers and other resources to make getting your contribution
6+
accepted.
7+
8+
# Certificate of Origin
9+
10+
By contributing to this project you agree to the Developer Certificate of Origin (DCO).
11+
This document was created by the Linux Kernel community and is a simple statement that
12+
you, as a contributor, have the legal right to make the contribution.
13+
14+
```
15+
Developer Certificate of Origin
16+
Version 1.1
17+
18+
Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
19+
660 York Street, Suite 102,
20+
San Francisco, CA 94110 USA
21+
22+
Everyone is permitted to copy and distribute verbatim copies of this
23+
license document, but changing it is not allowed.
24+
25+
26+
Developer's Certificate of Origin 1.1
27+
28+
By making a contribution to this project, I certify that:
29+
30+
(a) The contribution was created in whole or in part by me and I
31+
have the right to submit it under the open source license
32+
indicated in the file; or
33+
34+
(b) The contribution is based upon previous work that, to the best
35+
of my knowledge, is covered under an appropriate open source
36+
license and I have the right under that license to submit that
37+
work with modifications, whether created in whole or in part
38+
by me, under the same open source license (unless I am
39+
permitted to submit under a different license), as indicated
40+
in the file; or
41+
42+
(c) The contribution was provided directly to me by some other
43+
person who certified (a), (b) or (c) and I have not modified
44+
it.
45+
46+
(d) I understand and agree that this project and the contribution
47+
are public and that a record of the contribution (including all
48+
personal information I submit with it, including my sign-off) is
49+
maintained indefinitely and may be redistributed consistent with
50+
this project or the open source license(s) involved.
51+
```
52+
53+
54+
# Support Channels
55+
56+
- IRC: #[deis](irc://irc.freenode.org:6667/#deis) IRC channel on freenode.org
57+
58+
## Getting Started
59+
60+
- Fork the repository on GitHub
61+
- Read the README.md for build instructions
62+
63+
## Contribution Flow
64+
65+
This is a rough outline of what a contributor's workflow looks like:
66+
67+
- Create a topic branch from where you want to base your work. This is usually master.
68+
- Make commits of logical units.
69+
- Make sure your commit messages are in the proper format, see below
70+
- Push your changes to a topic branch in your fork of the repository.
71+
- Submit a pull request
72+
73+
Thanks for your contributions!
74+
75+
### Format of the Commit Message
76+
77+
We follow a rough convention for commit messages borrowed from CoreOS, who borrowed theirs
78+
from AngularJS. This is an example of a commit:
79+
80+
```
81+
feat(scripts/test-cluster): add a cluster test command
82+
83+
this uses tmux to setup a test cluster that you can easily kill and
84+
start for debugging.
85+
```
86+
87+
To make it more formal it looks something like this:
88+
89+
```
90+
{type}({scope}): {subject}
91+
<BLANK LINE>
92+
{body}
93+
<BLANK LINE>
94+
{footer}
95+
```
96+
97+
Any line of the commit message cannot be longer than 90 characters, with the subject line
98+
limited to 70 characters. This allows the message to be easier to read on github as well
99+
as in various git tools.
100+
101+
### More Details on Commits
102+
103+
For more details see the [commit style guide][1].
104+
105+
[1]: http://docs.deis.io/en/latest/contributing/standards/#commit-style-guide

docs/contributing/standards.rst

Lines changed: 192 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,8 @@ into the official repository, your code must pass two tests:
3333

3434
.. code-block:: console
3535
36-
$ cd $HOME/projects/deis
37-
$ make flake8
38-
flake8
39-
$
36+
$ make -C controller flake8
37+
flake8
4038
4139
No output, as above, means ``flake8`` found no errors. If errors
4240
are reported, fix them in your source code and try ``flake8`` again.
@@ -60,18 +58,17 @@ ensure that everything passes and that code coverage has not declined.
6058

6159
.. code-block:: console
6260
63-
$ cd $HOME/projects/deis
64-
$ make coverage
65-
coverage run manage.py test api celerytasks client web
66-
Creating test database for alias 'default'...
67-
...................ss.
68-
----------------------------------------------------------------------
69-
Ran 22 tests in 22.630s
61+
$ make -C controller coverage
62+
coverage run manage.py test --noinput api cm provider web
63+
WARNING Cannot synchronize with etcd cluster
64+
Creating test database for alias 'default'...
65+
....................................................................
66+
----------------------------------------------------------------------
67+
Ran 68 tests in 84.856s
7068
71-
OK (skipped=2)
72-
Destroying test database for alias 'default'...
73-
coverage html
74-
$
69+
OK
70+
Destroying test database for alias 'default'...
71+
coverage html
7572
7673
If a test fails, fixing it is obviously the first priority. And if you
7774
have introduced new code, it must be accompanied by unit tests.
@@ -91,6 +88,7 @@ changes. Current test coverage can be found here:
9188

9289
Pull Request
9390
------------
91+
9492
Now create a GitHub `pull request`_ with a description of what your code
9593
fixes or improves.
9694

@@ -105,6 +103,7 @@ automatically close the `GitHub issue`_ when the pull request is merged.
105103

106104
Merge Approval
107105
--------------
106+
108107
Deis maintainers add "**LGTM**" (Looks Good To Me) in code
109108
review comments to indicate that a PR is acceptable. Any code change--other than
110109
a simple typo fix or one-line documentation change--requires at least two of
@@ -119,3 +118,181 @@ Deis' maintainers to accept the change in this manner before it can be merged.
119118
.. _`The Zen of Python`: http://www.python.org/dev/peps/pep-0020/
120119
.. _`pull request`: https://github.com/opdemand/deis/pulls
121120
.. _`GitHub issue`: https://github.com/opdemand/deis/issues
121+
122+
123+
.. _commit_style_guide:
124+
125+
Commit Style Guide
126+
------------------
127+
128+
There are several reasons why we try to follow a specific style guide for commits:
129+
130+
- it allows us to recognize unimportant commits like formatting
131+
- it provides better information when browsing the git history
132+
133+
Recognizing Unimportant Commits
134+
```````````````````````````````
135+
136+
These commits are usually just formatting changes like adding/removing spaces/empty lines,
137+
fixing indentation, or adding comments. So when you are looking for some change in the
138+
logic, you can ignore these commits - there's no logic change inside this commit.
139+
140+
When bisecting, you can ignore these by running:
141+
142+
.. code-block:: console
143+
144+
git bisect skip $(git rev-list --grep irrelevant <good place> HEAD)
145+
146+
Providing more Information when Browsing the History
147+
````````````````````````````````````````````````````
148+
149+
This adds extra context to our commit logs. Look at these messages (taken from the last
150+
few AngularJS commits):
151+
152+
- Fix small typo in docs widget (tutorial instructions)
153+
- Fix test for scenario.Application - should remove old iframe
154+
- docs - various doc fixes
155+
- docs - stripping extra new lines
156+
- Replaced double line break with single when text is fetched from Google
157+
- Added support for properties in documentation
158+
159+
All of these messages try to specify where the change occurs, but they don’t share any
160+
convention. Now look at these messages:
161+
162+
- fix comment stripping
163+
- fixing broken links
164+
- Bit of refactoring
165+
- Check whether links do exist and throw exception
166+
- Fix sitemap include (to work on case sensitive linux)
167+
168+
Are you able to guess what’s inside each commit diff?
169+
170+
It's true that you can find this information by checking which files had been changed, but
171+
that’s slow. When looking in the git history, we can see that all of the developers are
172+
trying to specify where the change takes place, but the message is missing a convention.
173+
Cue commit message formatting entrance stage left.
174+
175+
Format of the Commit Message
176+
````````````````````````````
177+
178+
.. code-block:: console
179+
180+
{type}({scope}): {subject}
181+
<BLANK LINE>
182+
{body}
183+
<BLANK LINE>
184+
{footer}
185+
186+
Any line of the commit message cannot be longer than 90 characters, with the subject
187+
line limited to 70 characters. This allows the message to be easier to read on github
188+
as well as in various git tools.
189+
190+
Subject Line
191+
""""""""""""
192+
193+
The subject line contains a succinct description of the change to the logic.
194+
195+
The allowed {types} are as follows:
196+
197+
- feat -> feature
198+
- fix -> bug fix
199+
- docs -> documentation
200+
- style -> formatting
201+
- refactor
202+
- test -> adding missing tests
203+
- chore -> maintenance
204+
205+
The {scope} can be anything specifying place of the commit change e.g. the controller,
206+
the client, the logger, etc.
207+
208+
The {subject} needs to use imperative, present tense: “change”, not “changed” nor
209+
“changes”. The first letter should not be capitalized, and there is no dot (.) at the end.
210+
211+
Message Body
212+
""""""""""""
213+
214+
Just like the {subject}, the message {body} needs to be in the present tense, and includes
215+
the motivation for the change, as well as a contrast with the previous behavior.
216+
217+
Message Footer
218+
""""""""""""""
219+
220+
All breaking changes need to be mentioned in the footer with the description of the
221+
change, the justification behind the change and any migration notes required. For example:
222+
223+
.. code-block:: console
224+
225+
BREAKING CHANGE: the controller no longer listens on port 80. It now listens on
226+
port 8000, with the router redirecting requests on port 80 to the controller. To
227+
migrate to this change, SSH into your controller and run:
228+
229+
$ docker kill deis-controller
230+
$ docker rm deis-controller
231+
232+
and then restart the controller on port 8000:
233+
234+
$ docker run -d -p 8000:8000 -e ETCD=<etcd_endpoint> -e HOST=<host_ip> \
235+
-e PORT=8000 -name deis-controller deis/controller
236+
237+
now you can start the proxy component by running:
238+
239+
$ docker run -d -p 80:80 -e ETCD=<etcd_endpoint> -e HOST=<host_ip> -e PORT=80 \
240+
-name deis-router deis/router
241+
242+
The router should then start proxying requests from port 80 to the controller.
243+
244+
Referencing Issues
245+
""""""""""""""""""
246+
247+
Closed bugs should be listed on a separate line in the footer prefixed with the "closes"
248+
keyword like this:
249+
250+
.. code-block::console
251+
252+
closes #123
253+
254+
Or in the case of multiple issues:
255+
256+
.. code-block::console
257+
258+
closes #123, #456, #789
259+
260+
Examples
261+
````````
262+
263+
.. code-block:: console
264+
265+
feat(controller): add router component
266+
267+
This introduces a new router component to Deis, which proxies requests to Deis
268+
components.
269+
270+
closes #123
271+
272+
BREAKING CHANGE: the controller no longer listens on port 80. It now listens on
273+
port 8000, with the router redirecting requests on port 80 to the controller. To
274+
migrate to this change, SSH into your controller and run:
275+
276+
$ docker kill deis-controller
277+
$ docker rm deis-controller
278+
279+
and then restart the controller on port 8000:
280+
281+
$ docker run -d -p 8000:8000 -e ETCD=<etcd_endpoint> -e HOST=<host_ip> \
282+
-e PORT=8000 -name deis-controller deis/controller
283+
284+
now you can start the proxy component by running:
285+
286+
$ docker run -d -p 80:80 -e ETCD=<etcd_endpoint> -e HOST=<host_ip> -e PORT=80 \
287+
-name deis-router deis/router
288+
289+
The router should then start proxying requests from port 80 to the controller.
290+
----------------------------------------------------------------------------------
291+
test(client): add unit tests for app domains
292+
293+
Nginx does not allow domain names larger than 128 characters, so we need to make
294+
sure that we do not allow the client to add domains larger than 128 characters.
295+
A DomainException is raised when the domain name is larger than the maximum
296+
character size.
297+
298+
closes #392

0 commit comments

Comments
 (0)