site/
*.egg-info/
venv*/
-.nox
.python-version
only:
- master
+python:
+ - 3.6
+ - 3.7
+ - 3.8
+
+stages:
+ - check
+ - docs
+ - test
+
matrix:
include:
- - python: 3.7
- env: NOX_SESSION=check
- - python: 3.7
- env: NOX_SESSION=docs
-
- - python: 3.6
- env: NOX_SESSION=test-3.6
- - python: 3.7
- env: NOX_SESSION=test-3.7
- - python: 3.8
- env: NOX_SESSION=test-3.8
- dist: bionic # Required to get OpenSSL 1.1.1+
-
- - os: windows
+ -
+ stage: check
+ python: 3.7
+ script: scripts/check
+ - stage: docs
+ python: 3.7
+ script: scripts/docs-build
+ - stage: test
+ os: windows
language: shell
python: 3.7
env:
PATH=/c/Python37:/c/Python37/Scripts:$PATH
- NOX_SESSION=test-3.7
before_install:
- choco install python --version 3.7
- python -m pip install --upgrade pip
+ install: pip install -r requirements.txt
+ script: scripts/test
fast_finish: true
allow_failures:
# Some tests not yet resolved for Windows. (In progress)
- os: windows
-install:
- - pip install --upgrade nox
-
-script:
- - nox -s ${NOX_SESSION}
+script: scripts/test
after_script:
- if [ -f .coverage ]; then
$ git clone https://github.com/YOUR-USERNAME/httpx
```
-With the repository cloned you can access its folder, set up the
-virtual environment, install the project requirements,
-and then install HTTPX on edit mode:
+You can now install the project and its dependencies using:
```shell
$ cd httpx
-$ python3 -m venv venv
-$ source venv/bin/activate
-$ pip install -r test-requirements.txt
-$ pip install -e .
+$ scripts/install
```
-!!! note
- Feel free to replace this step with your development environment setup
- (pyenv, pipenv, virtualenvwrapper, docker, etc).
-
## Testing and Linting
-We use [nox](https://nox.thea.codes/en/stable/) to automate testing, linting,
-and documentation building workflow. Make sure you have it installed
-at your system before starting.
-
-Install `nox` with:
-
-```shell
-$ python3 -m pip install --user nox
-```
-
-Alternatively, use [pipx](https://github.com/pipxproject/pipx) if you prefer
-to keep it into an isolated environment:
-
-```shell
-$ pipx install nox
-```
+We use custom shell scripts to automate testing, linting,
+and documentation building workflow.
-Now, with nox installed, run the complete pipeline with:
+To run the tests, use:
```shell
-$ nox
+$ scripts/test
```
!!! warning
- The test suite spawns a testing server at the port **8000**.
- Make sure this isn't being used, so the tests can run properly.
+ The test suite spawns testing servers on ports **8000** and **8001**.
+ Make sure these are not in use, so the tests can run properly.
-To run the code auto-formatting separately:
+You can run a single test script like this:
```shell
-$ nox -s lint
+$ scripts/test -- tests/test_multipart.py
```
-Also, if you need to run the tests only:
+To run the code auto-formatting:
```shell
-$ nox -s test
+$ scripts/lint
```
-You can also run a single test script like this:
+Lastly, to run code checks separately (they are also run as part of `scripts/test`), run:
```shell
-$ nox -s test -- tests/test_multipart.py
+$ scripts/check
```
-Lastly, to ensure you're on track to pass the CI build, run:
-
-```shell
-$ scripts/test
-```
-
-This command is a light wrapper around `nox` that will run code style checks and test the code against all installed Python versions.
-
## Documenting
Documentation pages are located under the `docs/` folder.
To run the documentation site locally (useful for previewing changes), use:
```shell
-$ nox -s serve
+$ scripts/docs-serve
```
## Resolving Build / Travis Failures
Here are some common ways the test suite can fail:
-### NOX_SESSION=check Job Failed
+### Check Job Failed
<p align="center" style="margin: 0 0 10px">
<img src="https://raw.githubusercontent.com/encode/httpx/master/docs/img/travis-fail-check.png" alt='Failing Travis lint job'>
This job failing means there is either a code formatting issue or type-annotation issue.
You can look at the job output to figure out why it's failed or within a shell run:
-`nox -s check`
+```shell
+$ scripts/check
+```
-It may be worth it to run `nox -s lint` to attempt auto-formatting the code
+It may be worth it to run `$ scripts/lint` to attempt auto-formatting the code
and if that job succeeds commit the changes.
-### NOX_SESSION=docs Job Failed
+### Docs Job Failed
This job failing means the documentation failed to build. This can happen for
a variety of reasons like invalid markdown or missing configuration within `mkdocs.yml`.
-### NOX_SESSION=test-3.X Job Failed
+### Python 3.X Job Failed
<p align="center" style="margin: 0 0 10px">
<img src="https://raw.githubusercontent.com/encode/httpx/master/docs/img/travis-fail-test.png" alt='Failing Travis test job'>
+++ /dev/null
-import nox
-
-nox.options.stop_on_first_error = True
-nox.options.reuse_existing_virtualenvs = True
-nox.options.keywords = "not serve"
-
-source_files = ("httpx", "tools", "tests", "setup.py", "noxfile.py")
-
-
-@nox.session
-def lint(session):
- session.install(
- "--upgrade", "autoflake", "black", "flake8", "isort", "seed-isort-config"
- )
-
- session.run("autoflake", "--in-place", "--recursive", *source_files)
- session.run("seed-isort-config", "--application-directories=httpx")
- session.run("isort", "--project=httpx", "--recursive", "--apply", *source_files)
- session.run("black", "--target-version=py36", *source_files)
-
- check(session)
-
-
-@nox.session
-def check(session):
- session.install(
- "--upgrade", "black", "flake8", "flake8-bugbear", "flake8-pie", "isort", "mypy"
- )
-
- session.run("black", "--check", "--diff", "--target-version=py36", *source_files)
- session.run("flake8", *source_files)
- session.run("mypy", "httpx")
- session.run(
- "isort", "--check", "--diff", "--project=httpx", "--recursive", *source_files
- )
-
-
-@nox.session
-def docs(session):
- session.install("--upgrade", "mkdocs", "mkdocs-material", "mkautodoc>=0.1.0")
- session.install("-e", ".")
- session.run("mkdocs", "build")
-
-
-@nox.session(reuse_venv=True)
-def serve(session):
- session.install("--upgrade", "mkdocs", "mkdocs-material")
-
- session.run("mkdocs", "serve")
-
-
-@nox.session(python=["3.6", "3.7", "3.8"])
-def test(session):
- session.install("--upgrade", "-r", "test-requirements.txt")
- session.run("python", "-m", "pytest", *session.posargs)
# Optional
brotlipy==0.7.*
+autoflake
+black
cryptography
flake8
flake8-bugbear
flake8-pie
isort
+mkdocs
+mkautodoc
+mkdocs-material
mypy
pytest
pytest-asyncio
trio
trustme
uvicorn
+seed-isort-config
+
+attrs>=19.2 # See: https://github.com/encode/httpx/pull/566#issuecomment-559862665
--- /dev/null
+#!/bin/sh -e
+
+export PREFIX=""
+if [ -d 'venv' ] ; then
+ export PREFIX="venv/bin/"
+fi
+export SOURCE_FILES="httpx tests"
+
+set -x
+
+${PREFIX}black --check --diff --target-version=py36 $SOURCE_FILES
+${PREFIX}flake8 $SOURCE_FILES
+${PREFIX}mypy httpx
+${PREFIX}isort --check --diff --project=httpx --recursive $SOURCE_FILES
--- /dev/null
+#!/bin/sh -e
+
+export PREFIX=""
+if [ -d 'venv' ] ; then
+ export PREFIX="venv/bin/"
+fi
+
+set -x
+
+${PREFIX}mkdocs build
--- /dev/null
+#!/bin/sh -e
+
+export PREFIX=""
+if [ -d 'venv' ] ; then
+ export PREFIX="venv/bin/"
+fi
+
+set -x
+
+${PREFIX}mkdocs serve
--- /dev/null
+#!/bin/sh -e
+
+export PREFIX="venv/bin/"
+
+set -x
+
+python -m venv venv
+${PREFIX}python -m pip install -U pip
+${PREFIX}python -m pip install -r requirements.txt
+
+set +x
+
+echo
+echo "Success! You can now activate your virtual environment using:"
+echo "source ${PREFIX}activate"
--- /dev/null
+#!/bin/sh -e
+
+export PREFIX=""
+if [ -d 'venv' ] ; then
+ export PREFIX="venv/bin/"
+fi
+export SOURCE_FILES="httpx tests"
+
+set -x
+
+${PREFIX}autoflake --in-place --recursive $SOURCE_FILES
+${PREFIX}seed-isort-config --application-directories=httpx
+${PREFIX}isort --project=httpx --recursive --apply $SOURCE_FILES
+${PREFIX}black --target-version=py36 $SOURCE_FILES
#!/bin/sh -e
+export PREFIX=""
+if [ -d 'venv' ] ; then
+ export PREFIX="venv/bin/"
+fi
+
set -x
-nox -s check
-nox -s test
+if [ -z $CI ]; then
+ scripts/check
+fi
+
+${PREFIX}pytest $@
force_grid_wrap = 0
include_trailing_comma = True
known_first_party = httpx,httpxprof,tests
-known_third_party = brotli,certifi,chardet,click,cryptography,h11,h2,hstspreload,nox,pytest,requests,rfc3986,setuptools,tqdm,trio,trustme,uvicorn
+known_third_party = brotli,certifi,chardet,click,cryptography,h11,h2,hstspreload,pytest,rfc3986,setuptools,tqdm,trio,trustme,uvicorn
line_length = 88
multi_line_output = 3