[skip-ci]Update contributing.md (#8893)

Signed-off-by: yangxuan <xuan.yang@zilliz.com>
pull/8901/head
XuanYang-cn 2021-09-29 23:22:18 +08:00 committed by GitHub
parent 87b1d66d74
commit fc2dab174b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 58 additions and 23 deletions

View File

@ -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). 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? ## What contributions can I make?
| Suitable for | Projects | Resources | | Suitable for | Projects | Resources |
| ---------------------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | | ---------------------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| Go developers | [milvus](https://github.com/milvus-io/milvus), [milvus-sdk-go](https://github.com/milvus-io/milvus-sdk-go) | | | 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) | | | 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) | | 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) | | 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? ## How can I contribute?
### Contributing code ### 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. 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. 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 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 ### GitHub workflow
@ -99,9 +115,10 @@ $ git commit -s -m 'This is my commit message'
## Coding Style ## 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) - 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: 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 $ 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). 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: 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 - 120-character line length
- Camel-Cased file names - 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 Install clang-format
```shell ```shell
$ sudo apt-get install clang-format $ sudo apt-get install clang-format
$ rm cmake_build/CMakeCache.txt
``` ```
Check code style Check code style
```shell ```shell
$ ./build.sh -l $ ./build.sh -l
``` ```
To format the code To format the code
```shell ```shell
$ cd cmake_build $ cd cmake_build
@ -146,17 +159,39 @@ $ make clang-format
## Run unit test with code coverage ## 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%. 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 ```shell
$ go test -coverprofile fmtcoverage.html ./internal/allocator $ make test-go
ok github.com/milvus-io/milvus/internal/allocator 0.048s coverage: 69.6% of statements
``` ```
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++ ### C++
Install lcov Install lcov
```shell ```shell
$ sudo apt-get install lcov $ sudo apt-get install lcov
``` ```
Run unit test and generate code for code coverage check Run unit test and generate code for code coverage check
```shell ```shell
$ ./build.sh -u -c $ ./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)