github.com/muhammadn/cortex@v1.9.1-0.20220510110439-46bb7000d03d/docs/contributing/_index.md (about)

     1  ---
     2  title: Contributing
     3  linkTitle: "Contributing"
     4  weight: 10
     5  menu:
     6  ---
     7  
     8  Welcome! We're excited that you're interested in contributing. Below are some basic guidelines.
     9  
    10  ## Workflow
    11  
    12  Cortex follows a standard GitHub pull request workflow. If you're unfamiliar with this workflow, read the very helpful [Understanding the GitHub flow](https://guides.github.com/introduction/flow/) guide from GitHub.
    13  
    14  You are welcome to create draft PRs at any stage of readiness - this
    15  can be helpful to ask for assistance or to develop an idea. But before
    16  a piece of work is finished it should:
    17  
    18  * Be organised into one or more commits, each of which has a commit message that describes all changes made in that commit ('why' more than 'what' - we can read the diffs to see the code that changed).
    19  * Each commit should build towards the whole - don't leave in back-tracks and mistakes that you later corrected.
    20  * Have unit and/or [integration](./how-integration-tests-work.md) tests for new functionality or tests that would have caught the bug being fixed.
    21  * Include a CHANGELOG message if users of Cortex need to hear about what you did.
    22  * If you have made any changes to flags or config, run `make doc` and commit the changed files to update the config file documentation.
    23  
    24  ## Formatting
    25  
    26  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.
    27  
    28  You're using an IDE you may find useful the following settings for the Cortex project:
    29  
    30  - [VSCode](vscode-goimports-settings.json)
    31  
    32  
    33  ## Developer Certificates of Origin (DCOs)
    34  
    35  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:
    36  
    37  ```shell
    38  git commit -s -m "Here is my signed commit"
    39  ```
    40  
    41  You can find further instructions [here](https://github.com/probot/dco#how-it-works).
    42  
    43  ## Building Cortex
    44  
    45  To build:
    46  ```
    47  make
    48  ```
    49  
    50  (By default, the build runs in a Docker container, using an image built
    51  with all the tools required. The source code is mounted from where you
    52  run `make` into the build container as a Docker volume.)
    53  
    54  To run the unit tests suite:
    55  ```
    56  go test ./...
    57  ```
    58  
    59  To run the integration tests suite please see "[How integration tests work](./how-integration-tests-work.md)".
    60  
    61  ### Dependency management
    62  
    63  We uses [Go modules](https://golang.org/cmd/go/#hdr-Modules__module_versions__and_more) to manage dependencies on external packages.
    64  This requires a working Go environment with version 1.11 or greater, git and [bzr](http://wiki.bazaar.canonical.com/Download) installed.
    65  
    66  To add or update a new dependency, use the `go get` command:
    67  
    68  ```bash
    69  # Pick the latest tagged release.
    70  go get example.com/some/module/pkg
    71  
    72  # Pick a specific version.
    73  go get example.com/some/module/pkg@vX.Y.Z
    74  ```
    75  
    76  Tidy up the `go.mod` and `go.sum` files:
    77  
    78  ```bash
    79  go mod tidy
    80  go mod vendor
    81  git add go.mod go.sum vendor
    82  git commit
    83  ```
    84  
    85  You have to commit the changes to `go.mod` and `go.sum` before submitting the pull request.
    86  
    87  ## Design patterns and Code conventions
    88  
    89  Please see the dedicated "[Design patterns and Code conventions](design-patterns-and-conventions.md)" page.
    90  
    91  ## Documentation
    92  
    93  The Cortex documentation is compiled into a website published at [cortexmetrics.io](https://cortexmetrics.io/). Please see "[How to run the website locally](./how-to-run-website-locally.md)" for instructions.
    94  
    95  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.