Permalink
Newer
Older
100644 89 lines (65 sloc) 4.49 KB
1
# Contributing to Cockroach
2
3
### Getting and building
4
6
* A working C++ compiler (on mac os x something like `xcode-select
7
--install` will get you started). The compiler must support C++11
8
(GCC 4.9+ and clang 3.6+ are known to work).
9
* [Go environment](http://golang.org/doc/code.html). Currently a
10
64-bit version of go 1.5 is required.
11
* Git 1.8+ and Mercurial (for retrieving dependencies).
12
13
If you're on Mac OS X, [homebrew](http://brew.sh/) can be very helpful to fulfill these dependencies.
14
15
You can `go get -d github.com/cockroachdb/cockroach` or, alternatively,
17
```bash
Andrew Bonventre
Sep 7, 2014
18
mkdir -p $GOPATH/src/github.com/cockroachdb/
19
cd $GOPATH/src/github.com/cockroachdb/
20
git clone git@github.com:cockroachdb/cockroach.git
21
cd cockroach
22
```
23
24
Now you should be all set for `make build`, `make test` and everything else our Makefile has to
25
offer. Note that the first time you run `make` various dependent libraries and tools will be
26
downloaded and installed which can be somewhat time consuming. Be patient.
28
Note that if you edit a `.proto` or `.ts` file, you will need to manually regenerate the associated `.pb.{go,cc,h}` or `.js` files using `go generate ./...`.
29
`go generate` requires a collection of node modules which are installed via npm. If you don't have npm, it typically comes with node. To get it via homebrew:
30
`brew install node`
31
If you're not using homebrew, make sure you install both [node.js](https://nodejs.org/) and [npm](https://www.npmjs.com/).
Sep 28, 2015
32
If you plan on working on the UI, check out [the ui readme](ui).
34
To add or update a go dependency:
Jun 28, 2015
35
- `(cd $GOPATH/src && go get -u ./...)` to update the dependencies or `go get {package}` to add a dependency
36
- `glock save github.com/cockroachdb/cockroach` to update the GLOCKFILE
37
- `go generate ./...` to update generated files
38
- create a PR with all the changes
40
### Style guide
41
We're following the [Google Go Code Review](https://code.google.com/p/go-wiki/wiki/CodeReviewComments) fairly closely. In particular, you want to watch out for proper punctuation and capitalization and make sure that your lines stay well below 80 characters.
42
Andrew Bonventre
Sep 7, 2014
43
### Code review workflow
45
+ All contributors need to sign the
Jul 21, 2015
46
[Contributor License Agreement](https://cla-assistant.io/cockroachdb/cockroach).
Sep 10, 2014
48
+ Create a local feature branch to do work on, ideally on one thing at a time.
49
If you are working on your own fork, see
50
[this tip](http://blog.campoy.cat/2014/03/github-and-go-forking-pull-requests-and.html)
51
on forking in Go, which ensures that Go import paths will be correct.
53
`git checkout -b update-readme`
54
55
+ Hack away and commit your changes locally using `git add` and `git commit`. Remember to write tests! The following are helpful for running specific subsets of tests:
56
```
57
make test
58
# Run all tests in ./storage
59
make test PKG=./storage
60
# Run all kv tests matching `^TestFoo` with a timeout of 10s
61
make test PKG=./kv TESTS='^TestFoo' TESTTIMEOUT=10s
62
```
63
64
When you're ready to commit, do just that with a succinct title and informative
65
message. For example,
66
67
```bash
68
$ git commit
69
> 'update CONTRIBUTING.md
70
>
71
> Added details on running specific tests via `make`, and
72
> the CircleCI-equivalent test suite.
73
>
74
> Fixed some formatting.'
75
```
77
+ Run the whole CI test suite locally: `./build/circle-local.sh`. This requires the Docker setup; if you don't have/want that, `go generate ./... && make check test testrace` is a good first approximation.
78
79
+ When you’re ready for review, groom your work: each commit should pass tests and contain a substantial (but not overwhelming) unit of work. You may also want to `git fetch origin` and run `git rebase -i --exec "make check test" origin/master` to make sure you're submitting your changes on top of the newest version of our code. Next, push to your fork:
80
81
`git push -u <yourfork> update-readme`
Sep 10, 2014
82
83
+ Then [create a pull request using GitHub’s UI](https://help.github.com/articles/creating-a-pull-request).
Sep 10, 2014
84
85
+ If you get a test failure in CircleCI, check the Test Failure tab to see why the test failed. When the failure is logged in `excerpt.txt`, you can find the file from the Artifacts tab and see log messages. (You need to sign in to see the Artifacts tab.)
Sep 10, 2014
86
87
+ Address feedback in new commits. Wait (or ask) for new feedback on those commits if they are not straightforward. An `LGTM` ("looks good to me") by someone qualified is usually posted when you're free to go ahead and merge. Most new contributors aren't allowed to merge themselves; in that case, we'll do it for you. You may also be asked to re-groom your commits.
Sep 10, 2014
88