]> git.ipfire.org Git - thirdparty/httpx.git/commitdiff
Drop nox in favor of vanilla scripts (#566)
authorFlorimond Manca <florimond.manca@gmail.com>
Sat, 30 Nov 2019 11:50:13 +0000 (12:50 +0100)
committerTom Christie <tom@tomchristie.com>
Sat, 30 Nov 2019 11:50:13 +0000 (11:50 +0000)
* 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

12 files changed:
.gitignore
.travis.yml
docs/contributing.md
noxfile.py [deleted file]
requirements.txt [moved from test-requirements.txt with 50% similarity]
scripts/check [new file with mode: 0755]
scripts/docs-build [new file with mode: 0755]
scripts/docs-serve [new file with mode: 0755]
scripts/install [new file with mode: 0755]
scripts/lint [new file with mode: 0755]
scripts/test
setup.cfg

index 4c57b08ca90b4d49b750710c495f86fe6cd8661c..22e1fbfeba8dc48ed6ba0a76f37ad44ed897a6a2 100644 (file)
@@ -7,5 +7,4 @@ htmlcov/
 site/
 *.egg-info/
 venv*/
-.nox
 .python-version
index 9a872a4ea5816e675c1e25d7aef5817ad4027d02..9b0efbcad7e41798719e810162843bbca99699f5 100644 (file)
@@ -7,30 +7,36 @@ branches:
   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:
@@ -38,11 +44,7 @@ matrix:
     # 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
index 7b745073469836b480c1992282e12cae98af77cd..e2f149a6934248a1b706ebb68c35b269897b211f 100644 (file)
@@ -37,77 +37,46 @@ your GitHub username:
 $ 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.
@@ -115,7 +84,7 @@ 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
@@ -129,7 +98,7 @@ If the test suite fails, you'll want to click through to the "Details" link, and
 
 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'>
@@ -138,17 +107,19 @@ Here are some common ways the test suite can fail:
 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'>
diff --git a/noxfile.py b/noxfile.py
deleted file mode 100644 (file)
index 43494b5..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-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)
similarity index 50%
rename from test-requirements.txt
rename to requirements.txt
index 96437e0c3dd22ca068183268d440e407f10eb034..056a393f2c4b5257753427fde6b3689b765a4705 100644 (file)
@@ -3,11 +3,16 @@
 # Optional
 brotlipy==0.7.*
 
+autoflake
+black
 cryptography
 flake8
 flake8-bugbear
 flake8-pie
 isort
+mkdocs
+mkautodoc
+mkdocs-material
 mypy
 pytest
 pytest-asyncio
@@ -16,3 +21,6 @@ pytest-cov
 trio
 trustme
 uvicorn
+seed-isort-config
+
+attrs>=19.2  # See: https://github.com/encode/httpx/pull/566#issuecomment-559862665
diff --git a/scripts/check b/scripts/check
new file mode 100755 (executable)
index 0000000..f25b220
--- /dev/null
@@ -0,0 +1,14 @@
+#!/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
diff --git a/scripts/docs-build b/scripts/docs-build
new file mode 100755 (executable)
index 0000000..a6b9297
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/sh -e
+
+export PREFIX=""
+if [ -d 'venv' ] ; then
+    export PREFIX="venv/bin/"
+fi
+
+set -x
+
+${PREFIX}mkdocs build
diff --git a/scripts/docs-serve b/scripts/docs-serve
new file mode 100755 (executable)
index 0000000..4ac3beb
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/sh -e
+
+export PREFIX=""
+if [ -d 'venv' ] ; then
+    export PREFIX="venv/bin/"
+fi
+
+set -x
+
+${PREFIX}mkdocs serve
diff --git a/scripts/install b/scripts/install
new file mode 100755 (executable)
index 0000000..7e6a38f
--- /dev/null
@@ -0,0 +1,15 @@
+#!/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"
diff --git a/scripts/lint b/scripts/lint
new file mode 100755 (executable)
index 0000000..5141cca
--- /dev/null
@@ -0,0 +1,14 @@
+#!/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
index 5b8e09407c7bd36725eed61207ad7dc49937f412..6f781f7bd511af69a73819eb93ac74c831685106 100755 (executable)
@@ -1,6 +1,14 @@
 #!/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 $@
index 9b77116701c6de6d3fdc27d18ecd8638dda0363e..d75cf544004dbb4260226b40f608e849b15f0c14 100644 (file)
--- a/setup.cfg
+++ b/setup.cfg
@@ -14,7 +14,7 @@ combine_as_imports = True
 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