diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 65268245b5..ea71a0380a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,16 +6,32 @@ The following are a set of guidelines for contributing to Milvus. Following thes As for everything else in the project, the contributions to Milvus are governed by our [Code of Conduct](CODE_OF_CONDUCT.md). +**Content** + +- [What contributions can I make?](#what-contributions-can-i-make?) +- [How can I contribute?](#how-can-i-contribute?) + - [Contributing code](#contributing-code) + - [GitHub workflow](#github-workflow) + - [General guidelines](#general-guidelines) + - [Developer Certificate of Origin](#developer-certificate-of-origin-dco) +- [Coding style](#coding-style) + - [Golang](#golang-coding-style) + - [C++](#c++-coding-style) +- [Run unit test with code coverage](#run-unit-test-with-code-coverage) + - [Golang](#golang) + - [C++](#c++) +- [Commits and PRs](#commits-and-prs) + ## What contributions can I make? | Suitable for | Projects | Resources | | ---------------------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | -| Go developers | [milvus](https://github.com/milvus-io/milvus), [milvus-sdk-go](https://github.com/milvus-io/milvus-sdk-go) | | -| CPP developers | [milvus](https://github.com/milvus-io/milvus) | | +| Go developers | [milvus](https://github.com/milvus-io/milvus), [milvus-sdk-go](https://github.com/milvus-io/milvus-sdk-go)|| +| CPP developers | [milvus](https://github.com/milvus-io/milvus) || | Developers interested in other languages | [pymilvus](https://github.com/milvus-io/pymilvus), [milvus-sdk-node](https://github.com/milvus-io/milvus-sdk-node), [milvus-sdk-java](https://github.com/milvus-io/milvus-sdk-java) | [Contributing to PyMilvus](https://github.com/milvus-io/pymilvus/blob/master/CONTRIBUTING.md) | -| Kubernetes enthusiasts | [milvus-helm](https://github.com/milvus-io/milvus-helm) | | +| Kubernetes enthusiasts | [milvus-helm](https://github.com/milvus-io/milvus-helm) || | Tech writers and docs enthusiasts | [milvus-docs](https://github.com/milvus-io/milvus-docs) | [Contributing to milvus docs](https://github.com/milvus-io/milvus-docs/blob/v2.0.0/CONTRIBUTING.md) | -| Web developers | [milvus-insight](https://github.com/milvus-io/milvus-insight) | | +| Web developers | [milvus-insight](https://github.com/milvus-io/milvus-insight)|| ## How can I contribute? ### Contributing code @@ -45,7 +61,7 @@ If you want to become a contributor of Milvus, send us your pull requests! For t 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](CODE_REVIEW.md) for details. -If everything is perfect, the reviewer will label `/lgtm`, and the approver will label `/approve`. +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 @@ -99,9 +115,10 @@ $ 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: +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 +### Golang coding style - Coding style: refer to the [Effictive Go Style Guide](https://golang.org/doc/effective_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: @@ -109,7 +126,12 @@ We also use `golangci-lint` to perform code check. Run the following command bef $ make static-check ``` -###C++ +To format code +```shell +$ make fmt +``` + +### C++ coding style The c++ coding style used in Milvus generally follow [Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html). And we made the following changes based on the guide: @@ -118,25 +140,16 @@ And we made the following changes based on the guide: - 120-character line length - Camel-Cased file names -### Commits and PRs -- Commit message and PR description style: refer to [good commit messages](https://chris.beams.io/posts/git-commit) - -### Format code -#### Go -```shell -$ make fmt -``` - -####C++ Install clang-format ```shell $ sudo apt-get install clang-format -$ rm cmake_build/CMakeCache.txt ``` + Check code style ```shell $ ./build.sh -l ``` + To format the code ```shell $ cd cmake_build @@ -146,17 +159,39 @@ $ 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 +### Golang + +You can run all the Golang unit tests using make. ```shell -$ go test -coverprofile fmtcoverage.html ./internal/allocator -ok github.com/milvus-io/milvus/internal/allocator 0.048s coverage: 69.6% of statements +$ make test-go ``` + +You can also run unit tests in package level. + +```shell +# run unit tests in datanode package +$ go test ./internal/datanode -cover +ok github.com/milvus-io/milvus/internal/datanode 3.874s coverage: 88.2% of statements +``` + +You can run a sub unit test. + +In this case, we only concern about the tests with name "SegmentReplica" and +sub tests with name "segmentFlushed". When running sub tests, the coverage is not concerned. +```shell +$ go test ./internale/datanode -run SegmentReplica/segmentFlushed +ok github.com/milvus-io/milvus/internal/datanode 0.019s +``` + ### C++ Install lcov ```shell $ sudo apt-get install lcov ``` Run unit test and generate code for code coverage check -```shell +```shell $ ./build.sh -u -c ``` + +## Commits and PRs +- Commit message and PR description style: refer to [good commit messages](https://chris.beams.io/posts/git-commit)