This document explains how to contribute code
- For code and comment, follow the Golang style guide.
- Provide unit test for all code
- Pass all unit test
- Follow our regulations of submitting codes
Below tutorial will guide you to submit code
-
Go to BFE Ingress Github, click
Fork
button to create a repository in your own GitHub space.https://github.com/${USERNAME}/ingress-bfe
-
Clone
Clone the repository in your own space to your local :
$ git clone https://github.com/${USERNAME}/ingress-bfe $ cd ingress-bfe
-
Create local branch
We currently use Git Branching Model to develop, test, release and maintenance, refer to Release Regulation。
- all development for feature and bug fix should be performed in a new branch
- create new branch from branch
develop
in most case
Use
git checkout -b
to create and switch to a new branch.$ git checkout -b my-cool-stuff
Before checkout, verify by
git status
command and keep current branch clean, otherwise untracked files will be brought to the new branch. -
Use pre-commit hook
We use pre-commit tool to manage Git pre-commit hook.
- run following command:
$ pip install pre-commit $ pre-commit install
- use
gofmt
to format code.
- run following command:
-
Use
license-eye
toollicense-eye helps us check and fix file's license header declaration. All files' license header should be done before committing.
The
license-eye
check is part of the Github-Action. A PR that check failed cannot be submitted to BFE. Installlicense-eye
and do check or fix:$ make license-eye-install $ make license-check $ make license-fix
-
Coding
-
Build and test
Compile source code, build BFE Ingress Controller docker and then test it. See more instruction in Deploy Guide
-
Commit
run
git commit
.Provides commit message for each commit, to let other people know what is changed in this commit.
git commit
.Notice:commit message is also required to trigger CI unit test,format as below:
# trigger CI unit test in develop branch $ git commit -m "test=develop" # trigger CI unit test in release/1.1 branch $ git commit -m "test=release/1.1"
-
Keep local repository up-to-date
An experienced Git user always pulls from the official repo before pushing. They even pull daily or hourly, so they notice conflicts earlier, and it's easier to resolve smaller conflicts.
git remote add upstream https://github.com/bfenetworks/ingress-bfe git fetch upstream git pull upstream develop
-
Push to remote repository
Push local to your repository on GitHub
https://github.com/${USERNAME}/ingress-bfe
# Example: push to remote repository `origin` branch `my-cool-stuff`
$ git push origin my-cool-stuff
Refer to BFE Local Develop Guide
- Create an Issue and finish Pull Request
- Pass unit test
- Delete the branch used at your own repository
- Delete the branch used at your local repository
Refer to BFE Submit PR Guide