So, you want to hack on OpenKF? Yay!
First of all, thank you for considering contributing to our project! We appreciate your time and effort, and we value any contribution, whether it's reporting a bug, suggesting a new feature, or submitting a pull request.
This document provides guidelines and best practices to help you contribute effectively.
We hope that anyone can join OpenKF , even if you are a student, writer, translator
Please meet the minimum version of the Go language published in go.mod. If you want to manage the Go language version, we provide tools to install gvm in our Makefile
You'd better use Linux as the development environment, Linux with Makefile can help you quickly build and test OpenKF project.
If you are familiar with Makefile , you can easily see the clever design of the OpenKF Makefile. Storing the necessary tools such as golangci in the /tools directory can avoid some tool version issues.
The Makefile is for every developer, even if you don't know how to use the Makefile tool, don't worry, we provide two great commands to get you up to speed with the Makefile architecture, make help and make help-all, it can reduce problems of the developing environment.
Every action to make project OpenKF better is encouraged. On GitHub, every improvement for OpenKF could be via a PR (short for pull request).
Getting good at GitHub is the first step, we have a list of labes and reading some of the common tags helps us get involved in the community quickly.GitHub allows you to filter out types of issues and pull requests, which helps you discover items in need of triaging. This table includes some predetermined searches for convenience:
| Search | What it sorts |
|---|---|
| created-asc | Untriaged issues by age |
| needs-triage | Issues that need to be assigned to a Labels |
is:open is:issue |
Newest incoming issues |
| comments-desc | Busiest untriaged issues, sorted by # of comments |
| comments-asc | Issues that need more attention, based on # of comments |
We suggest preparing your triage by filtering out the oldest, unlabelled issues and pull requests first.
Note
Reply to/assignor/assign @yourselfwith a question you wish to resolve, and we'll assign the question to you and your name will be listed underAssignees
For any substantial design, there should be a well-crafted design document. This document is not just a simple record, but also a detailed description and manifestation, which can help team members better understand the design thinking and grasp the design direction. In the process of writing the design document, we can choose to use tools such as Google Docs or Notion, and even mark RFC in issues or discussions for better collaboration. Of course, after completing the design document, we should also add it to our Shared Drive and notify the appropriate working group to let everyone know of its existence. Only by doing so can we maximize the effectiveness of the design document and provide strong support for the smooth progress of the project.
Anybody can access the shared Drive for reading. To get access to comment. Once you've done that, head to the shared Drive and behold all the docs.
In addition to that, we'd love to invite you to Join Our Slack where you can play with your imagination, tell us what you're working on, and get a quick response.
When documenting a new design, we recommend a 2-step approach:
In order to contribute a feature to OpenKF you'll need to go through the following steps:
But keep in mind that there is no guarantee of it being accepted and so it is usually best to get agreement on the idea/design before time is spent coding it. However, sometimes seeing the exact code change can help focus discussions, so the choice is up to you.
Note
A simple example allows you to quickly contribute your first PR to OpenKF.
To propose PR for the OpenKF item, we assume you have registered a GitHub ID. Then you could finish the preparation in the following steps:
Fork the repository(OpenKF)
CLONE your own repository to master locally. Use git clone https://github.com/<your-username>/OpenKF.git to clone repository to your local machine. Then you can create new branches to finish the change you wish to make.
Set Remote upstream to be https://github.com/openimsdk/openkf.git using the following two commands:
❯ git remote add upstream https://github.com/openimsdk/openkf.git
❯ git remote set-url --push upstream no-pushing
With this remote setting, you can check your git remote configuration like this:
❯ git remote -v
origin https://github.com/<your-username>/OpenKF.git (fetch)
origin https://github.com/<your-username>/OpenKF.git (push)
upstream https://github.com/openimsdk/openkf.git (fetch)
upstream no-pushing (push)
Adding this, we can easily synchronize local branches with upstream branches.
Create a new branch for your changes (use a descriptive name, such as fix/bug-123 or feature/add-new-xxx and release/xxx).
❯ cd OpenKF
❯ git fetch upstream
❯ git checkout -b fix/bug-<issue-id>
Note
Please don't use
git pullinstead of the abovefetchandrebase. Sincegit pullexecutes a merge, it creates merge commits. These make the commit history messy and violate the principle that commits ought to be individually understandable and useful.You might also consider changing your
.git/configfile viagit config branch.autoSetupRebase alwaysto change the behavior ofgit pull, or another non-merge option such asgit pull --rebase.
Create a new branch:
❯ git checkout -b <new-branch>
Make any change on the new-branch then use Makefile build and test your codes.
Commit your changes to your local branch, lint before committing and commit with sign-off
❯ git rebase upstream/main
❯ make lint # golangci-lint run -c .golangci.yml
❯ git add -A # add changes to staging
❯ git commit -a -s -m "fix: message for your changes" # -s adds a Signed-off-by trailer
Push your branch to your forked repository, it is recommended to have only one commit for a PR.
# sync up with upstream
❯ git fetch upstream
❯ git rebase upstream/main
❯ git rebase -i <commit-id> # rebase with interactive mode to `squash` your commits into a single one
❯ git push # push to the remote repository, if it's a first time push, run git push --set-upstream origin <new-branch>
You can also use git commit -s --amend && git push -f to update modifications on the previous commit.
If you have developed multiple features in the same branch, you should create PR separately by rebasing to the main branch between each push:
# create new branch, for example git checkout -b feature/infra
❯ git checkout -b <new branch>
# update some code, feature1
❯ git add -A
❯ git commit -s -m "feat: feature one"
❯ git push # if it's first time push, run git push --set-upstream origin <new-branch>
# then create pull request, and merge
# update some new feature, feature2, rebase main branch first.
❯ git rebase upstream/main # rebase the current branch to upstream/main branch
❯ git add -A
❯ git commit -s -m "feat: feature two"
# then create pull request, and merge
Open a pull request to OpenIMSDK/OpenKF:main
It is recommended to review your changes before filing a pull request. Check if your code doesn't conflict with the main branch and no redundant code is included.
We divide the problem into security and general problems:
Security issues are always treated seriously. As our usual principle, we discourage anyone to spread security issues. If you find a security issue of OpenKF, please do not discuss it in public and even do not open a public issue.
Instead we encourage you to send us a private email to {email} to report this.
To be honest, we regard every user of OpenKFas a very kind contributor. After experiencing OpenKF, you may have some feedback for the project. Then feel free to open an issue via NEW ISSUE.
Since we collaborate project OpenKF in a distributed way, we appreciate WELL-WRITTEN, DETAILED, EXPLICIT issue reports. To make the communication more efficient, we wish everyone could search if your issue is an existing one in the searching list. If you find it existing, please add your details in comments under the existing issue instead of opening a brand new one.
To make the issue details as standard as possible, we setup an ISSUE TEMPLATE for issue reporters. You can find three kinds of issue templates there: question, bug report and feature request. Please BE SURE to follow the instructions to fill fields in template.
There are a lot of cases when you could open an issue:
Also, we must be reminded when submitting a new question about OpenKF, please remember to remove the sensitive data from your post. Sensitive data could be password, secret key, network locations, private business data and so on.
Note
We have requirements for Commits, PR, Docs, and good standards help us collaborate better and understand what you're doing.
Actually in OpenKF, we take two rules serious when committing:
🥇 Commit Message:
Commit message could help reviewers better understand what the purpose of submitted PR is. It could help accelerate the code review procedure as well. We encourage contributors to use EXPLICIT commit message rather than ambiguous message. In general, we advocate the following commit message type:
We use Semantic Commits to make it easier to understand what a commit does and to build pretty changelogs. Please use the following prefixes for your commits:
docs: xxxx. For example, "docs: add docs about storage installation".feature: xxxx.For example, "feature: make result show in sorted order".bugfix: xxxx. For example, "bugfix: fix panic when input nil parameter".style: xxxx. For example, "style: format the code style of Constants.java".refactor: xxxx. For example, "refactor: simplify to make codes more readable".test: xxx. For example, "test: add unit test case for func InsertIntoArray".chore: xxx. For example, "chore: integrate travis-ci". It's the type of mantainance change.On the other side, we discourage contributors from committing message like the following ways:
🥈 Commit Content:
Commit content represents all content changes included in one commit. We had better include things in one single commit which could support reviewer's complete review without any other commits' help.
In another word, contents in one single commit can pass the CI to avoid code mess. In brief, there are two minor rules for us to keep in mind:
No matter what the commit message, or commit content is, we do take more emphasis on code review.
An example for this could be:
❯ git commit -a -s -m "docs: add a new section to the readme"
PR is the only way to make change to OpenKF project files. To help reviewers better get your purpose, PR description could not be too detailed. We encourage contributors to follow the PR template to finish the pull request.
You can find some very formal PR in RFC issues and learn about them.
📖 Opening PRs:
mainFixes: #{ID_1}, #{ID_2}🈴 Reviewing PRs:
⚠️ DCO check:
We have a DCO check which runs on every PR to verify that the commit has been signed off.
Once installed, this integration will set the status to failed if commits in a Pull Request do not contain a valid Signed-off-by line.
To sign off the last commit you made, you can use:
❯ git commit --amend --signoff
Contributors sign-off that they adhere to these requirements by adding a Signed-off-by line to commit messages.
Git even has a -s command line option to append this automatically to your commit message:
❯ git commit -s -m "docs: this is my commit message"
You can also automate signing off your commits by adding the following to your .zshrc or .bashrc:
❯ cat ~/.bashrc || cat ~/.zshrc
git() {
if [ $# -gt 0 ] && [[ "$1" == "commit" ]] ; then
shift
command git commit --signoff "$@"
else
command git "$@"
fi
}
We host CI on GitHub Actions, we will make sure PR pass tests before we can merge it.
These two kind of tests: lint and unit test
lint tests if your code matches our code conventions, please consult golangci-lint and lint config
Note
You can use the Makefile to run Lint with the command
make lint.
Note
We use the Makefile utility,
make teseto run the unit tests, and themake coverutility to check the unit test coverage.
Try your best to keep every function has been tested, it keeps the function behaves as intended.
The documentation for OpenKF includes:
Please obey the following rules to better format the docs, which would greatly improve the reading experience.
HTTP instead of http, MySQL rather than mysql, Kubernetes instead of kubernetes, etc.Markfile Lint:
We integrated in the CICD actions markdownlint, it detects Markfile specification.
Note
We recommend reading markdownlint rules, This document contains a description of all rules, what they are checking for, as well as an examples of documents that break the rule and corrected versions of the examples.
We choose GitHub as the primary place for OpenKF to collaborate. So the latest updates of OpenKF are always here. Although contributions via PR is an explicit way to help, we still call for any other ways.
In a word, ANY HELP IS CONTRIBUTION.
Releases of OpenKF are done using Release Please and GoReleaser. The workflow looks like this:
🎯 A PR is merged to the main branch:
🎯 Merging the 'release please' PR to main:
With the next relevant merge, a new release PR will be created and the process starts again
👀 Manually setting the version:
If you want to manually set the version, you can create a PR with an empty commit message that contains the version number in the commit message. For example:
Such a commit can get produced as follows:
❯ git commit --allow-empty -m "chore: release 0.0.3" -m "Release-As: 0.0.3
We value close connections with our users, developers, and contributors here at OpenKF. With a large community and maintainer team, we're always here to help and support you. Whether you're looking to join our community or have any questions or suggestions, we welcome you to get in touch with us.
Our most recommended way to get in touch is through Slack. Even if you're in China, Slack is usually not blocked by firewalls, making it an easy way to connect with us. Our Slack community is the ideal place to discuss and share ideas and suggestions with other users and developers of OpenKF. You can ask technical questions, seek help, or share your experiences with other users of OpenKF.
In addition to Slack, we also offer the following ways to get in touch:
Whether you're looking to join our community or have any questions or suggestions, we welcome you to get in touch with us.