Skip to content

Latest commit

 

History

History
355 lines (233 loc) · 17.8 KB

CONTRIBUTING.md

File metadata and controls

355 lines (233 loc) · 17.8 KB

Contributing to horizon

So, you want to hack on horizon? 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.

Requirements

Please meet the minimum version of the Go language published in go.mod.

You'd better use Linux OR WSL as the development environment, Linux with Makefile can help you quickly build and test horizon project.

If you are familiar with Makefile , you can easily see the clever design of the horizon 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.

Code of Conduct

Code and doc contribution

Every action to make project horizon better is encouraged. On GitHub, every improvement for horizon could be via a PR (short for pull request).

  • If you find a typo, try to fix it!
  • If you find a bug, try to fix it!
  • If you find some redundant codes, try to remove them!
  • If you find some test cases missing, try to add them!
  • If you could enhance a feature, please DO NOT hesitate!
  • If you find code implicit, try to add comments to make it clear!
  • If you find code ugly, try to refactor that!
  • If you can help to improve documents, it could not be better!
  • If you find document incorrect, just do it and fix that!
  • ...

Where should I start?

  • If you are new to the project, don't know how to contribute horizon, please check out the good first issue label.
  • You should be good at filtering the horizon issue tags and finding the ones you like, such as RFC for big initiatives, features for feature proposals, and bug fixes.
  • If you are looking for something to work on, check out our open issues.
  • If you have an idea for a new feature, please open an issue, and we can discuss it.

Design documents

Any substantial design deserves a design document. Design documents are written with Google Docs OR Notion、Even mark RFC in issues, discussions and should be shared with the community by adding the doc to our shared Drive and sending a note to the appropriate working group to let people know the doc is there.

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:

  1. Use the short-form RFC template to outline your ideas and get early feedback.
  2. Once you have received sufficient feedback and consensus, you may use the longer-form design doc template to specify and discuss your design in more details.

In order to contribute a feature to horizon you'll need to go through the following steps:

  • Discuss your idea with the appropriate working groups on the working group's Slack channel.
  • Once there is general agreement that the feature is useful, create a GitHub issue to track the discussion. The issue should include information about the requirements and use cases that it is trying to address.
  • Include a discussion of the proposed design and technical details of the implementation in the issue.

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.

Getting Started

To propose PR for the horizon item, we assume you have registered a GitHub ID. Then you could finish the preparation in the following steps:

  1. Fork the repository(horizon)

  2. CLONE your own repository to master locally. Use git clone https://github.com/<your-username>/horizon.git to clone repository to your local machine. Then you can create new branches to finish the change you wish to make.

  3. Set Remote upstream to be https://github.com/horizoncd/horizon.git using the following two commands:

    ❯ git remote add upstream https://github.com/horizoncd/horizon.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>/horizon.git (fetch)
    origin     https://github.com/<your-username>/horizon.git (push)
    upstream   https://github.com/horizoncd/horizon.git (fetch)
    upstream   no-pushing (push)

    Adding this, we can easily synchronize local branches with upstream branches.

  4. Create a new branch for your changes (use a descriptive name, such as fix-bug-123 or add-new-feature).

    cd horizon
    ❯ git fetch upstream
    ❯ git checkout upstream/main

    Create a new branch:

    ❯ git checkout -b <new-branch>

    Make any change on the new-branch then use Makefile build and test your codes.

  5. Commit your changes to your local branch, lint before committing and commit with sign-off

    ❯ git rebase upstream/main
    ❯ make link	  # 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
  6. 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 main
    ❯ 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># sync up with upstream
    ❯ git fetch upstream main
    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 -m -s "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 -m -s "feat: feature two"
    # then create pull request, and merge
  7. Open a pull request to horizoncd/horizon: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.

Style and Specification

We divide the problem into security and general problems:

Reporting security issues

Security issues are always treated seriously. As our usual principle, we discourage anyone to spread security issues. If you find a security issue of horizon, please do not discuss it in public and even do not open a public issue.

You can also message us on slack or chat with us on wechat.

Reporting general issues

