Thanks for your interest in improving the project! This document provides a step-by-step guide for general contributions to Chaos Mesh.
Before starting work on something major, please reach out to us via GitHub, Slack, email, etc. We will make sure no one else is already working on it and ask you to open a GitHub issue. Also, we will provide necessary guidance should you need it.
Specifically, if you want to develop a specific chaos type, you may also find Development Guide useful.
If you have a specific idea of a fix or update, follow these steps below to submit a PR:
- Step 1: Make the change
- Step 2: Run unit tests
- Step 3: Start Chaos Mesh locally and do manual tests
- Step 4: Commit and push your changes
- Step 5: Create a pull request
- Step 6: Get a code review
-
Fork the Chaos Mesh repo, and then clone it:
$ export user={your github. profile name} $ git clone [email protected]:${user}/chaos-mesh.git
-
Set your cloned local to track the upstream repository:
$ cd chaos-mesh $ git remote add upstream https://github.com/chaos-mesh/chaos-mesh
-
Disable pushing to upstream master:
$ git remote set-url --push upstream no_push $ git remote -v
The output should look like:
origin [email protected]:$(user)/chaos-mesh.git (fetch) origin [email protected]:$(user)/chaos-mesh.git (push) upstream https://github.com/chaos-mesh/chaos-mesh (fetch) upstream no_push (push)
-
Get your local master up-to-date and create your working branch:
$ git fetch upstream $ git checkout master $ git rebase upstream/master $ git checkout -b myfeature
-
Make the change on the code.
You can new edit the code on the
myfeature
branch.If you want to update the
crd.yaml
according the the CRD structs, run the following commands:$ make generate $ make manifests/crd.yaml
-
Check the code change by running the following command:
$ make check
This will show errors if your code change does not pass the check. (eg: fmt, lint). Please fix them before submitting the PR.
Before running your code in a real Kubernetes cluster, make sure it passes all unit tests:
$ make ensure-kubebuilder # install some test dependencies
$ make test
-
Start a Kubernetes cluster locally. There are two options:
-
Use kind to start a Kubernetes cluster locally and kubectl to access the cluster. If you install these manually, run
kind
:kind create cluster
to start the cluster. -
Install the above dependencies in
~/local/bin
usinginstall.sh
:$ ./install.sh --local kind --dependency-only
-
-
Make sure the installation in step 1 is successful:
$ source ~/.bash_profile $ kind --version ... $ kubectl version ...
-
Install Chaos Mesh:
Following command will rebuild project code and reinstall chaos mesh.
# $ ./hack/local-up-chaos-mesh.sh
Now you can test your code update on the deployed cluster.
Congratulations! Now you have finished all tests and are ready to commit your code.
-
Run the following commands to keep your branch in sync:
$ git fetch upstream $ git rebase upstream/master
-
Commit your changes:
$ git add -A $ git commit --signoff
-
Push your changes to the remote branch:
$ git push -f origin myfeature
- Visit your fork at https://github.com/chaos-mesh/chaos-mesh (replace the first chaos-mesh with your username).
- Click the Compare & pull request button next to your
myfeature
branch. - Edit the description of the pull request to match your changes.
Once your pull request has been opened, it will be assigned to at least two reviewers. The reviewers will do a thorough code review of correctness, bugs, opportunities for improvement, documentation and comments, and style.
Commit changes made in response to review comments to the same branch on your fork.