Skip to content
Myr

contributing.md

This file

Path

docs/contributing.md

187 lines · 5.8 KiB · Markdown

Last changed by

Add test script (#451)Florimond Mancabefore adoption5e4f54d

History of this file

Take it

Create a Contributing page in the documentation (#190)Humberto Rochabefore adoption079ab33

lines 1–2why, one step back
1# Contributing
2

Fix typos, spelling issues, and grammar in docs (#426)Kyle Galbraithbefore adoptionb65bce5

lines 3–4why, one step back
3Thank you for being interested in contributing to HTTPX.
4There are many ways you can contribute to the project:

Create a Contributing page in the documentation (#190)Humberto Rochabefore adoption079ab33

line 5why, one step back
5

Add additional info to Contributing Guide (#213)Humberto Rochabefore adoption7156c36

lines 6–27why, one step back
6- Try HTTPX and [report bugs/issues you find](https://github.com/encode/httpx/issues/new)
7- [Implement new features](https://github.com/encode/httpx/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22)8- [Review Pull Requests of others](https://github.com/encode/httpx/pulls)9- Write documentation10- Participate in discussions1112## Reporting Bugs or Other Issues1314Found something that HTTPX should support?15Stumbled upon some unexpected behavior?1617Feel free to open an issue at the18[issue tracker](https://github.com/encode/httpx/issues).19Try to be more descriptive as you can and in case of a bug report,20provide as much information as possible like:2122- OS platform23- Python version24- Installed dependencies and versions (`python -m pip freeze`)25- Code snippet26- Error traceback27

Create a Contributing page in the documentation (#190)Humberto Rochabefore adoption079ab33

lines 28–29why, one step back
28## Development
29

Add additional info to Contributing Guide (#213)Humberto Rochabefore adoption7156c36

lines 30–31why, one step back
30To start developing HTTPX create a **fork** of the
31[HTTPX repository](https://github.com/encode/httpx) on GitHub.

Create a Contributing page in the documentation (#190)Humberto Rochabefore adoption079ab33

lines 32–39why, one step back
32
33Then clone your fork with the following command replacing `YOUR-USERNAME` with34your GitHub username:3536```shell37$ git clone https://github.com/YOUR-USERNAME/httpx38```39

Add additional info to Contributing Guide (#213)Humberto Rochabefore adoption7156c36

lines 40–42why, one step back
40With the repository cloned you can access its folder, set up the
41virtual environment, install the project requirements,42and then install HTTPX on edit mode:

Create a Contributing page in the documentation (#190)Humberto Rochabefore adoption079ab33

line 43why, one step back
43

Add additional info to Contributing Guide (#213)Humberto Rochabefore adoption7156c36

lines 44–50why, one step back
44```shell
45$ cd httpx46$ python3 -m venv venv47$ source venv/bin/activate48$ pip install -r test-requirements.txt49$ pip install -e .50```

Create a Contributing page in the documentation (#190)Humberto Rochabefore adoption079ab33

line 51why, one step back
51

Add additional info to Contributing Guide (#213)Humberto Rochabefore adoption7156c36

lines 52–54why, one step back
52!!! note
53 Feel free to replace this step with your development environment setup54 (pyenv, pipenv, virtualenvwrapper, docker, etc).

Create a Contributing page in the documentation (#190)Humberto Rochabefore adoption079ab33

line 55why, one step back
55

Add additional info to Contributing Guide (#213)Humberto Rochabefore adoption7156c36

lines 56–61why, one step back
56## Testing and Linting
5758We use [nox](https://nox.thea.codes/en/stable/) to automate testing, linting,59and documentation building workflow. Make sure you have it installed60at your system before starting.61

Fix typos, spelling issues, and grammar in docs (#426)Kyle Galbraithbefore adoptionb65bce5

line 62why, one step back
62Install `nox` with:

Add additional info to Contributing Guide (#213)Humberto Rochabefore adoption7156c36

line 63why, one step back
63

Create a Contributing page in the documentation (#190)Humberto Rochabefore adoption079ab33

lines 64–67why, one step back
64```shell
65$ python3 -m pip install --user nox66```67

Add additional info to Contributing Guide (#213)Humberto Rochabefore adoption7156c36

lines 68–69why, one step back
68Alternatively, use [pipx](https://github.com/pipxproject/pipx) if you prefer
69to keep it into an isolated environment:

Create a Contributing page in the documentation (#190)Humberto Rochabefore adoption079ab33

lines 70–74why, one step back
70
71```shell72$ pipx install nox73```74

Fix typos, spelling issues, and grammar in docs (#426)Kyle Galbraithbefore adoptionb65bce5

line 75why, one step back
75Now, with nox installed, run the complete pipeline with:

Create a Contributing page in the documentation (#190)Humberto Rochabefore adoption079ab33

lines 76–83why, one step back
76
77```shell78$ nox79```8081!!! warning82 The test suite spawns a testing server at the port **8000**.83 Make sure this isn't being used, so the tests can run properly.

Add additional info to Contributing Guide (#213)Humberto Rochabefore adoption7156c36

lines 84–102why, one step back
84
85To run the code auto-formatting separately:8687```shell88$ nox -s lint89```9091Also, if you need to run the tests only:9293```shell94$ nox -s test95```9697You can also run a single test script like this:9899```shell100$ nox -s test -- tests/test_multipart.py101```102

Add test script (#451)Florimond Mancabefore adoption5e4f54d

lines 103–110why, one step back
103Lastly, to ensure you're on track to pass the CI build, run:
104105```shell106$ scripts/test107```108109This command is a light wrapper around `nox` that will run code style checks and test the code against all installed Python versions.110

Add additional info to Contributing Guide (#213)Humberto Rochabefore adoption7156c36

lines 111–112why, one step back
111## Documenting
112

Allow serving docs via nox (#450)Florimond Mancabefore adoption65b8593

line 113why, one step back
113Documentation pages are located under the `docs/` folder.

Add additional info to Contributing Guide (#213)Humberto Rochabefore adoption7156c36

line 114why, one step back
114

Allow serving docs via nox (#450)Florimond Mancabefore adoption65b8593

line 115why, one step back
115To run the documentation site locally (useful for previewing changes), use:

Add additional info to Contributing Guide (#213)Humberto Rochabefore adoption7156c36

lines 116–117why, one step back
116
117```shell

Allow serving docs via nox (#450)Florimond Mancabefore adoption65b8593

line 118why, one step back
118$ nox -s serve

Add additional info to Contributing Guide (#213)Humberto Rochabefore adoption7156c36

line 119why, one step back
119```

Document the release process (#363)Florimond Mancabefore adoption1275246

line 120why, one step back
120

Add hints for debugging CI issues (#399)Seth Michael Larsonbefore adoptiona80c432

lines 121–169why, one step back
121## Resolving Build / Travis Failures
122123Once you've submitted your pull request, the test suite will automatically run, and the results will show up in GitHub.124If the test suite fails, you'll want to click through to the "Details" link, and try to identify why the test suite failed.125126<p align="center" style="margin: 0 0 10px">127 <img src="https://raw.githubusercontent.com/encode/httpx/master/docs/img/travis-fail.png" alt='Failing PR commit status'>128</p>129130Here are some common ways the test suite can fail:131132### NOX_SESSION=check Job Failed133134<p align="center" style="margin: 0 0 10px">135 <img src="https://raw.githubusercontent.com/encode/httpx/master/docs/img/travis-fail-check.png" alt='Failing Travis lint job'>136</p>137138This job failing means there is either a code formatting issue or type-annotation issue.139You can look at the job output to figure out why it's failed or within a shell run:140141`nox -s check`142143It may be worth it to run `nox -s lint` to attempt auto-formatting the code144and if that job succeeds commit the changes.145146### NOX_SESSION=docs Job Failed147148This job failing means the documentation failed to build. This can happen for149a variety of reasons like invalid markdown or missing configuration within `mkdocs.yml`.150151### NOX_SESSION=test-3.X Job Failed152153<p align="center" style="margin: 0 0 10px">154 <img src="https://raw.githubusercontent.com/encode/httpx/master/docs/img/travis-fail-test.png" alt='Failing Travis test job'>155</p>156157This job failing means the unit tests failed or not all code paths are covered by unit tests.158159If tests are failing you will see this message under the coverage report:160161`=== 1 failed, 435 passed, 1 skipped, 1 xfailed in 11.09s ===`162163If tests succeed but coverage isn't 100% you will see this message under the coverage report:164165`FAIL Required test coverage of 100% not reached. Total coverage: 99.00%`166167Look at the [coverage report from codecov](https://codecov.io/gh/encode/httpx/pulls)168for the pull request for help debugging coverage.169

Document the release process (#363)Florimond Mancabefore adoption1275246

lines 170–187why, one step back
170## Releasing
171172*This section is targeted at HTTPX maintainers.*173174Before releasing a new version, create a pull request that includes:175176- **An update to the changelog**:177 - We follow the format from [keepachangelog](https://keepachangelog.com/en/1.0.0/).178 - [Compare](https://github.com/encode/httpx/compare/) `master` with the tag of the latest release, and list all entries that are of interest to our users:179 - Things that **must** go in the changelog: added, changed, deprecated or removed features, and bug fixes.180 - Things that **should not** go in the changelog: changes to documentation, tests or tooling.181 - Try sorting entries in descending order of impact / importance.182 - Keep it concise and to-the-point. 🎯183- **A version bump**: see `__version__.py`.184185For an example, see [#362](https://github.com/encode/httpx/pull/362).186187Once the release PR is merged, run `$ scripts/publish` to publish the new release to PyPI.