|
| 1 | +# Contributing to kubechecks |
| 2 | + |
| 3 | +We're always looking for community contributions to `kubechecks`. The best way to get started is to create an issue. This can be for a bug, or for a new feature. This helps us gauge how many other users are impacted, or would benefit from a new feature. |
| 4 | + |
| 5 | +## Issues |
| 6 | + |
| 7 | +We use [Github Issues](https://github.com/zapier/kubechecks/issues) to track issues and features for this project. |
| 8 | + |
| 9 | +## Contributor Agreement |
| 10 | + |
| 11 | +We have decided to use [DCO](https://en.wikipedia.org/wiki/Developer_Certificate_of_Origin) to reduce the friction of contributing to `kubechecks`. To sign off on a commit you can use `-s` or `--signoff` when committing to append a [trailer](https://git-scm.com/docs/git-commit#Documentation/git-commit.txt--s). |
| 12 | + |
| 13 | +If you forget to sign off on your last commit you can amend it using `git commit --amend --signoff`, or if there are multiple commits that need to be amended `git rebase --signoff HEAD~2` can be used replacing `HEAD~2` with the number of commits to go back. More information can be found in this [Stack Overflow](https://stackoverflow.com/questions/13043357/git-sign-off-previous-commits) post. |
| 14 | + |
| 15 | +Other notable projects that use DCO: |
| 16 | + |
| 17 | +* [Linux Kernel](https://developercertificate.org/) |
| 18 | +* [Gitlab](https://about.gitlab.com/community/contribute/dco-cla/) |
| 19 | +* [GCC](https://gcc.gnu.org/dco.html) |
| 20 | + |
| 21 | +------------- |
| 22 | + |
| 23 | +## Pull Request Process |
| 24 | + |
| 25 | +1. You are welcome to submit a draft pull request for commentary or review before it is fully completed. Feel free to provide more information on the issue you're addressing or a link to a specific one to add more context. |
| 26 | +2. When time permits `kubechecks`'s core team members will look over your contribution and either merge, or provide comments. It may take some time for us to respond. We kindly ask that you do not target specific team members. We may also reject a PR at this time with comments around why, and if we would reconsider it. |
| 27 | +3. If we have requested changes, you can either make those changes or, if you disagree with the suggested changes, we can discuss it further in the pull request. This may be a multi-step process. It is the contributor's responsibility to address any changes requested. While reviewers are happy to give guidance, it is unsustainable for us to perform the coding work necessary to get a PR into a mergeable state. |
| 28 | +4. Once all outstanding comments and checklist items have been addressed, your contribution will be merged! The core team takes care of updating the change log as required. It may be a bit before we cut a new release so your changes may not be available immediately. |
| 29 | + |
| 30 | +### PR Checks |
| 31 | + |
| 32 | +The following checks run when a PR is opened: |
| 33 | + |
| 34 | +* Developer Certificate of Origin (DCO): This check is applied against every **commit**. If a single commit is not signed the check will fail. Please checkout our [Contributor Agreement](#contributor-agreement) for more details. |
| 35 | +* Tests / Build: unit tests, go vet and docker build are executed on each PR. These must all pass for a PR to be considered mergeable. |
| 36 | + |
| 37 | +----------- |
| 38 | + |
| 39 | +## Developer Environment |
| 40 | + |
| 41 | +### Tools / Accounts |
| 42 | + |
| 43 | +* [Go 1.19](https://go.dev/) |
| 44 | +* [Earthly](https://earthly.dev/) |
| 45 | +* [Ngrok](https://ngrok.com/) |
| 46 | +* [Tilt](https://tilt.dev/) |
| 47 | +* [Gitlab](https://gitlab.com) / [Github](https://github.com) token |
| 48 | +* [OpenAI](https://openai.com) token (Optional) |
| 49 | +* [Kubernetes](https://kubernetes.io/) |
| 50 | + * [minikube](https://minikube.sigs.k8s.io/docs/) |
| 51 | + * [kind](https://kind.sigs.k8s.io/) |
| 52 | + * [Docker Desktop](https://docs.docker.com/desktop/kubernetes/) |
| 53 | + |
| 54 | +Some of the above tools are not necessary if you're developing against an externally accessible kubernetes cluster. We leverage Ngrok for local testing in order to accept webhooks from Gitlab/Github. |
| 55 | + |
| 56 | +### Tilt |
| 57 | + |
| 58 | +[Tilt.dev](https://tilt.dev) is used to power the local development environment. |
| 59 | +The `Tiltfile` defines all the resources required to build, run and test `kubechecks`. |
| 60 | +It creates: |
| 61 | + |
| 62 | +* Gitlab / Github repository with test files. |
| 63 | +* Deploys ArgoCD and some demo applications to your kubernetes cluster. |
| 64 | +* Deploys ngrok to provide an external accessible URL for Github/Gitlab to send webhooks to your local dev environment. |
| 65 | +* Builds, tests and runs (with watch and hot restart) the `kubechecks` server in the local Kubernetes cluster. |
| 66 | +* Delve live debugger is available for `kubechecks`. |
| 67 | + |
| 68 | +To get started do the following: |
| 69 | + |
| 70 | +* Copy the `.env.example` and set required values. |
| 71 | + |
| 72 | + ```console |
| 73 | + cp .env.example .env |
| 74 | + ``` |
| 75 | + |
| 76 | +* From the root directory of this repo: |
| 77 | + |
| 78 | + ```console |
| 79 | + tilt up |
| 80 | + ``` |
| 81 | + |
| 82 | +You should see output like: |
| 83 | + |
| 84 | + ``` |
| 85 | + Tilt started on http://localhost:10350/ |
| 86 | + v0.30.13, built 2022-12-05 |
| 87 | + |
| 88 | + (space) to open the browser |
| 89 | + (s) to stream logs (--stream=true) |
| 90 | + (t) to open legacy terminal mode (--legacy=true) |
| 91 | + (ctrl-c) to exit |
| 92 | + |
| 93 | + ``` |
| 94 | + |
| 95 | +In the background Tilt has started building and deploying resources. |
| 96 | + |
| 97 | +You should go ahead and press the space bar to open the Tilt web UI. |
| 98 | + |
| 99 | +There are currently some circular dependencies in the local dev resources, so all resources may not come up cleanly on the first launch. |
| 100 | + |
| 101 | + |
| 102 | + |
| 103 | +Click the Detailed view button at the top, and click the refresh button next to the `Tiltfile` resource to run another cycle. |
| 104 | + |
| 105 | + |
| 106 | + |
| 107 | +#### Minikube |
| 108 | + |
| 109 | +If you're using minikube with Tilt we recommend following this [guide](https://github.com/tilt-dev/minikube-local) to setup a local registry that Tilt can push to automatically. Without this Tilt will attempt to push up to Docker Hub by default. |
| 110 | + |
| 111 | +### Code Changes |
| 112 | + |
| 113 | +We use Earthly to simplify our CI/CD process with `kubechecks`. This also simplifies testing changes locally before pushing them up to ensure your PR will pass all required checks. The best command to run is `earthly +unit-test` this will pull all the required dependencies (including any new ones that you have added). It will then run [go vet](https://pkg.go.dev/cmd/vet), and if those pass it will run `go test` with race detection enabled. You can also always run these commands directly `go test -race ./...` will run all tests in the repo with race detection enabled. Please ensure that `earthly +unit-test` is passing before opening a PR. |
| 114 | + |
| 115 | +### Documentation Changes |
| 116 | + |
| 117 | +We use [mkdocs](https://www.mkdocs.org/) to build our docs locally. You can build these docs by running `mkdocs serve` from the root of the repository. It will also auto reload when any file is changed in that directory. By default you can view the docs under `http://localhost:8000`. Please confirm that any changes to documentation render correctly and that your changes display as expected. |
0 commit comments