2021-09-13 20:17:02 +08:00
|
|
|
# Milvus Code Review Guide
|
|
|
|
|
|
|
|
All PRs are checked in automatically by the sre-robot, with the following condition:
|
|
|
|
|
|
|
|
1. DCO check passed
|
2021-09-29 19:09:00 +08:00
|
|
|
2. All test passed and code coverage check passed, with a `ci-passed` label
|
2021-10-17 16:46:34 +08:00
|
|
|
3. Reviewe passed, with a `lgtm` label
|
|
|
|
4. Approver passed, with a `approved` label
|
2021-09-13 20:17:02 +08:00
|
|
|
|
2021-09-22 20:15:55 +08:00
|
|
|
Generally speaking, reviewer is volunteered and can be anyone in the community who is familiar with the packages the PR modifies.
|
|
|
|
Reviewers are responsible for the logic correctness, error handling, unit test coverage and code readability.
|
2021-10-25 20:06:00 +08:00
|
|
|
While Approver focuses on overall design, code readability, and ensuring the PR follows code of
|
2021-09-22 20:15:55 +08:00
|
|
|
conduct(Such as meaningful title and commit message, marked with correct labels, meaningful comments). Currently,
|
|
|
|
all Approvers are listed under OWNERS_ALIASES file.
|
2021-09-13 20:17:02 +08:00
|
|
|
|
|
|
|
## Things to do before review
|
|
|
|
|
2021-10-17 16:46:34 +08:00
|
|
|
- Read the title, commit message and related issue of the PR, if it's not easy to understand, ask for improvement
|
2021-09-13 20:17:02 +08:00
|
|
|
|
2021-10-25 20:06:00 +08:00
|
|
|
- For a bug fix PR, there should be a detailed bug description in related issue, and make sure the test cases to cover this bug.
|
2021-09-13 20:17:02 +08:00
|
|
|
|
2021-10-17 16:46:34 +08:00
|
|
|
- For a function enhancement PR, understand the function use case, make sure the functionality is reasonable.
|
2021-09-13 20:17:02 +08:00
|
|
|
|
2021-10-17 16:46:34 +08:00
|
|
|
- For a performance PR, make sure benchmark result is listed in PR.
|
2021-09-13 20:17:02 +08:00
|
|
|
|
2021-10-17 16:46:34 +08:00
|
|
|
- Think deeply about why is the solution necessary, any workaround or substitutions?
|
2021-09-13 20:17:02 +08:00
|
|
|
|
|
|
|
## Things to check during the review
|
|
|
|
|
2021-10-17 16:46:34 +08:00
|
|
|
- Does the code follow style guide?
|
2021-09-13 20:17:02 +08:00
|
|
|
|
2021-10-25 20:06:00 +08:00
|
|
|
- Does the code do exactly the same as title and commit message describe?
|
2021-09-13 20:17:02 +08:00
|
|
|
|
2021-11-05 13:27:37 +08:00
|
|
|
- Can this function and variable's behavior be inferred by its name?
|
2021-09-13 20:17:02 +08:00
|
|
|
|
2021-10-17 16:46:34 +08:00
|
|
|
- Do unit tests cover all the important code branches?
|
2021-09-13 20:17:02 +08:00
|
|
|
|
2021-10-17 16:46:34 +08:00
|
|
|
- What about the edge cases and failure handling path?
|
2021-09-13 20:17:02 +08:00
|
|
|
|
2021-10-17 16:46:34 +08:00
|
|
|
- Do we need better layering and abstraction?
|
2021-09-13 20:17:02 +08:00
|
|
|
|
2021-10-17 16:46:34 +08:00
|
|
|
- Are there enough comments to understand the intent of the code?
|
2021-09-13 20:17:02 +08:00
|
|
|
|
2021-10-17 16:46:34 +08:00
|
|
|
- Are hacks, workarounds and temporary fixes commented?
|
2021-09-13 20:17:02 +08:00
|
|
|
|
|
|
|
## Things to keep in mind when you are writing a review comment
|
|
|
|
|
2021-10-17 16:46:34 +08:00
|
|
|
- Be kind to the coder, not to the code.
|
2021-09-13 20:17:02 +08:00
|
|
|
|
2021-10-17 16:46:34 +08:00
|
|
|
- Ask questions rather than make statements.
|
2021-09-13 20:17:02 +08:00
|
|
|
|
2021-10-17 16:46:34 +08:00
|
|
|
- Treat people who know less than you with respect, deference, and patience.
|
2021-09-13 20:17:02 +08:00
|
|
|
|
2021-10-17 16:46:34 +08:00
|
|
|
- Remember to praise when the code quality exceeds your expectation.
|
2021-09-13 20:17:02 +08:00
|
|
|
|
2021-10-17 16:46:34 +08:00
|
|
|
- It isn't necessarily wrong if the coder's solution is different than yours.
|
2021-09-13 20:17:02 +08:00
|
|
|
|
2021-10-17 16:46:34 +08:00
|
|
|
- Community is not only about the product, it is about person. Help others to improve whenever possible.
|
2021-09-13 20:17:02 +08:00
|
|
|
|
2021-10-17 16:46:34 +08:00
|
|
|
## For Approvers
|
2021-09-13 20:17:02 +08:00
|
|
|
|
|
|
|
Besides All the reviewer's responsibility listed above, Approvers should also maintain code of conduct.
|
|
|
|
|
2021-10-17 16:46:34 +08:00
|
|
|
- Be sure the pr has only one commit, author has to do a squash commit in local REPO
|
2021-09-13 20:17:02 +08:00
|
|
|
|
2021-10-17 16:46:34 +08:00
|
|
|
- Commit message starts with a capital letter and does not end with punctuation
|
2021-09-13 20:17:02 +08:00
|
|
|
|
2021-10-17 16:46:34 +08:00
|
|
|
- Commit message is clear and meaningful. You can only have title but no body if the title is self explained
|
2021-09-13 20:17:02 +08:00
|
|
|
|
2021-10-17 16:46:34 +08:00
|
|
|
- PR links to the correct issue, which clearly states the problems to be solved and the planned solution
|
2021-09-13 20:17:02 +08:00
|
|
|
|
2021-10-17 16:46:34 +08:00
|
|
|
- PR sets kind label
|
2021-09-13 20:17:02 +08:00
|
|
|
|
2021-10-25 20:06:00 +08:00
|
|
|
- The variable names appearing in the source code need to be readable. Comments are necessary if it is an unusual abbreviations
|
2021-09-13 20:17:02 +08:00
|
|
|
|
2021-10-08 17:26:54 +08:00
|
|
|
Thanks for [Code Review Guide](https://github.com/pingcap/tidb/blob/master/code_review_guide.md) from Pingcap community.
|