| 1 |
# How to Contribute |
| 2 |
|
| 3 |
CNI is [Apache 2.0 licensed](LICENSE) and accepts contributions via GitHub |
| 4 |
pull requests. This document outlines some of the conventions on development |
| 5 |
workflow, commit message formatting, contact points and other resources to make |
| 6 |
it easier to get your contribution accepted. |
| 7 |
|
| 8 |
We gratefully welcome improvements to documentation as well as to code. |
| 9 |
|
| 10 |
## Certificate of Origin |
| 11 |
|
| 12 |
By contributing to this project you agree to the Developer Certificate of |
| 13 |
Origin (DCO). This document was created by the Linux Kernel community and is a |
| 14 |
simple statement that you, as a contributor, have the legal right to make the |
| 15 |
contribution. See the [DCO](DCO) file for details. |
| 16 |
|
| 17 |
## Email and Chat |
| 18 |
|
| 19 |
The project uses the cni-dev email list, IRC chat, and Slack: |
| 20 |
- Email: [cni-dev](https://groups.google.com/forum/#!forum/cni-dev) |
| 21 |
- IRC: #[containernetworking](irc://irc.freenode.net:6667/#containernetworking) channel on [freenode.net](https://freenode.net/) |
| 22 |
- Slack: #cni on the [CNCF slack](https://slack.cncf.io/). NOTE: the previous CNI Slack (containernetworking.slack.com) has been sunsetted. |
| 23 |
|
| 24 |
Please avoid emailing maintainers found in the MAINTAINERS file directly. They |
| 25 |
are very busy and read the mailing lists. |
| 26 |
|
| 27 |
## Getting Started |
| 28 |
|
| 29 |
- Fork the repository on GitHub |
| 30 |
- Read the [README](README.md) for build and test instructions |
| 31 |
- Play with the project, submit bugs, submit pull requests! |
| 32 |
|
| 33 |
## Contribution workflow |
| 34 |
|
| 35 |
This is a rough outline of how to prepare a contribution: |
| 36 |
|
| 37 |
- Create a topic branch from where you want to base your work (usually branched from main). |
| 38 |
- Make commits of logical units. |
| 39 |
- Make sure your commit messages are in the proper format (see below). |
| 40 |
- Push your changes to a topic branch in your fork of the repository. |
| 41 |
- If you changed code: |
| 42 |
- add automated tests to cover your changes, using the [Ginkgo](https://onsi.github.io/ginkgo/) & [Gomega](https://onsi.github.io/gomega/) style |
| 43 |
- if the package did not previously have any test coverage, add it to the list |
| 44 |
of `TESTABLE` packages in the `test.sh` script. |
| 45 |
- run the full test script and ensure it passes |
| 46 |
- Make sure any new code files have a license header (this is now enforced by automated tests) |
| 47 |
- Submit a pull request to the original repository. |
| 48 |
|
| 49 |
## How to run the test suite |
| 50 |
|
| 51 |
We generally require test coverage of any new features or bug fixes. |
| 52 |
|
| 53 |
Here's how you can run the test suite on any system (even Mac or Windows) using |
| 54 |
[Vagrant](https://www.vagrantup.com/) and a hypervisor of your choice: |
| 55 |
|
| 56 |
```bash |
| 57 |
vagrant up |
| 58 |
vagrant ssh |
| 59 |
# you're now in a shell in a virtual machine |
| 60 |
sudo su |
| 61 |
cd /go/src/github.com/containernetworking/cni |
| 62 |
|
| 63 |
# to run the full test suite |
| 64 |
./test.sh |
| 65 |
|
| 66 |
# to focus on a particular test suite |
| 67 |
cd libcni |
| 68 |
go test |
| 69 |
``` |
| 70 |
|
| 71 |
## Acceptance policy |
| 72 |
|
| 73 |
These things will make a PR more likely to be accepted: |
| 74 |
|
| 75 |
- a well-described requirement |
| 76 |
- tests for new code |
| 77 |
- tests for old code! |
| 78 |
- new code and tests follow the conventions in old code and tests |
| 79 |
- a good commit message (see below) |
| 80 |
|
| 81 |
In general, we will merge a PR once two maintainers have endorsed it. |
| 82 |
Trivial changes (e.g., corrections to spelling) may get waved through. |
| 83 |
For substantial changes, more people may become involved, and you might get asked to resubmit the PR or divide the changes into more than one PR. |
| 84 |
|
| 85 |
### Format of the Commit Message |
| 86 |
|
| 87 |
We follow a rough convention for commit messages that is designed to answer two |
| 88 |
questions: what changed and why. The subject line should feature the what and |
| 89 |
the body of the commit should describe the why. |
| 90 |
|
| 91 |
```md |
| 92 |
scripts: add the test-cluster command |
| 93 |
|
| 94 |
this uses tmux to setup a test cluster that you can easily kill and |
| 95 |
start for debugging. |
| 96 |
|
| 97 |
Fixes #38 |
| 98 |
``` |
| 99 |
|
| 100 |
The format can be described more formally as follows: |
| 101 |
|
| 102 |
```md |
| 103 |
<subsystem>: <what changed> |
| 104 |
<BLANK LINE> |
| 105 |
<why this change was made> |
| 106 |
<BLANK LINE> |
| 107 |
<footer> |
| 108 |
``` |
| 109 |
|
| 110 |
The first line is the subject and should be no longer than 70 characters, the |
| 111 |
second line is always blank, and other lines should be wrapped at 80 characters. |
| 112 |
This allows the message to be easier to read on GitHub as well as in various |
| 113 |
git tools. |
| 114 |
|
| 115 |
## 3rd party plugins |
| 116 |
|
| 117 |
So you've built a CNI plugin. Where should it live? |
| 118 |
|
| 119 |
Short answer: We'd be happy to link to it from our [list of 3rd party plugins](README.md#3rd-party-plugins). |
| 120 |
But we'd rather you kept the code in your own repo. |
| 121 |
|
| 122 |
Long answer: An advantage of the CNI model is that independent plugins can be |
| 123 |
built, distributed and used without any code changes to this repository. While |
| 124 |
some widely used plugins (and a few less-popular legacy ones) live in this repo, |
| 125 |
we're reluctant to add more. |
| 126 |
|
| 127 |
If you have a good reason why the CNI maintainers should take custody of your |
| 128 |
plugin, please open an issue or PR. |