Permalink
Newer
Older
100644 172 lines (134 sloc) 7.17 KB
1
# Contributing to Cockroach
2
3
## Getting and Building
5
1. Install the following prerequisites, as necessary:
6
- A C++ compiler that supports C++11. Note that GCC prior to 6.0 doesn't
7
work due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48891
8
- A Go environment with a recent 64-bit version of the toolchain. Note that
9
the Makefile enforces the specific version required, as it is updated
10
frequently.
11
- Git 1.8+
12
- Bash (4+ is preferred)
13
- GNU Make (3.81+ is known to work)
14
- CMake 3.1+
15
- Autoconf 2.68+
16
- Optional: NodeJS 6.x and Yarn 0.22.0+. Required when compiling protocol
17
buffers.
19
Note that at least 4GB of RAM is required to build from source and run tests.
21
2. Get the CockroachDB code:
23
```shell
24
go get -d github.com/cockroachdb/cockroach
25
cd $GOPATH/src/github.com/cockroachdb/cockroach
26
```
28
3. Run `make build`, `make test`, or anything else our Makefile offers. Note
29
that the first time you run `make`, it can take some time to download and
30
install various dependencies. After running `make build`, the `cockroach`
31
executable will be in your current directory and can be run as shown in the
32
[README](README.md).
34
### Other Considerations
36
- The default binary contains core open-source functionally covered by the
37
Apache License 2 (APL2) and enterprise functionality covered by the
38
CockroachDB Community License (CCL). To build a pure open-source (APL2)
39
version excluding enterprise functionality, use `make buildoss`. See this
40
[blog post] for more details.
41
42
[blog post]: https://www.cockroachlabs.com/blog/how-were-building-a-business-to-last/
44
- If you edit a `.proto` or `.ts` file, you will need to manually regenerate
45
the associated `.pb.{go,cc,h}` or `.js` files using `make generate`.
47
- We advise to run `make generate` using our embedded Docker setup.
48
`build/builder.sh` is a wrapper script designed to make this convenient. You
49
can run `build/builder.sh make generate` from the repository root to get the
50
intended result.
52
- If you plan on working on the UI, check out [the UI README](pkg/ui).
54
- To add or update a Go dependency:
55
- See [`build/README.md`](build/README.md) for details on adding or updating
56
dependencies.
57
- Run `make generate` to update generated files.
58
- Create a PR with all the changes.
62
[Style Guide](STYLE.md)
64
## Code Review Workflow
66
+ All contributors need to sign the [Contributor License Agreement](https://cla-assistant.io/cockroachdb/cockroach).
68
+ Create a local feature branch to do work on, ideally on one thing at a time.
69
If you are working on your own fork, see [this tip](http://blog.campoy.cat/2014/03/github-and-go-forking-pull-requests-and.html)
70
on forking in Go, which ensures that Go import paths will be correct.
72
`git checkout -b update-readme`
73
74
+ Hack away and commit your changes locally using `git add` and `git commit`.
75
Remember to write tests! The following are helpful for running specific
76
subsets of tests:
78
```shell
79
make test
80
# Run all tests in ./pkg/storage
81
make test PKG=./pkg/storage
82
# Run all kv tests matching '^TestFoo' with a timeout of 10s
83
make test PKG=./pkg/kv TESTS='^TestFoo' TESTTIMEOUT=10s
84
# Run the sql logic tests
85
make test PKG=./pkg/sql TESTS='TestLogic$$'
86
# or, using a shortcut,
87
make testlogic
88
# Run a specific sql logic subtest
89
make test PKG=./pkg/sql TESTS='TestLogic$$/select$$'
90
# or, using a shortcut,
91
make testlogic FILES=select
92
```
93
94
Logs are disabled during tests by default. To enable them, include
95
`TESTFLAGS="-v -show-logs"` as an argument the test command:
96
97
```shell
98
make test ... TESTFLAGS="-v -show-logs"
99
```
100
101
When you're ready to commit, be sure to write a Good Commit Message™. Consult
102
https://github.com/erlang/otp/wiki/Writing-good-commit-messages if you're
103
not sure what constitutes a Good Commit Message™.
104
In addition to the general rules referenced above, please also prefix your
105
commit subject line with the affected package, if one can easily be chosen.
106
For example, the subject line of a commit mostly affecting the
107
`server/serverpb` package might read: "server/serverpb: made great again".
108
Commits which affect many packages as a result of a shared dependency change
109
should probably begin their subjects with the name of the shared dependency.
110
Finally, some commits may need to affect many packages in a way which does
111
not point to a specific package; those commits may begin with "*:" or "all:"
112
to indicate their reach.
114
+ Run the linters, code generators, and unit test suites locally:
116
```
117
make pre-push
118
````
119
120
This will take several minutes.
121
122
+ When you’re ready for review, groom your work: each commit should pass tests
123
and contain a substantial (but not overwhelming) unit of work. You may also
124
want to `git fetch origin` and run
125
`git rebase -i --exec "make lint test" origin/master` to make sure you're
126
submitting your changes on top of the newest version of our code. Next, push
127
to your fork:
128
129
`git push -u <yourfork> update-readme`
Sep 10, 2014
130
131
+ Then [create a pull request using GitHub’s UI](https://help.github.com/articles/creating-a-pull-request). If you know of
132
another GitHub user particularly suited to reviewing your pull request, be
133
sure to mention them in the pull request body. If you possess the necessary
134
GitHub privileges, please also [assign them to the pull request using
135
GitHub's UI](https://help.github.com/articles/assigning-issues-and-pull-requests-to-other-github-users/).
136
This will help focus and expedite the code review process.
Sep 10, 2014
137
138
+ Address test failures and feedback by amending your commits. If your change
139
contains multiple commits, address each piece of feedback by amending that
140
commit to which the particular feedback is aimed. Wait (or ask) for new
141
feedback on those commits if they are not straightforward. An `LGTM` ("looks
142
good to me") by someone qualified is usually posted when you're free to go
143
ahead and merge. Most new contributors aren't allowed to merge themselves;
144
in that case, we'll do it for you.
Oct 28, 2015
145
Oct 28, 2015
147
148
Peeking into a running cluster can be done in several ways:
149
150
* the [net/trace](https://godoc.org/golang.org/x/net/trace) endpoint at
151
`/debug/requests`. It has a breakdown of the recent traced requests, in
152
particularly slow ones. Two families are traced: `node` and `coord`, the
153
former (and likely more interesting one) containing what happens inside of
154
`Node`/`Store`/`Replica` and the other inside of the coordinator
155
(`TxnCoordSender`).
156
* [pprof](https://golang.org/pkg/net/http/pprof/) gives us (among other things)
157
heap and cpu profiles; [this golang blog post](http://blog.golang.org/profiling-go-programs) explains it extremely well and
158
[this one by Dmitry Vuykov](https://software.intel.com/en-us/blogs/2014/05/10/debugging-performance-issues-in-go-programs)
159
goes into even more detail.
Oct 28, 2015
160
161
An easy way to locally run a workload against a cluster are the acceptance
162
tests. For example,
Oct 28, 2015
163
164
```shell
Oct 28, 2015
165
make acceptance TESTS='TestPut$$' TESTFLAGS='-v -d 1200s -l .' TESTTIMEOUT=1210s
166
```
167
168
runs the `Put` acceptance test for 20 minutes with logging (useful to look at
169
the stack trace in case of a node dying). When it starts, all the relevant
170
commands for `pprof`, `trace` and logs are logged to allow for convenient
171
inspection of the cluster.