| 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 | ## Contribution workflow |
| 18 | |
| 19 | This is a rough outline of how to prepare a contribution: |
| 20 | |
| 21 | - Create a topic branch from where you want to base your work |
| 22 | (usually branched from main). |
| 23 | - Make commits of logical units. |
| 24 | - Make sure your commit messages are in the proper format (see below). |
| 25 | - Push your changes to a topic branch in your fork of the repository. |
| 26 | - If you changed code: |
| 27 | - Add unit and integration tests to cover your changes |
| 28 | (see existing tests for style). |
| 29 | - Run all the test and ensure they pass. |
| 30 | - Make sure any new code files have a license header. |
| 31 | - Submit a pull request to the original repository. |
| 32 | - Examine the check results on the PR. All required checks should pass. |
| 33 | |
| 34 | ## How to run the test suite |
| 35 | We generally require test coverage of any new features or bug fixes. |
| 36 | |
| 37 | Unit test should not require any dependencies and may run on any platform. |
| 38 | |
| 39 | Integration tests depend on nftables and require a Linux platform with nftable |
| 40 | support in the kernel and the `nft` executable. |
| 41 | |
| 42 | To run the unit-tests, use this command from the project root: |
| 43 | ```bash |
| 44 | ./autmation/run-tests.sh --unit-test |
| 45 | ``` |
| 46 | |
| 47 | To run the integration-tests, use this command from the project root: |
| 48 | ```bash |
| 49 | ./autmation/run-tests.sh --integration-test |
| 50 | ``` |
| 51 | |
| 52 | ## Help utilities |
| 53 | |
| 54 | In order to help resolve the formatting checks, developers can use the |
| 55 | provided `./automation/go-format.sh` script to format inline the code. |
| 56 | |
| 57 | |
| 58 | # Acceptance policy |
| 59 | |
| 60 | The following points will make a PR more likely to be accepted: |
| 61 | |
| 62 | - A well-described requirement. |
| 63 | - Tests for new code. |
| 64 | - Tests for old code! |
| 65 | - A good commit message (see below). |
| 66 | |
| 67 | In general, we will merge a PR once at least one maintainer has endorsed it. |
| 68 | For substantial changes, more people may become involved, |
| 69 | and you might get asked to resubmit the PR or divide the changes into more than |
| 70 | one PR/commit. |
| 71 | |
| 72 | ### Format of the Commit Message |
| 73 | |
| 74 | We follow a rough convention for commit messages that is designed to answer two |
| 75 | questions: what changed and why. The subject line should feature the what and |
| 76 | the body of the commit should describe the why. |
| 77 | |
| 78 | See https://chris.beams.io/posts/git-commit . |