github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/CONTRIBUTING.md (about)

     1  # How to contribute
     2  
     3  This document outlines some of the conventions on development workflow, commit
     4  message formatting, contact points and other resources to make it easier to get
     5  your contribution accepted.
     6  
     7  ## Get started
     8  
     9  - Fork the repository on GitHub.
    10  - Read the README.md for build instructions.
    11  - Play with the project, submit bugs, submit patches!
    12  
    13  ## Build TiDB-CDC
    14  
    15  Developing TiDB-CDC requires:
    16  
    17  * [Go 1.21+](https://go.dev/doc/code)
    18  * An internet connection to download the dependencies
    19  
    20  Simply run `make` to build the program.
    21  
    22  ```sh
    23  make
    24  ```
    25  
    26  ### Run tests
    27  
    28  This project contains unit tests and integration tests with coverage collection.
    29  See [tests/integration_tests/README.md](./tests/integration_tests/README.md) for how to execute and add tests.
    30  
    31  For more information on how to trigger these tests, please see the [command help](./docs/ci/command.md).
    32  
    33  ### Debug with [Delve](https://github.com/go-delve/delve)
    34  
    35  ```shell
    36  dlv debug --build-flags="-ldflags='-X github.com/pingcap/tiflow/pkg/version.ReleaseVersion=$(git describe --tags)'" ./cmd/cdc -- server
    37  ```
    38  
    39  ### Update dependencies
    40  
    41  TiDB-CDC uses [Go Modules](https://github.com/golang/go/wiki/Modules) to manage dependencies. To add or update a dependency: use the `go mod edit` command to change the dependency.
    42  
    43  ## Contribution flow
    44  
    45  This is a rough outline of what a contributor's workflow looks like:
    46  
    47  - Create a topic branch from where you want to base your work. This is usually `master`.
    48  - Make commits of logical units and add test case if the change fixes a bug or adds new functionality.
    49  - Run tests and make sure all the tests are passed.
    50  - Make sure your commit messages are in the proper format (see below).
    51  - Push your changes to a topic branch in your fork of the repository.
    52  - Submit a pull request.
    53  - Your PR must receive LGTMs from two maintainers.
    54  
    55  Thanks for your contributions!
    56  
    57  ### Code style
    58  
    59  The coding style suggested by the Golang community is used in TiDB-CDC. See the [style doc](https://github.com/golang/go/wiki/CodeReviewComments) for details.
    60  
    61  Please follow this style to make TiDB-CDC easy to review, maintain and develop.
    62  
    63  ### Commit message format
    64  
    65  We follow a rough convention for commit messages that is designed to answer two
    66  questions: what changed and why. The subject line should feature the what and
    67  the body of the commit should describe the why.
    68  
    69  ```
    70  capture(ticdc): add comment for variable declaration
    71  
    72  Improve documentation.
    73  ```
    74  
    75  The format can be described more formally as follows:
    76  
    77  ```
    78  <subsystem>(ticdc|dm|engine|all): <what changed>
    79  <BLANK LINE>
    80  <why this change was made>
    81  <BLANK LINE>
    82  <footer>(optional)
    83  ```
    84  
    85  The first line is the subject and should be no longer than 70 characters, the second line is always blank, and other lines should be wrapped at 80 characters. This allows the message to be easier to read on GitHub as well as in various git tools.
    86  
    87  - If the change affects more than one subsystem, use a comma to separate them like ```capture,puller:```.
    88  - If the change affects many subsystems, use ```*``` instead, like ```*:```.
    89  - If the change affects only TiCDC, use ```<subsystem>(ticdc):```.
    90  - If the change affects only DM, use ```<subsystem>(dm):```.
    91  - If the change affects only the dataflow engine, use ```<subsystem>(engine):```.
    92  - If the change involves code that is used by all products, use ```<subsystem>(all):```.
    93  
    94  For the why part, if no specific reason for the change, you can use one of some generic reasons like "Improve documentation.", "Improve performance.", "Improve robustness.", "Improve test coverage."