To be honest, we regard every user of horizonas a very kind contributor. After experiencing horizon, you may have some feedback for the project. Then feel free to open an issue via NEW ISSUE.

Since we collaborate project horizon 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:

  • bug report
  • feature request
  • horizon performance issues
  • feature proposal
  • feature design
  • help wanted
  • doc incomplete
  • test improvement
  • any questions on horizon project
  • and so on

Also, we must be reminded when submitting a new question about horizon, 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.

Commit Rules

Actually in Horizon, 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.
  • other readable and explicit expression ways.

On the other side, we discourage contributors from committing message like the following ways:

  • fix bug
  • update
  • add doc

🥈 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:

  1. avoid very large change in a commit;
  2. complete and reviewable for each commit.

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 -m "docs: add a new section to the README"

PR Description

PR is the only way to make change to horizon 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:

  • As long as you are working on your PR, please mark it as a draft
  • Please make sure that your PR is up-to-date with the latest changes in main
  • Mention the issue that your PR is addressing (Fix: #{ID_1}, #{ID_2})
  • Make sure that your PR passes all checks

Reviewing PRs:

  • Be respectful and constructive
  • Assign yourself to the PR
  • Check if all checks are passing
  • Suggest changes instead of simply commenting on found issues
  • If you are unsure about something, ask the author
  • If you are not sure if the changes work, try them out
  • Reach out to other reviewers if you are unsure about something
  • If you are happy with the changes, approve the PR
  • Merge the PR once it has all approvals and the checks are passing

⚠️ DCO check:

We have a DCO check that runs on every pull request to ensure code quality and maintainability. This check verifies that the commit has been signed off, indicating that you have read and agreed to the provisions of the Developer Certificate of Origin. If you have not yet signed off on the commit, you can use the following command to sign off on the last commit you made:

❯ git commit --amend --signoff

Please note that signing off on a commit is a commitment that you have read and agreed to the provisions of the Developer Certificate of Origin. If you have not yet read this document, we strongly recommend that you take some time to read it carefully. If you have any questions about the content of this document, or if you need further assistance, please contact an administrator or relevant personnel.

You can also automate signing off your commits by adding the following to your .zshrc or .bashrc:

git() {
  if [ $# -gt 0 ] && [[ "$1" == "commit" ]] ; then
     shift
     command git commit --signoff "$@"
  else
     command git "$@"
  fi
}

CI actions

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

unit test runs all the test in code, and the code coverage should not less than 70 percent.

Try your best to keep every function has been tested, it keeps the function behaves as intended.

Docs Contribution

The documentation for horizon includes:

  • README.md
  • CONTRIBUTING.md
  • DEVELOPGUIDE.md
  • Official Documentation

Please obey the following rules to better format the docs, which would greatly improve the reading experience.

  1. Please do not use Chinese punctuations in English docs, and vice versa.
  2. Please use upper case letters where applicable, like the first letter of sentences / headings, etc.
  3. Please specify a language for each Markdown code blocks, unless there's no associated languages.
  4. Please insert a whitespace between Chinese and English words.
  5. Please use the correct case for technical terms, such as using HTTP instead of http, MySQL rather than mysql, Kubernetes instead of kubernetes, etc.
  6. Please check if there's any typos in the docs before submitting PRs.

Engage to help anything

We choose GitHub as the primary place for horizon to collaborate. So the latest updates of horizon are always here. Although contributions via PR is an explicit way to help, we still call for any other ways.

  • reply to other's issues if you could;
  • help solve other user's problems;
  • help review other's PR design;
  • discuss about horizon to make things clearer;
  • advocate horizon technology beyond GitHub;
  • write blogs on horizon and so on.

In a word, ANY HELP IS CONTRIBUTION.

Releasing

Releases of horizon are done using Release Please and GoReleaser. The workflow looks like this:

🎯 A PR is merged to the main branch:

  • Release please is triggered, creates or updates a new release PR
  • This is done with every merge to main, the current release PR is updated every time

🎯 Merging the 'release please' PR to main:

  • Release please is triggered, creates a new release and updates the changelog based on the commit messages
  • GoReleaser is triggered, builds the binaries and attaches them to the release
  • Containers are created and pushed to the container registry

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