2019-10-15 23:35:23 -04:00
# Contributing to Puma
By participating in this project, you agree to follow the [code of conduct].
[code of conduct]: https://github.com/puma/puma/blob/master/CODE_OF_CONDUCT.md
2021-09-21 11:58:09 -04:00
There are lots of ways to contribute to Puma. Some examples include:
2019-10-15 23:35:23 -04:00
* creating a [bug report] or [feature request]
2019-10-15 23:52:10 -04:00
* verifying [existing bug reports] and adding [reproduction steps]
2021-09-21 11:58:09 -04:00
* reviewing [pull requests] and testing the changes locally on your machine
2020-03-14 09:11:13 -04:00
* writing or editing [documentation]
2019-10-15 23:35:23 -04:00
* improving test coverage
2019-10-15 23:52:10 -04:00
* fixing a [reproducing bug] or adding a new feature
2019-10-15 23:35:23 -04:00
[bug report]: https://github.com/puma/puma/issues/new?template=bug_report.md
[feature request]: https://github.com/puma/puma/issues/new?template=feature_request.md
2019-10-15 23:52:10 -04:00
[existing bug reports]: https://github.com/puma/puma/issues?q=is%3Aopen+is%3Aissue+label%3Aneeds-repro
2019-10-15 23:35:23 -04:00
[pull requests]: https://github.com/puma/puma/pulls
2020-03-14 09:11:13 -04:00
[documentation]: https://github.com/puma/puma/tree/master/docs
2019-10-15 23:35:23 -04:00
[reproduction steps]: https://github.com/puma/puma/blob/CONTRIBUTING.md#reproduction-steps
2019-10-15 23:52:10 -04:00
[reproducing bug]: https://github.com/puma/puma/issues?utf8=%E2%9C%93& q=is%3Aopen+is%3Aissue+label%3Abug
2019-10-15 23:35:23 -04:00
2020-03-14 09:12:36 -04:00
Newbies welcome! We would be happy to help you make your first contribution to a F/OSS project.
2019-10-15 23:35:23 -04:00
## Setup
2020-10-21 16:40:34 -04:00
First step: join us on Matrix at [#puma-contrib:matrix.org ](https://matrix.to/#/!blREBEDhVeXTYdjTVT:matrix.org?via=matrix.org )
2021-09-21 11:58:09 -04:00
Clone the Puma repository:
```sh
git clone git@github.com:puma/puma.git & & cd puma
```
2019-10-15 23:52:10 -04:00
2021-09-21 11:58:09 -04:00
You need to install [ragel] (use Ragel version 7.0.0.9) to generate Puma's extension code.
2019-10-15 23:35:23 -04:00
macOS:
```sh
brew install ragel
```
Linux:
```sh
apt-get install ragel
```
2021-04-25 21:23:23 -04:00
Windows (Ruby 2.5 and later):
```sh
ridk exec pacman -S mingw-w64-x86_64-openssl mingw-w64-x86_64-ragel
```
2021-09-21 11:58:09 -04:00
Install the Ruby dependencies:
2019-10-15 23:35:23 -04:00
```sh
bundle install
```
2021-09-21 11:58:09 -04:00
To run Puma locally, you must compile the native extension.
2019-10-15 23:52:10 -04:00
2021-09-21 11:58:09 -04:00
Ubuntu, macOS, etc:
2019-10-15 23:52:10 -04:00
```sh
bundle exec rake compile
2021-09-21 11:58:09 -04:00
```
2021-04-25 21:23:23 -04:00
2021-09-21 11:58:09 -04:00
Windows:
```sh
2021-04-25 21:23:23 -04:00
bundle exec rake -rdevkit compile
2019-10-15 23:52:10 -04:00
```
2021-09-21 11:58:09 -04:00
Now, you should be able to run Puma locally:
2019-10-15 23:52:10 -04:00
```sh
bundle exec bin/puma test/rackup/hello.ru
2021-04-25 21:23:23 -04:00
# -or-
bundle exec ruby -Ilib bin/puma test/rackup/hello.ru
2019-10-15 23:52:10 -04:00
```
2021-04-17 10:28:51 -04:00
Alternatively, you can reference your local copy in a project's `Gemfile` :
```ruby
gem "puma", path: "/path/to/local/puma"
```
See the [Bundler docs ](https://bundler.io/man/gemfile.5.html#PATH ) for more details.
2021-09-21 11:58:09 -04:00
[ragel]: https://www.colm.net/open-source/ragel/
2019-10-15 23:35:23 -04:00
2021-09-21 11:58:09 -04:00
## Running tests
2019-10-15 23:35:23 -04:00
2021-09-21 11:58:09 -04:00
To run the entire test suite:
2019-10-15 23:35:23 -04:00
```sh
bundle exec rake test:all
```
To run a single test file:
```sh
2020-03-14 09:11:13 -04:00
bundle exec ruby test/test_binder.rb
2019-10-15 23:35:23 -04:00
```
2021-09-21 11:58:09 -04:00
You can also run tests with [`m` ](https://github.com/qrush/m ):
2019-10-15 23:35:23 -04:00
```sh
bundle exec m test/test_binder.rb
```
2021-09-21 11:58:09 -04:00
To run a single test:
2019-10-15 23:35:23 -04:00
```sh
bundle exec m test/test_binder.rb:37
```
2021-12-11 16:59:49 -05:00
To run a single test with 5 seconds as the test case timeout:
```sh
TEST_CASE_TIMEOUT=5 bundle exec m test/test_binder.rb:37
```
2019-10-15 23:52:10 -04:00
## How to contribute
2021-09-21 11:58:09 -04:00
Puma could use your help in several areas!
**The [contrib-wanted] label indicates that an issue might approachable to first-time contributors.**\
2019-10-15 23:52:10 -04:00
2021-09-21 11:58:09 -04:00
**Reproducing bug reports**: The [needs-repro] label indicates than an issue lacks reproduction steps. You can help by reproducing the issue and sharing the steps you took in the comments.
2019-10-15 23:52:10 -04:00
2021-09-21 11:58:09 -04:00
**Helping with our native extensions**: If you are interested in writing C or Java, we could really use your help. Check out the issue labels for [c-ext] and [JRuby].
2019-10-15 23:52:10 -04:00
2021-09-21 11:58:09 -04:00
**Fixing bugs**: Issues with the [bug] label have working reproduction steps, which you can use to write a test and submit a patch.
2019-10-15 23:52:10 -04:00
2021-09-21 11:58:09 -04:00
**Writing features**: The [feature] label highlights requests for new functionality. Write tests and code up our new feature!
2019-10-15 23:52:10 -04:00
2021-09-21 11:58:09 -04:00
**Code review**: Take a look at open pull requests and offer your feedback. Code review is not just for maintainers. We need your help and eyeballs!
2019-10-15 23:52:10 -04:00
2021-09-21 11:58:09 -04:00
**Write documentation**: Puma needs more docs in many areas, especially where we have open issues with the [docs] label.
2019-10-15 23:52:10 -04:00
2021-09-21 11:58:09 -04:00
[bug]: https://github.com/puma/puma/issues?q=is%3Aopen+is%3Aissue+label%3Abug
[c-ext]: https://github.com/puma/puma/issues?q=is%3Aopen+is%3Aissue+label%3Ac-ext
[contrib-wanted]: https://github.com/puma/puma/issues?q=is%3Aopen+is%3Aissue+label%3Acontrib-wanted
[docs]: https://github.com/puma/puma/issues?q=is%3Aopen+is%3Aissue+label%3Adocs
[feature]: https://github.com/puma/puma/issues?q=is%3Aopen+is%3Aissue+label%3Afeature
[jruby]: https://github.com/puma/puma/issues?q=is%3Aopen+is%3Aissue+label%3Ajruby
[needs-repro]: https://github.com/puma/puma/issues?q=is%3Aopen+is%3Aissue+label%3Aneeds-repro
2019-10-15 23:52:10 -04:00
2019-10-15 23:35:23 -04:00
## Reproduction steps
Reproducing a bug helps identify the root cause of that bug so it can be fixed.
2021-09-21 11:58:09 -04:00
2019-10-15 23:35:23 -04:00
To get started, create a rackup file and config file and then run your test app
with:
```sh
bundle exec puma -C < path / to / config . rb > < path / to / rackup . ru >
```
2021-09-21 11:58:09 -04:00
For example, using a test rack app ([`test/rackup/hello.ru`][rackup]) and a
test config file ([`test/config/settings.rb`][config]):
2019-10-15 23:35:23 -04:00
```sh
bundle exec puma -C test/config/settings.rb test/rackup/hello.ru
```
2021-09-21 11:58:09 -04:00
There is also a Dockerfile available for reproducing Linux-specific issues:
2019-10-15 23:35:23 -04:00
```sh
docker build -f tools/docker/Dockerfile -t puma .
docker run -p 9292:9292 -it puma
```
[rackup]: https://github.com/puma/puma/blob/master/test/rackup/hello.ru
[config]: https://github.com/puma/puma/blob/master/test/config/settings.rb
## Pull requests
Code contributions should generally include test coverage. If you aren't sure how to
test your changes, please open a pull request and leave a comment asking for
help.
2021-09-21 11:58:09 -04:00
There's no need to update the changelog ([`History.md`](History.md)); that is done [when a new release is made ](Release.md ).
2019-10-15 23:52:10 -04:00
2021-09-29 14:03:25 -04:00
Puma uses [GitHub Actions ](https://docs.github.com/en/actions ) for CI testing. Please consider running the workflows in your fork before creating a PR. It is possible to enable GitHub Actions on your fork in the repositories' `Actions` tab.
2021-04-25 21:23:23 -04:00
2020-11-14 17:01:55 -05:00
## Backports
2021-04-25 21:23:23 -04:00
Puma does not have a backport "policy" - maintainers will not consistently backport bugfixes to previous minor or major versions (we do treat security differently, see [`SECURITY.md` ](SECURITY.md ).
2020-11-14 17:01:55 -05:00
As a contributor, you may make pull requests against `-stable` branches to backport fixes, and maintainers will release them once they're merged. For example, if you'd like to make a backport for 4.3.x, you can make a pull request against `4-3-stable` . If there is no appropriate branch for the release you'd like to backport against, please just open an issue and we'll make one for you.
2020-10-21 16:40:34 -04:00
## Join the community
If you're looking to contribute to Puma, please join us on Matrix at [#puma-contrib:matrix.org ](https://matrix.to/#/!blREBEDhVeXTYdjTVT:matrix.org?via=matrix.org ).
2019-10-15 23:52:10 -04:00
## Bibliography/Reading
Puma can be a bit intimidating for your first contribution because there's a lot of concepts here that you've probably never had to think about before - Rack, sockets, forking, threads etc. Here are some helpful links for learning more about things related to Puma:
2020-03-14 09:11:13 -04:00
* [Puma's Architecture docs ](https://github.com/puma/puma/blob/master/docs/architecture.md )
2020-09-22 23:13:37 -04:00
* [The Rack specification ](https://github.com/rack/rack/blob/master/SPEC.rdoc )
2019-10-15 23:52:10 -04:00
* The Ruby docs for IO.pipe, TCPServer/Socket.
* [nio4r documentation ](https://github.com/socketry/nio4r/wiki/Getting-Started )