milvus/CONTRIBUTING.md
XuanYang-cn 6bbae85674
[skip-ci]Fix typo (#8334)
Signed-off-by: yangxuan <xuan.yang@zilliz.com>
2021-09-22 19:52:00 +08:00

8.9 KiB

Contributing to Milvus

Contributions to Milvus are welcome from everyone. We strive to make the contribution process simple and straightforward. Up-to-date information can be found at milvus.io.

The following are a set of guidelines for contributing to Milvus. Following these guidelines makes contributing to this project easy and transparent. These are mostly guidelines, not rules. Use your best judgment, and feel free to propose changes to this document in a pull request.

As for everything else in the project, the contributions to Milvus are governed by our Code of Conduct.

What contributions can I make?

Suitable for Projects Resources
Go developers milvus, milvus-sdk-go
CPP developers milvus
Developers interested in other languages pymilvus, milvus-sdk-node, milvus-sdk-java Contributing to PyMilvus
Kubernetes enthusiasts milvus-helm
Tech writers and docs enthusiasts milvus-docs Contributing to milvus docs
Web developers milvus-insight

How can I contribute?

Contributing code

If you encountered a bug, you can

  • (Recommended) File an issue about the bug.
  • (Optional) Provide clear and concrete ways/scripts to reproduce the bug.
  • (Optional) Provide possible solutions for the bug.
  • (Optional) Pull a request to fix the bug.

If you're interested in existing issues, you can

  • (Recommended) Provide answers for issue labeled question.
  • Provide help for issues labeled bug, improvement, and enhancement by
    • (Recommended) Asking questions, reproducing the issue, or providing solutions.
    • Pulling a request to fix the issue.

If you require new feature or major enhancement, you can

  • (Recommended) File an issue about the feature/enhancement with reasons.
  • (Optional) Provide a MEP for the feature/enhancement.
  • (Optional) Pull a request to implement the MEP.

If you are a reviewer/approver of Milvus, you can

  • Participate in PR review process.
  • Instruct newcomers in the community to complete the PR process.

If you want to become a contributor of Milvus, send us your pull requests! For those just getting started, see GitHub workflow below.

All submissions will be reviewed as quickly as possible. There will be a reviewer to review the codes, and an approver to review everything aside the codes, see code review for details. If everything is perfect, the reviewer will label /lgtm, and the approver will label /approve. Once the 2 labels are on your PR, and all actions pass, your PR will be merged into base branch automaticaly by our @sre-ci-robot

GitHub workflow

Generally, we follow the "fork-and-pull" Git workflow.

  1. Fork the repository on GitHub.
  2. Clone your fork to your local machine with git clone git@github.com:<yourname>/milvus.git.
  3. Create a branch with git checkout -b my-topic-branch.
  4. Commit changes to your own branch, then push to to GitHub with git push origin my-topic-branch.
  5. Submit a pull request so that we can review your changes.

Remember to sync your forked repository before submitting proposed changes upstream. If you have an existing local repository, please update it before you start, to minimize the chance of merge conflicts.

git remote add upstream git@github.com:milvus-io/milvus.git
git fetch upstream
git checkout upstream/master -b my-topic-branch

General guidelines

Before submitting your pull requests for review, make sure that your changes are consistent with the coding style, and run unit tests to check your code coverage rate.

  • Include unit tests when you contribute new features, as they help to prove that your code works correctly, and also guard against future breaking changes to lower the maintenance cost.
  • Bug fixes also require unit tests, because the presence of bugs usually indicates insufficient test coverage.
  • Keep API compatibility in mind when you change code in Milvus. Reviewers of your pull request will comment on any API compatibility issues.
  • When you contribute a new feature to Milvus, the maintenance burden is (by default) transferred to the Milvus team. This means that the benefit of the contribution must be compared against the cost of maintaining the feature.

Developer Certificate of Origin (DCO)

All contributions to this project must be accompanied by acknowledgment of, and agreement to, the Developer Certificate of Origin. Acknowledgment of and agreement to the Developer Certificate of Origin must be included in the comment section of each contribution and must take the form of Signed-off-by: {{Full Name}} <{{email address}}> (without the {}). Contributions without this acknowledgment will be required to add it before being accepted. If contributors are unable or unwilling to agree to the Developer Certificate of Origin, their contribution will not be included.

Contributors sign-off that they adhere to DCO by adding the following Signed-off-by line to commit messages:

This is my commit message

Signed-off-by: Random J Developer <random@developer.example.org>

Git also has a -s command line option to append this automatically to your commit message:

$ git commit -s -m 'This is my commit message'

Coding Style

Keeping a consistent style for code, code comments, commit messages, and PR descriptions will greatly accelerate your PR review process. We highly recommend you refer to and comply to the following style guides when you put together your pull requests:

Go

We also use golangci-lint to perform code check. Run the following command before submit your pull request and make sure there is no issue reported:

$ make static-check

###C++ The c++ coding style used in Milvus generally follow Google C++ Style Guide. And we made the following changes based on the guide:

  • 4 spaces for indentation
  • Adopt .cpp file extension instead of .cc extension
  • 120-character line length
  • Camel-Cased file names

Commits and PRs

Format code

Go

$ make fmt

####C++ Install clang-format

$ sudo apt-get install clang-format
$ rm cmake_build/CMakeCache.txt

Check code style

$ ./build.sh -l

To format the code

$ cd cmake_build
$ make clang-format

Run unit test with code coverage

Before submitting your Pull Request, make sure you have run unit test, and your code coverage rate is >= 90%.

Go

$ go test -coverprofile fmtcoverage.html  ./internal/allocator
ok  	github.com/milvus-io/milvus/internal/allocator 0.048s	coverage: 69.6% of statements

C++

Install lcov

$ sudo apt-get install lcov

Run unit test and generate code for code coverage check

$ ./build.sh -u -c