Drop nox in favor of vanilla scripts (#566)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
* Drop nox in favor of vanilla scripts * Use named stages * Fix attrs dependency resolution madness * Add missing mkautodoc dev dependency * Add missing install step on windows build * Explicitly define stage order so that timed out Windows build runs last * Add missing dev dependency on Black * Clean up contributing guide * Separate docs into docs-build and docs-serve
authored by Florimond Manca · committed by Tom Christie · parent 3218c35 · Browse files · 13 files·+144 added−148 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
13 files+144 added−148 removed
- other:+144 added−148 removed
Provenance
- Commit
8d55d78- Tree
f1c63b5- Author
Florimond Manca <florimond.manca@gmail.com>- Committer
Tom Christie <tom@tomchristie.com>- Parent
3218c35
13 files changed+144 added−148 removed
modified:docs/contributing.md+22 added-51 removed
35 unmodified lines36373839404142404142434647484944454652535455474858596049505162525354655556576869707172737475767778798058828359606185626364886566679168697094717273977475761007778791031041051061071081091108081828384858611887888990915 unmodified lines97989910013210110210310410510610710810914111011111211314311411511614611711811912012115112212312412512632 unmodified lines35 unmodified lines```shell$ git clone https://github.com/YOUR-USERNAME/httpx```
With the repository cloned you can access its folder, set up thevirtual 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 installedat your system before starting.We use custom shell scripts to automate testing, linting,and documentation building workflow.
Install `nox` with:To run the tests, use:
```shell$ python3 -m pip install --user nox$ scripts/test```
Alternatively, use [pipx](https://github.com/pipxproject/pipx) if you preferto keep it into an isolated environment:
```shell$ pipx install nox```
Now, with nox installed, run the complete pipeline with:
```shell$ nox```
!!! 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
5 unmodified lines</p>
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'></p>
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 codeIt may be worth it to run `$ scripts/lint` to attempt auto-formatting the codeand 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 fora 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'></p>32 unmodified linesadded:scripts/check+14 added
1+#!/bin/sh -e2+3+export PREFIX=""4+if [ -d 'venv' ] ; then5+ export PREFIX="venv/bin/"6+fi7+export SOURCE_FILES="httpx tests"8+9+set -x10+11+${PREFIX}black --check --diff --target-version=py36 $SOURCE_FILES12+${PREFIX}flake8 $SOURCE_FILES13+${PREFIX}mypy httpx14+${PREFIX}isort --check --diff --project=httpx --recursive $SOURCE_FILESadded:scripts/docs-build+10 added
1+#!/bin/sh -e2+3+export PREFIX=""4+if [ -d 'venv' ] ; then5+ export PREFIX="venv/bin/"6+fi7+8+set -x9+10+${PREFIX}mkdocs buildadded:scripts/docs-serve+10 added
1+#!/bin/sh -e2+3+export PREFIX=""4+if [ -d 'venv' ] ; then5+ export PREFIX="venv/bin/"6+fi7+8+set -x9+10+${PREFIX}mkdocs serveadded:scripts/install+15 added
1+#!/bin/sh -e2+3+export PREFIX="venv/bin/"4+5+set -x6+7+python -m venv venv8+${PREFIX}python -m pip install -U pip9+${PREFIX}python -m pip install -r requirements.txt10+11+set +x12+13+echo14+echo "Success! You can now activate your virtual environment using:"15+echo "source ${PREFIX}activate"added:scripts/lint+14 added
1+#!/bin/sh -e2+3+export PREFIX=""4+if [ -d 'venv' ] ; then5+ export PREFIX="venv/bin/"6+fi7+export SOURCE_FILES="httpx tests"8+9+set -x10+11+${PREFIX}autoflake --in-place --recursive $SOURCE_FILES12+${PREFIX}seed-isort-config --application-directories=httpx13+${PREFIX}isort --project=httpx --recursive --apply $SOURCE_FILES14+${PREFIX}black --target-version=py36 $SOURCE_FILESmodified:scripts/test+10 added-2 removed
1 #!/bin/sh -e2 3+export PREFIX=""4+if [ -d 'venv' ] ; then5+ export PREFIX="venv/bin/"6+fi7+8 set -x9 5-nox -s check6-nox -s test10+if [ -z $CI ]; then11+ scripts/check12+fi13+14+${PREFIX}pytest $@modified:.gitignore-1 removed
5 unmodified lines6 htmlcov/7 site/8 *.egg-info/9 venv*/10-.nox10 .python-versionmodified:.travis.yml+22 added-20 removed
5 unmodified lines6 branches:7 only:8 - master9 10-matrix:11- include:12- - python: 3.713- env: NOX_SESSION=check14- - python: 3.715- env: NOX_SESSION=docs10+python:11+ - 3.612+ - 3.713+ - 3.814 17- - python: 3.618- env: NOX_SESSION=test-3.619- - python: 3.720- env: NOX_SESSION=test-3.721- - python: 3.822- env: NOX_SESSION=test-3.823- dist: bionic # Required to get OpenSSL 1.1.1+15+stages:16+ - check17+ - docs18+ - test19 20+matrix:21+ include:22+ -23+ stage: check24+ python: 3.725+ script: scripts/check26+ - stage: docs27+ python: 3.728+ script: scripts/docs-build29+ - stage: test25- - os: windows30+ os: windows31 language: shell32 python: 3.733 env:34 PATH=/c/Python37:/c/Python37/Scripts:$PATH30- NOX_SESSION=test-3.735 before_install:36 - choco install python --version 3.737 - python -m pip install --upgrade pip38+ install: pip install -r requirements.txt39+ script: scripts/test40 41 fast_finish: true42 allow_failures:43 # FIX44 # Some tests not yet resolved for Windows. (In progress)45 - os: windows46 41-install:42- - pip install --upgrade nox47+script: scripts/test48 44-script:45- - nox -s ${NOX_SESSION}46-49 after_script:50 - if [ -f .coverage ]; then51 python -m pip install codecov;52 codecov --required;1 unmodified linedeleted:noxfile.py-55 removed
1-import nox2-3-nox.options.stop_on_first_error = True4-nox.options.reuse_existing_virtualenvs = True5-nox.options.keywords = "not serve"6-7-source_files = ("httpx", "tools", "tests", "setup.py", "noxfile.py")8-9-10-@nox.session11-def lint(session):12- session.install(13- "--upgrade", "autoflake", "black", "flake8", "isort", "seed-isort-config"14- )15-16- session.run("autoflake", "--in-place", "--recursive", *source_files)17- session.run("seed-isort-config", "--application-directories=httpx")18- session.run("isort", "--project=httpx", "--recursive", "--apply", *source_files)19- session.run("black", "--target-version=py36", *source_files)20-21- check(session)22-23-24-@nox.session25-def check(session):26- session.install(27- "--upgrade", "black", "flake8", "flake8-bugbear", "flake8-pie", "isort", "mypy"28- )29-30- session.run("black", "--check", "--diff", "--target-version=py36", *source_files)31- session.run("flake8", *source_files)32- session.run("mypy", "httpx")33- session.run(34- "isort", "--check", "--diff", "--project=httpx", "--recursive", *source_files35- )36-37-38-@nox.session39-def docs(session):40- session.install("--upgrade", "mkdocs", "mkdocs-material", "mkautodoc>=0.1.0")41- session.install("-e", ".")42- session.run("mkdocs", "build")43-44-45-@nox.session(reuse_venv=True)46-def serve(session):47- session.install("--upgrade", "mkdocs", "mkdocs-material")48-49- session.run("mkdocs", "serve")50-51-52-@nox.session(python=["3.6", "3.7", "3.8"])53-def test(session):54- session.install("--upgrade", "-r", "test-requirements.txt")55- session.run("python", "-m", "pytest", *session.posargs)added:requirements.txt+26 added
1+-e .2+3+# Optional4+brotlipy==0.7.*5+6+autoflake7+black8+cryptography9+flake810+flake8-bugbear11+flake8-pie12+isort13+mkdocs14+mkautodoc15+mkdocs-material16+mypy17+pytest18+pytest-asyncio19+pytest-trio20+pytest-cov21+trio22+trustme23+uvicorn24+seed-isort-config25+26+attrs>=19.2 # See: https://github.com/encode/httpx/pull/566#issuecomment-559862665modified:setup.cfg+1 added-1 removed
12 unmodified lines13 combine_as_imports = True14 force_grid_wrap = 015 include_trailing_comma = True16 known_first_party = httpx,httpxprof,tests17-known_third_party = brotli,certifi,chardet,click,cryptography,h11,h2,hstspreload,nox,pytest,requests,rfc3986,setuptools,tqdm,trio,trustme,uvicorn17+known_third_party = brotli,certifi,chardet,click,cryptography,h11,h2,hstspreload,pytest,rfc3986,setuptools,tqdm,trio,trustme,uvicorn18 line_length = 8819 multi_line_output = 320 21 [tool:pytest]3 unmodified linesdeleted:test-requirements.txt-18 removed
1--e .2-3-# Optional4-brotlipy==0.7.*5-6-cryptography7-flake88-flake8-bugbear9-flake8-pie10-isort11-mypy12-pytest13-pytest-asyncio14-pytest-trio15-pytest-cov16-trio17-trustme18-uvicorn