You have made some changes to CockroachDB and you want to submit it to the CockroachDB team for inclusion in the main release.

How does this work? In summary, we will look at the following:

Is this your first time submitting a PR? Check Your first CockroachDB PR!

Presence of unit tests

Every CockroachDB change that fixes a bug or changes functionality must be accompanied by testing code.

A unit test is good when:

  1. it would fail if ran on CockroachDB before your change,

  2. it succeeds when ran after the change,

  3. it does not test too many other things besides the area you're changing,

  4. it is fully automated.

If your change affects multiple areas, there should probably be a different unit test for each area (principle 3).

Currently in the CockroachDB project we use the following types of test:

Adherence to the coding style

During a review, some attention is given to the coding style.

  1. CockroachDB uses a couple extra formatting rules in addition to those used by gofmt. We provide the command crlfmt to enforce those automaticaly: Use:
    crlfmt -tab 2
    We advise to integrate this in your text editor.

  2. We value good naming for variables, functions for new concepts, etc. If your change extends an area where there is already an established naming pattern, you can reuse the existing pattern. If you are introducing new concepts, be creative! But during the review we might kindly request you to rename some of the entities.

Adequate in-line comments

We value in-line comments that clarify what is going on in the Go code.

  1. Good comments:

    1. are written in grammatical English, with full sentences (capital at beginning, period at end).

    2. do not repeat what the code does (i.e. do not write // This loop iterates from 1 to 10 in front of a for-loop), but instead clarifies the goal and/or the motivation (e.g. // This loop aggregates a result over all the instances).

  2. We value adequate (but not excessive) single empty lines to separate blocks of code that correspond to units of reasoning.

  3. In some cases we even value adding comments on code that you have not changed, but that was unclear to you (when the comments would add a future reader).

Explanatory commit message and release note annotation

Do not confuse the Git commit message and the PR description message!

As much as possible, put all the information about your change primarily in the git commit message, and merely maintain the PR description as a copy or a summary of the git commit message.

See the separate page on Git Commit Messages.

Impact on UX

If your change affects the experience of many CockroachDB users (i.e. it affects a common case), we will validate that it fits with the mission to "make data easy".

If there is potential UX impact, we kindly request that you approach us to discuss this impact prior to starting to program the change. Depending on that discussion, we might express additional requirement that can influence the approach you'll take.

Separating changes into multiple commits

Short, simple projects produce a PR containing a single, small commit. However, it is often the case that a PR grows to contain multiple commits.

This happens mainly in two situations:

See Organizing PRs and Commits for details.