|
1 | | -## Contribution Guidelines |
| 1 | +You'll find here general guidelines to contribute to this project. |
| 2 | +They mostly correspond to standard practices for open source repositories. |
| 3 | + |
| 4 | +We have tried to keep things as simple as possible. |
| 5 | + |
| 6 | +> [!NOTE] |
| 7 | +> If you're an experienced go developer on github, then you should just feel at home with us |
| 8 | +> and you may well skip the rest of this document. |
| 9 | +> |
| 10 | +> You'll essentially apply the usual guidelines for a go library project on github. |
| 11 | +
|
| 12 | +These guidelines are common to all libraries published on github by the `go-openapi` organization, |
| 13 | +so you'll feel at home with any of our projects. |
| 14 | + |
| 15 | +You'll find more detailed (or repo-specific) instructions in the [maintainer's docs][maintainers-doc]. |
| 16 | + |
| 17 | +[maintainers-doc]: ../docs/MAINTAINERS.md |
| 18 | + |
| 19 | +## How can I contribute |
| 20 | + |
| 21 | +There are many ways in which you can contribute, not just code. Here are a few ideas: |
| 22 | + |
| 23 | +- Reporting issues or bugs |
| 24 | +- Suggesting improvements |
| 25 | +- Documentation |
| 26 | +- Art work that makes the project look great |
| 27 | +- Code |
| 28 | + - proposing bug fixes and new features that are within the main project scope |
| 29 | + - improving test coverage |
| 30 | + - addressing code quality issues |
| 31 | + |
| 32 | +## Questions & issues |
| 33 | + |
| 34 | +### Asking a question |
| 35 | + |
| 36 | +You may inquire anything about this library by reporting a "Question" issue on github. |
| 37 | + |
| 38 | +You may also join our discord server where you may discuss issues or requests. |
| 39 | + |
| 40 | +[![Discord Server][discord-badge]][discord-url] |
| 41 | + |
| 42 | +[discord-badge]: https://img.shields.io/discord/1446918742398341256?logo=discord&label=discord&color=blue |
| 43 | +[discord-url]: https://discord.gg/DrafRmZx |
| 44 | + |
| 45 | +### Reporting issues |
| 46 | + |
| 47 | +Reporting a problem with our libraries _is_ a valuable contribution. |
| 48 | +You can do this on the github issues page of this repository. |
| 49 | + |
| 50 | +Please be as specific as possible when describing your issue. |
| 51 | + |
| 52 | +Whenever relevant, please provide information about your environment (go version, OS). |
| 53 | + |
| 54 | +Adding a code snippet to reproduce the issue is great, and a big time saver for maintainers. |
| 55 | + |
| 56 | +### Triaging issues |
| 57 | + |
| 58 | +You can help triage issues which may include: |
| 59 | + |
| 60 | +* reproducing bug reports |
| 61 | +* asking for important information, such as version numbers or reproduction instructions |
| 62 | +* answering questions and sharing your insight in issue comments |
| 63 | + |
| 64 | +## Code contributions |
2 | 65 |
|
3 | 66 | ### Pull requests are always welcome |
4 | 67 |
|
5 | | -We are always thrilled to receive pull requests, and do our best to |
6 | | -process them as fast as possible. Not sure if that typo is worth a pull |
7 | | -request? Do it! We will appreciate it. |
| 68 | +We are always thrilled to receive pull requests, and we do our best to |
| 69 | +process them as fast as possible. |
| 70 | + |
| 71 | +Not sure if that typo is worth a pull request? Do it! We will appreciate it. |
| 72 | + |
| 73 | +If your pull request is not accepted on the first try, don't be discouraged! |
| 74 | +If there's a problem with the implementation, hopefully you've received feedback on what to improve. |
| 75 | + |
| 76 | +If you have a lot of ideas or a lot of issues to solve, try to refrain a bit and post focused |
| 77 | +pull requests. |
| 78 | +Think that they must be reviewed by a maintainer and it is easy to lose track of things on big PRs. |
| 79 | + |
| 80 | +We're trying very hard to keep the go-openapi packages lean and focused. |
| 81 | + |
| 82 | +Together, these packages constitute a toolkit for go developers: |
| 83 | +it won't do everything for everybody out of the box, |
| 84 | +but everybody can use it to do just about everything related to OpenAPI. |
8 | 85 |
|
9 | | -If your pull request is not accepted on the first try, don't be |
10 | | -discouraged! If there's a problem with the implementation, hopefully you |
11 | | -received feedback on what to improve. |
| 86 | +This means that we might decide against incorporating a new feature. |
12 | 87 |
|
13 | | -We're trying very hard to keep go-swagger lean and focused. We don't want it |
14 | | -to do everything for everybody. This means that we might decide against |
15 | | -incorporating a new feature. However, there might be a way to implement |
16 | | -that feature *on top of* go-swagger. |
| 88 | +However, there might be a way to implement that feature *on top of* our libraries. |
17 | 89 |
|
| 90 | +### Environment |
| 91 | + |
| 92 | +You just need a `go` compiler to be installed. No special tools are needed to work with our libraries. |
| 93 | + |
| 94 | +The minimal go compiler version required is always the old stable (latest minor go version - 1). |
| 95 | + |
| 96 | +Our libraries are designed and tested to work on `Linux`, `MacOS` and `Windows`. |
| 97 | + |
| 98 | +If you're used to work with `go` you should already have everything in place. |
| 99 | + |
| 100 | +Although not required, you'll be certainly more productive with a local installation of `golangci-lint`, |
| 101 | +the meta-linter our CI uses. |
| 102 | + |
| 103 | +If you don't have it, you may install it like so: |
| 104 | + |
| 105 | +```sh |
| 106 | +go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest |
| 107 | +``` |
18 | 108 |
|
19 | 109 | ### Conventions |
20 | 110 |
|
21 | | -Fork the repo and make changes on your fork in a feature branch: |
| 111 | +#### Git flow |
| 112 | + |
| 113 | +Fork the repo and make changes to your fork in a feature branch. |
22 | 114 |
|
23 | | -- If it's a bugfix branch, name it XXX-something where XXX is the number of the |
24 | | - issue |
25 | | -- If it's a feature branch, create an enhancement issue to announce your |
26 | | - intentions, and name it XXX-something where XXX is the number of the issue. |
| 115 | +To submit a pull request, push your branch to your fork (e.g. `upstream` remote): |
| 116 | +github will propose to open a pull request on the original repository. |
27 | 117 |
|
28 | | -Submit unit tests for your changes. Go has a great test framework built in; use |
29 | | -it! Take a look at existing tests for inspiration. Run the full test suite on |
30 | | -your branch before submitting a pull request. |
| 118 | +Typically you'd follow some common naming conventions: |
31 | 119 |
|
32 | | -Update the documentation when creating or modifying features. Test |
33 | | -your documentation changes for clarity, concision, and correctness, as |
34 | | -well as a clean documentation build. See ``docs/README.md`` for more |
35 | | -information on building the docs and how docs get released. |
| 120 | +- if it's a bug fixing branch, name it `fix/XXX-something` where XXX is the number of the |
| 121 | + issue on github |
| 122 | +- if it's a feature branch, create an enhancement issue to announce your |
| 123 | + intentions, and name it `feature/XXX-something` where XXX is the number of the issue. |
36 | 124 |
|
37 | | -Write clean code. Universally formatted code promotes ease of writing, reading, |
38 | | -and maintenance. Always run `gofmt -s -w file.go` on each changed file before |
39 | | -committing your changes. Most editors have plugins that do this automatically. |
| 125 | +NOTE: we don't enforce naming conventions on branches: it's your fork after all. |
| 126 | + |
| 127 | +#### Tests |
| 128 | + |
| 129 | +Submit unit tests for your changes. |
| 130 | + |
| 131 | +Go has a great built-in test framework ; use it! |
| 132 | + |
| 133 | +Take a look at existing tests for inspiration, and run the full test suite on your branch |
| 134 | +before submitting a pull request. |
| 135 | + |
| 136 | +Our CI measures test coverage and the test coverage of every patch. |
| 137 | + |
| 138 | +Although not a blocking step - because there are so many special cases - |
| 139 | +this is an indicator that maintainers consider when approving a PR. |
| 140 | +Please try your best to cover at least 80% of your patch. |
| 141 | + |
| 142 | +#### Code style |
| 143 | + |
| 144 | +You may read our stance on code style [there](../docs/STYLE.md). |
| 145 | + |
| 146 | +#### Documentation |
| 147 | + |
| 148 | +Don't forget to update the documentation when creating or modifying a feature. |
| 149 | + |
| 150 | +Most documentation for this library is directly found in code as comments for godoc. |
| 151 | + |
| 152 | +The documentation for this go-openapi package is published on [the public go docs site][go-doc]. |
| 153 | + |
| 154 | +--- |
| 155 | + |
| 156 | +Check your documentation changes for clarity, concision, and correctness. |
| 157 | + |
| 158 | +If you want to assess the rendering of your changes when published to `pkg.go.dev`, you may |
| 159 | +want to install the `pkgsite` tool proposed by `golang.org`. |
| 160 | + |
| 161 | +```sh |
| 162 | +go install golang.org/x/pkgsite/cmd/pkgsite@latest |
| 163 | +``` |
| 164 | + |
| 165 | +Then run on the repository folder: |
| 166 | + |
| 167 | +```sh |
| 168 | +pkgsite . |
| 169 | +``` |
| 170 | + |
| 171 | +This will run a godoc server locally where you may see the documentation generated from your local repository. |
| 172 | + |
| 173 | +[go-doc]: https://pkg.go.dev/github.com/go-openapi/swag |
| 174 | + |
| 175 | +#### Commit messages |
40 | 176 |
|
41 | 177 | Pull requests descriptions should be as clear as possible and include a |
42 | 178 | reference to all the issues that they address. |
43 | 179 |
|
44 | 180 | Pull requests must not contain commits from other users or branches. |
45 | 181 |
|
46 | | -Commit messages must start with a capitalized and short summary (max. 50 |
47 | | -chars) written in the imperative, followed by an optional, more detailed |
48 | | -explanatory text which is separated from the summary by an empty line. |
| 182 | +Commit messages are not required to follow the "conventional commit" rule, but it's certainly a good |
| 183 | +thing to follow that convention (e.g. "fix: fixed panic in XYZ", "ci: did this", "feat: did that" ...). |
49 | 184 |
|
50 | | -Code review comments may be added to your pull request. Discuss, then make the |
51 | | -suggested modifications and push additional commits to your feature branch. Be |
52 | | -sure to post a comment after pushing. The new commits will show up in the pull |
53 | | -request automatically, but the reviewers will not be notified unless you |
54 | | -comment. |
| 185 | +The title in your commit message is used directly to produce our release notes: try to keep them neat. |
55 | 186 |
|
56 | | -Before the pull request is merged, make sure that you squash your commits into |
57 | | -logical units of work using `git rebase -i` and `git push -f`. After every |
58 | | -commit the test suite should be passing. Include documentation changes in the |
59 | | -same commit so that a revert would remove all traces of the feature or fix. |
| 187 | +The commit message body should detail your changes. |
60 | 188 |
|
61 | | -Commits that fix or close an issue should include a reference like `Closes #XXX` |
62 | | -or `Fixes #XXX`, which will automatically close the issue when merged. |
| 189 | +If an issue should be closed by a commit, please add this reference in the commit body: |
63 | 190 |
|
64 | | -### Sign your work |
| 191 | +``` |
| 192 | +* fixes #{issue number} |
| 193 | +``` |
65 | 194 |
|
66 | | -The sign-off is a simple line at the end of the explanation for the |
67 | | -patch, which certifies that you wrote it or otherwise have the right to |
68 | | -pass it on as an open-source patch. The rules are pretty simple: if you |
69 | | -can certify the below (from |
70 | | -[developercertificate.org](http://developercertificate.org/)): |
| 195 | +#### Code review |
71 | 196 |
|
72 | | -``` |
73 | | -Developer Certificate of Origin |
74 | | -Version 1.1 |
| 197 | +Code review comments may be added to your pull request. |
75 | 198 |
|
76 | | -Copyright (C) 2004, 2006 The Linux Foundation and its contributors. |
77 | | -660 York Street, Suite 102, |
78 | | -San Francisco, CA 94110 USA |
| 199 | +Discuss, then make the suggested modifications and push additional commits to your feature branch. |
79 | 200 |
|
80 | | -Everyone is permitted to copy and distribute verbatim copies of this |
81 | | -license document, but changing it is not allowed. |
| 201 | +Be sure to post a comment after pushing. The new commits will show up in the pull |
| 202 | +request automatically, but the reviewers will not be notified unless you comment. |
82 | 203 |
|
| 204 | +Before the pull request is merged, |
| 205 | +**make sure that you've squashed your commits into logical units of work** |
| 206 | +using `git rebase -i` and `git push -f`. |
83 | 207 |
|
84 | | -Developer's Certificate of Origin 1.1 |
| 208 | +After every commit the test suite should be passing. |
85 | 209 |
|
86 | | -By making a contribution to this project, I certify that: |
| 210 | +Include documentation changes in the same commit so that a revert would remove all traces of the feature or fix. |
87 | 211 |
|
88 | | -(a) The contribution was created in whole or in part by me and I |
89 | | - have the right to submit it under the open source license |
90 | | - indicated in the file; or |
| 212 | +#### Sign your work |
91 | 213 |
|
92 | | -(b) The contribution is based upon previous work that, to the best |
93 | | - of my knowledge, is covered under an appropriate open source |
94 | | - license and I have the right under that license to submit that |
95 | | - work with modifications, whether created in whole or in part |
96 | | - by me, under the same open source license (unless I am |
97 | | - permitted to submit under a different license), as indicated |
98 | | - in the file; or |
| 214 | +Software is developed by real people. |
99 | 215 |
|
100 | | -(c) The contribution was provided directly to me by some other |
101 | | - person who certified (a), (b) or (c) and I have not modified |
102 | | - it. |
| 216 | +The sign-off is a simple line at the end of your commit message, |
| 217 | +which certifies that you wrote it or otherwise have the right to |
| 218 | +pass it on as an open-source patch. |
103 | 219 |
|
104 | | -(d) I understand and agree that this project and the contribution |
105 | | - are public and that a record of the contribution (including all |
106 | | - personal information I submit with it, including my sign-off) is |
107 | | - maintained indefinitely and may be redistributed consistent with |
108 | | - this project or the open source license(s) involved. |
109 | | -``` |
| 220 | +We require the simple DCO below with an email signing your commit. |
| 221 | +PGP-signed commit are greatly appreciated but not required. |
110 | 222 |
|
111 | | -then you just add a line to every git commit message: |
| 223 | +The rules are pretty simple: |
112 | 224 |
|
113 | | - Signed-off-by: Joe Smith <[email protected]> |
| 225 | +- read our [DCO][dco-doc] (from [developercertificate.org][dco-source]) |
| 226 | +- if you agree with these terms, then you just add a line to every git commit message |
| 227 | + |
| 228 | +``` |
| 229 | +Signed-off-by: Joe Smith <[email protected]> |
| 230 | +``` |
114 | 231 |
|
115 | 232 | using your real name (sorry, no pseudonyms or anonymous contributions.) |
116 | 233 |
|
117 | | -You can add the sign off when creating the git commit via `git commit -s`. |
| 234 | +You can add the sign-off when creating the git commit via `git commit -s`. |
| 235 | + |
| 236 | +[dco-doc]: ./DCO.md |
| 237 | +[dco-source]: https://developercertificate.org |
| 238 | + |
| 239 | +## Code contributions by AI agents |
| 240 | + |
| 241 | +Our agentic friends are welcome to contribute! |
| 242 | + |
| 243 | +We only have a few demands to keep-up with human maintainers. |
| 244 | + |
| 245 | +1. Issues and PRs written or posted by agents should always mention the original (human) poster for reference |
| 246 | +2. We don't accept PRs attributed to agents. We don't want commits signed like "author: @claude.code". |
| 247 | + Agents or bots may coauthor commits, though. |
| 248 | +3. Security vulnerability reports by agents should always be reported privately and mention the original (human) poster |
| 249 | + (see also [Security Policy][security-doc]). |
| 250 | + |
| 251 | +[security-doc]: ../SECURITY.md |
0 commit comments