(Update): Add the contribution guide for developer (#118)

Signed-off-by: chandan kumar <chandan.kr404@gmail.com>
This commit is contained in:
Chandan Kumar 2020-01-23 17:16:25 +05:30 committed by Karthik Satchitanand
parent c642df2ea9
commit 78a7d46e1e
5 changed files with 251 additions and 1 deletions

62
CONTRIBUTING.md Normal file
View File

@ -0,0 +1,62 @@
# Contributing to Litmus Chaos-Operator
Litmus is an Apache 2.0 Licensed project and uses the standard GitHub pull requests process to review and accept contributions.
There are several areas of Litmus that could use your help. For starters, you could help in improving the sections in this document by either creating a new issue describing the improvement or submitting a pull request to this repository.
* If you are a first-time contributor, please see [Steps to Contribute](#steps-to-contribute).
* If you would like to suggest new tests to be added to litmus, please go ahead and [create a new issue](https://github.com/litmuschaos/litmus/issues/new) describing your test. All you need to do is specify the workload type and the operations that you would like to perform on the workload.
* If you would like to work on something more involved, please connect with the Litmus Contributors.
* If you would like to make code contributions, all your commits should be signed with Developer Certificate of Origin. See [Sign your work](#sign-your-work).
## Steps to Contribute
* Find an issue to work on or create a new issue. The issues are maintained at [litmuschaos/litmus] (https://github.com/litmuschaos/litmus/issues). You can pick up from a list of [good-first-issues] (https://github.com/litmuschaos/litmus/labels/good%20first%20issue).
* Claim your issue by commenting your intent to work on it to avoid duplication of efforts.
* Fork the repository on GitHub.
* Create a branch from where you want to base your work (usually master).
* Make your changes.
* Relevant coding style guidelines are the [Go Code Review Comments](https://code.google.com/p/go-wiki/ wiki/CodeReviewComments) and the _Formatting and style_ section of Peter Bourgon's [Go: Best Practices for Production Environments](http://peter.bourgon.org/go-in-production/#formatting-and-style).
* Commit your changes by making sure the commit messages convey the need and notes about the commit.
* Push your changes to the branch in your fork of the repository.
* Submit a pull request to the original repository. See [Pull Request checklist](#pull-request-checklist)
## Pull Request Checklist
* Rebase to the current master branch before submitting your pull request.
* Commits should be as small as possible. Each commit should follow the checklist below:
- For code changes, add tests relevant to the fixed bug or new feature
- Pass the compile and tests - includes spell checks, formatting, etc
- Commit header (first line) should convey what changed
- Commit body should include details such as why the changes are required and how the proposed changes
- DCO Signed
* If your PR is not getting reviewed or you need a specific person to review it, please reach out to the Litmus contributors at the [Litmus slack channel](https://app.slack.com/client/T09NY5SBT/CNXNB0ZTN)
## Sign your work
We use the Developer Certificate of Origin (DCO) as an additional safeguard for the LitmusChaos project. This is a well established and widely used mechanism to assure that contributors have confirmed their right to license their contribution under the project's license. Please add a line to every git commit message:
```sh
Signed-off-by: Random J Developer <random@developer.example.org>
```
Use your real name (sorry, no pseudonyms or anonymous contributions). The email id should match the email id provided in your GitHub profile.
If you set your `user.name` and `user.email` in git config, you can sign your commit automatically with `git commit -s`.
You can also use git [aliases](https://git-scm.com/book/tr/v2/Git-Basics-Git-Aliases) like `git config --global alias.ci 'commit -s'`. Now you can commit with `git ci` and the commit will be signed.
## Setting up your Development Environment
This project is implemented using Go and uses the standard golang tools for development and build. In addition, this project heavily relies on Docker and Kubernetes. It is expected that the contributors:
- are familiar with working with Go;
- are familiar with Docker containers;
- are familiar with Kubernetes and have access to a Kubernetes cluster or Minikube to test the changes.
For setting up a Development environment on your local host, see the detailed instructions [here](./docs/developer.md).
## Community
The litmus community will have a weekly contributor sync-up on Tuesdays 16.00-16.30IST / 12.30-13.00CEST
- The sync up meeting is held online on [Google Hangouts](https://meet.google.com/uvt-ozaw-bvp)
- The release items are tracked in this [planning sheet](https://docs.google.com/spreadsheets/d/15svGB99bDcSTkwAYttH1QzP5WJSb-dFKbPzl-9WqmXM).

View File

@ -11,6 +11,9 @@ DOCKER_REPO ?= litmuschaos
DOCKER_IMAGE ?= chaos-operator
DOCKER_TAG ?= latest
.PHONY: all
all: deps format lint build test dockerops
.PHONY: help
help:
@echo ""
@ -29,7 +32,6 @@ godeps:
@echo "INFO:\tverifying dependencies for chaos exporter build ..."
@go get -u -v golang.org/x/lint/golint
@go get -u -v golang.org/x/tools/cmd/goimports
@go get -u -v github.com/golang/dep/cmd/dep
.PHONY: _build_check_docker
_build_check_docker:

View File

@ -176,3 +176,5 @@ They are available at [litmus docs](https://docs.litmuschaos.io)
The Chaos Operator is in _alpha_ stage and needs all the help you can provide! Please contribute by raising issues,
improving the documentation, contributing to the core framework and tooling, etc.
Head over to the [Contribution guide](CONTRIBUTING.md)

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

184
docs/developer.md Normal file
View File

@ -0,0 +1,184 @@
# Development Workflow
## Chaos-Operator Architecture
![Chaos-Operator Architecture](./docs/chaos-operator-architecture.png)
## Prerequisites
* You have Go 1.10+ installed on your local host/development machine.
* You have Docker installed on your local host/development machine. Docker is required for building chaos-operator component container images and to push them into a Kubernetes cluster for testing.
## Initial Setup
### Fork in the cloud
1. Visit https://github.com/litmuschaos/chaos-operator.
2. Click `Fork` button (top right) to establish a cloud-based fork.
### Clone fork to local host
Place `litmuschaos/chaos-operator` code on your `GOPATH` using the following cloning procedure.
Create your clone:
```sh
mkdir -p $GOPATH/src/github.com/litmuschaos
cd $GOPATH/src/github.com/litmuschaos
# Note: Here $user is your GitHub profile name
git clone https://github.com/$user/chaos-operator.git
# Configure remote upstream
cd $GOPATH/src/github.com/litmuschaos/chaos-operator
git remote add upstream https://github.com/litmuschaos/chaos-operator.git
# Never push to upstream master
git remote set-url --push upstream no_push
# Confirm that your remotes make sense
git remote -v
```
## Development
### Always sync your local repository
Open a terminal on your local host. Change directory to the chaos-operator fork root.
```sh
$ cd $GOPATH/src/github.com/litmuschaos/chaos-operator
```
Checkout the master branch.
```sh
$ git checkout master
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.
```
Recall that origin/master is a branch on your remote GitHub repository.
Make sure you have the upstream remote litmuschaos/chaos-operator by listing them.
```sh
$ git remote -v
origin https://github.com/$user/chaos-operator.git (fetch)
origin https://github.com/$user/chaos-operator.git (push)
upstream https://github.com/litmuschaos/chaos-operator.git (fetch)
upstream no_push (push)
```
If the upstream is missing, add it by using below command.
```sh
$ git remote add upstream https://github.com/litmuschaos/chaos-operator.git
```
Fetch all the changes from the upstream master branch.
```sh
$ git fetch upstream master
remote: Counting objects: 141, done.
remote: Compressing objects: 100% (29/29), done.
remote: Total 141 (delta 52), reused 46 (delta 46), pack-reused 66
Receiving objects: 100% (141/141), 112.43 KiB | 0 bytes/s, done.
Resolving deltas: 100% (79/79), done.
From github.com:litmuschaos/chaos-operator
* branch master -> FETCH_HEAD
```
Rebase your local master with the upstream/master.
```sh
$ git rebase upstream/master
First, rewinding head to replay your work on top of it...
Fast-forwarded master to upstream/master.
```
This command applies all the commits from the upstream master to your local master.
Check the status of your local branch.
```sh
$ git status
On branch master
Your branch is ahead of 'origin/master' by 38 commits.
(use "git push" to publish your local commits)
nothing to commit, working directory clean
```
Your local repository now has all the changes from the upstream remote. You need to push the changes to your own remote fork which is origin master.
Push the rebased master to origin master.
```sh
$ git push origin master
Username for 'https://github.com': $user
Password for 'https://$user@github.com':
Counting objects: 223, done.
Compressing objects: 100% (38/38), done.
Writing objects: 100% (69/69), 8.76 KiB | 0 bytes/s, done.
Total 69 (delta 53), reused 47 (delta 31)
To https://github.com/$user/chaos-operator.git
8e107a9..5035fa1 master -> master
```
### Create a new feature branch to work on your issue
Your branch name should have the format `XYZ-descriptive` where `XYZ` is the issue number you are working on followed by some descriptive text. For example:
```sh
$ git checkout -b 256-fix-reconsiler
Switched to a new branch '256-reconsiler'
```
### Make your changes and build them
```sh
cd $GOPATH/src/github.com/litmuschaos/chaos-operator
make all
```
Check your linting.
```sh
make lint
```
### Test your changes
- Replace the image with the builded image [here](../deploy/operator.yaml)
- Run the choos-operator in kubernetes cluster
```sh
cd $GOPATH/src/github.com/litmuschaos/chaos-operator
kubectl apply -f ./deploy/chaos_crds.yaml
kubectl apply -f ./deploy/rbac.yaml
kubectl apply -f ./deploy/operator.yaml
```
- Run the chaos by following the [Litmus Docs](https://docs.litmuschaos.io/docs/getstarted/#install-chaos-experiments)
- Verify the changes
### Keep your branch in sync
[Rebasing](https://git-scm.com/docs/git-rebase) is very important to keep your branch in sync with the changes being made by others and to avoid huge merge conflicts while raising your Pull Requests. You will always have to rebase before raising the PR.
```sh
git fetch upstream
git rebase upstream/master
```
While you rebase your changes, you must resolve any conflicts that might arise and build and test your changes using the above steps.
## Submission
### Create a pull request
Before you raise the Pull Requests, ensure you have reviewed the checklist in the [CONTRIBUTING GUIDE](../CONTRIBUTING.md):
- Ensure that you have re-based your changes with the upstream using the steps above.
- Ensure that you have added the required unit tests for the bug fixes or new feature that you have introduced.
- Ensure your commits history is clean with proper header and descriptions.
Go to the [litmuschaos/chaos-operator github](https://github.com/litmuschaos/chaos-operator) and follow the Open Pull Request link to raise your PR from your development branch.