Skip to content
Myr

CONTRIBUTING.md

This file

Path

CONTRIBUTING.md

275 lines · 12.3 KiB · Markdown

Last changed by

docs: fix link reference for pull request template (#3806)Michielbefore adoptionef349f8

History of this file

Take it

The walk stopped after 200 commits: lines older than dcbcf5c point at it.

axum-extra: Make typed-routing feature enable routing feature (#3514)tottotobefore adoptiondcbcf5c

lines 1–33why, one step back
1# Contributing to axum
23🎈 Thanks for your help improving the project! We are so happy to have4you!56There are opportunities to contribute to `axum` at any level. It doesn't7matter if you are just getting started with Rust or are the most weathered8expert, we can use your help.910**No contribution is too small and all contributions are valued.**1112This guide will help you get started. **Do not let this guide intimidate you**.13It should be considered a map to help you navigate the process.1415Don't know where to start? Check [issues labeled with "E-help-wanted"](https://github.com/tokio-rs/axum/issues?q=is%3Aopen+is%3Aissue+label%3AE-help-wanted) or ["E-easy"](https://github.com/tokio-rs/axum/issues?q=is%3Aopen+is%3Aissue+label%3AE-easy).1617You may also get help with contributing in the [`axum` Discord18channel][discord], please join us!1920[discord]: https://discord.gg/tokio2122## Conduct2324The `axum` project adheres to the [Rust Code of Conduct][coc]. This25describes the _minimum_ behavior expected from all contributors.2627[coc]: https://github.com/rust-lang/rust/blob/master/CODE_OF_CONDUCT.md2829## Contributing in Issues3031For any issue, there are fundamentally three ways an individual can contribute:32331. By opening the issue for discussion: For instance, if you believe that you

chore: fix typos (#3758)David Pedersenbefore adoption5bc0046

line 34why, one step back
34 have uncovered a bug in an `axum` crate, creating a new issue in the

axum-extra: Make typed-routing feature enable routing feature (#3514)tottotobefore adoptiondcbcf5c

lines 35–167why, one step back
35 tokio-rs/axum [issue tracker][issues] is the way to report it.
36372. By helping to triage the issue: This can be done by providing38 supporting details (a test case that demonstrates a bug), providing39 suggestions on how to address the issue, or ensuring that the issue is tagged40 correctly.41423. By helping to resolve the issue: Typically this is done either in the form of43 demonstrating that the issue reported is not a problem after all, or more44 often, by opening a Pull Request that changes some bit of something in45 axum in a concrete and reviewable manner.4647**Anybody can participate in any stage of contribution**. We urge you to48participate in the discussion around bugs and participate in reviewing PRs.4950[issues]: https://github.com/tokio-rs/axum/issues5152### Asking for General Help5354If you have reviewed existing documentation and still have questions or are55having problems, you can open an issue asking for help.5657In exchange for receiving help, we ask that you contribute back a documentation58PR that helps others avoid the problems that you encountered.5960### Submitting a Bug Report6162When opening a new issue in the `axum` issue tracker, users will63be presented with a [basic template][template] that should be filled in. If you64believe that you have uncovered a bug, please fill out this form, following the65template to the best of your ability. Do not worry if you cannot answer every66detail, just fill in what you can.6768The two most important pieces of information we need in order to properly69evaluate the report is a description of the behavior you are seeing and a simple70test case we can use to recreate the problem on our own. If we cannot recreate71the issue, it becomes harder for us to fix.7273See [How to create a Minimal, Complete, and Verifiable example][mcve].7475[mcve]: https://stackoverflow.com/help/mcve76[template]: .github/ISSUE_TEMPLATE/bug_report.md7778### Triaging a Bug Report7980Once an issue has been opened, it is not uncommon for there to be discussion81around it. Some contributors may have differing opinions about the issue,82including whether the behavior being seen is a bug or a feature. This discussion83is part of the process and should be kept focused, helpful, and professional.8485Short, clipped responses—that provide neither additional context nor supporting86detail—are not helpful or professional. To many, such responses are simply87annoying and unfriendly.8889Contributors are encouraged to help one another make forward progress as much as90possible, empowering one another to solve issues collaboratively. If you choose91to comment on an issue that you feel either is not a problem that needs to be92fixed, or if you encounter information in an issue that you feel is incorrect,93explain why you feel that way with additional supporting context, and be willing94to be convinced that you may be wrong. By doing so, we can often reach the95correct outcome much faster.9697### Resolving a Bug Report9899In the majority of cases, issues are resolved by opening a Pull Request. The100process for opening and reviewing a Pull Request is similar to that of opening101and triaging issues, but carries with it a necessary review and approval102workflow that ensures that the proposed changes meet the minimal quality.103104## Pull Requests105106Pull Requests are the way concrete changes are made to the code, documentation,107and dependencies in the `axum` repository.108109Even tiny pull requests (e.g., one character pull request fixing a typo in API110documentation) are greatly appreciated. Before making a large change, it is111usually a good idea to first open an issue describing the change to solicit112feedback and guidance. This will increase the likelihood of the PR getting113merged.114115### Tests116117If the change being proposed alters code (as opposed to only documentation for118example), it is either adding new functionality to a crate or it is fixing119existing, broken functionality. In both of these cases, the pull request should120include one or more tests to ensure that the crate does not regress in the future.121122#### Documentation tests123124Ideally, every API has at least one [documentation test] that demonstrates how to125use the API. Documentation tests are run with `cargo test --doc`. This ensures126that the example is correct and provides additional test coverage.127128The trick to documentation tests is striking a balance between being succinct129for a reader to understand and actually testing the API.130131In Rust documentation, lines that start with `/// #` are removed when the132documentation is generated. They are only there to get the test to run.133134### Commits135136It is a recommended best practice to keep your changes as logically grouped as137possible within individual commits. There is no limit to the number of commits138any single Pull Request may have, and many contributors find it easier to review139changes that are split across multiple commits.140141Note that multiple commits often get squashed when they are landed (see the142notes about [commit squashing]).143144#### Commit message guidelines145146A good commit message should describe what changed and why.1471481. The first line should:149150 * Contain a short description of the change (preferably 50 characters or less,151 and no more than 72 characters)1521532. Keep the second line blank.1543. Wrap all other lines at 72 columns (except for long URLs).1554. If your patch fixes an open issue, you can add a reference to it at the end156 of the log. Use the `Fixes: #` prefix and the issue number. For other157 references use `Refs: #`. `Refs` may include multiple issues, separated by a158 comma.159160 Examples:161162 - `Fixes: #1337`163 - `Refs: #1234, #42`164165### Opening the Pull Request166167From within GitHub, opening a new Pull Request will present you with a

docs: fix link reference for pull request template (#3806)Michielbefore adoptionef349f8

line 168why, one step back
168[template][pr_template] that should be filled out. Please try to do your best at filling out

axum-extra: Make typed-routing feature enable routing feature (#3514)tottotobefore adoptiondcbcf5c

lines 169–170why, one step back
169the details, but feel free to skip parts if you're not sure what to put.
170

docs: fix link reference for pull request template (#3806)Michielbefore adoptionef349f8

line 171why, one step back
171[pr_template]: .github/PULL_REQUEST_TEMPLATE.md

axum-extra: Make typed-routing feature enable routing feature (#3514)tottotobefore adoptiondcbcf5c

lines 172–275why, one step back
172
173### Discuss and update174175You will probably get feedback or requests for changes to your Pull Request.176This is a big part of the submission process so don't be discouraged! Some177contributors may sign off on the Pull Request right away, others may have178more detailed comments or feedback. This is a necessary part of the process179in order to evaluate whether the changes are correct and necessary.180181**Any community member can review a PR and you might get conflicting feedback**.182Keep an eye out for comments from code owners to provide guidance on conflicting183feedback.184185**Once the PR is open, do not rebase the commits**. See [Commit Squashing] for186more details.187188### Commit Squashing189190In most cases, **do not squash commits that you add to your Pull Request during191the review process**. When the commits in your Pull Request land, they may be192squashed into one commit per logical change. Metadata will be added to the193commit message (including links to the Pull Request, links to relevant issues,194and the names of the reviewers). The commit history of your Pull Request,195however, will stay intact on the Pull Request page.196197## Reviewing Pull Requests198199**Any Tokio, Hyperium, and Tower, axum community member is welcome to review any pull request**.200201All contributors who choose to review and provide feedback on Pull Requests have202a responsibility to both the project and the individual making the contribution.203Reviews and feedback must be helpful, insightful, and geared towards improving204the contribution as opposed to simply blocking it. If there are reasons why you205feel the PR should not land, explain what those are. Do not expect to be able to206block a Pull Request from advancing simply because you say "No" without giving207an explanation. Be open to having your mind changed. Be open to working with the208contributor to make the Pull Request better.209210Reviews that are dismissive or disrespectful of the contributor or any other211reviewers are strictly counter to the Code of Conduct.212213When reviewing a Pull Request, the primary goals are for the codebase to improve214and for the person submitting the request to succeed. **Even if a Pull Request215does not land, the submitters should come away from the experience feeling like216their effort was not wasted or unappreciated**. Every Pull Request from a new217contributor is an opportunity to grow the community.218219### Review a bit at a time.220221Do not overwhelm new contributors.222223It is tempting to micro-optimize and make everything about relative performance,224perfect grammar, or exact style matches. Do not succumb to that temptation.225226Focus first on the most significant aspects of the change:2272281. Does this change make sense for axum?2292. Does this change make axum better, even if only incrementally?2303. Are there clear bugs or larger scale issues that need attending to?2314. Is the commit message readable and correct? If it contains a breaking change232 is it clear enough?233234Note that only **incremental** improvement is needed to land a PR. This means235that the PR does not need to be perfect, only better than the status quo. Follow236up PRs may be opened to continue iterating.237238When changes are necessary, *request* them, do not *demand* them, and **do not239assume that the submitter already knows how to add a test or run a benchmark**.240241Specific performance optimization techniques, coding styles and conventions242change over time. The first impression you give to a new contributor never does.243244Nits (requests for small changes that are not essential) are fine, but try to245avoid stalling the Pull Request. Most nits can typically be fixed by the axum246Collaborator landing the Pull Request but they can also be an opportunity for247the contributor to learn a bit more about the project.248249It is always good to clearly indicate nits when you comment: e.g.250`Nit: change foo() to bar(). But this is not blocking.`251252If your comments were addressed but were not folded automatically after new253commits or if they proved to be mistaken, please, [hide them][hiding-a-comment]254with the appropriate reason to keep the conversation flow concise and relevant.255256### Be aware of the person behind the code257258Be aware that *how* you communicate requests and reviews in your feedback can259have a significant impact on the success of the Pull Request. Yes, we may land a260particular change that makes `axum` better, but the individual might just261not want to have anything to do with `axum` ever again. The goal is not262just having good code.263264### Abandoned or Stalled Pull Requests265266If a Pull Request appears to be abandoned or stalled, it is polite to first267check with the contributor to see if they intend to continue the work before268checking if they would mind if you took it over (especially if it just has nits269left). When doing so, it is courteous to give the original contributor credit270for the work they started, either by preserving their name and email address in271the commit log, or by using an `Author: ` meta-data tag in the commit.272273[hiding-a-comment]: https://help.github.com/articles/managing-disruptive-comments/#hiding-a-comment274[documentation test]: https://doc.rust-lang.org/rustdoc/documentation-tests.html275[keep-a-changelog]: https://github.com/olivierlacan/keep-a-changelog/blob/master/CHANGELOG.md