Welcome! We’re excited that you’re interested in contributing. Below are some basic guidelines.
Cortex follows a standard GitHub pull request workflow. If you’re unfamiliar with this workflow, read the very helpful Understanding the GitHub flow guide from GitHub.
You are welcome to create draft PRs at any stage of readiness - this can be helpful to ask for assistance or to develop an idea. But before a piece of work is finished it should:
make docand commit the changed files to update the config file documentation.
Cortex projects uses
goimports tool (
go get golang.org/x/tools/cmd/goimports to install) to format the Go files, and sort imports. We use goimports with
-local github.com/cortexproject/cortex parameter, to put Cortex internal imports into a separate group. We try to keep imports sorted into three groups: imports from standard library, imports of 3rd party packages and internal Cortex imports. Goimports will fix the order, but will keep existing newlines between imports in the groups. We try to avoid extra newlines like that.
You’re using an IDE you may find useful the following settings for the Cortex project:
Before submitting your work in a pull request, make sure that all commits are signed off with a Developer Certificate of Origin (DCO). Here’s an example:
git commit -s -m "Here is my signed commit"
You can find further instructions here.
(By default, the build runs in a Docker container, using an image built
with all the tools required. The source code is mounted from where you
make into the build container as a Docker volume.)
To run the unit tests suite:
go test ./...
To run the integration tests suite please see “How integration tests work”.
To add or update a new dependency, use the
go get command:
# Pick the latest tagged release. go get example.com/some/module/pkg # Pick a specific version. go get example.com/some/module/[email protected]
Tidy up the
go mod tidy go mod vendor git add go.mod go.sum vendor git commit
You have to commit the changes to
go.sum before submitting the pull request.
Please see the dedicated “Design patterns and Code conventions” page.
Note: if you attempt to view pages on Github, it’s likely that you might find broken links or pages. That is expected and should not be addressed unless it is causing issues with the site that occur as part of the build.