Repository: encode/httpx

Issue:
scripts as a single top-level point of project automation.
Generally across the `encode` projects I've been using [GitHub's "Scripts to Rule Them All" pattern](https://github.blog/2015-06-30-scripts-to-rule-them-all/) as a consistent style for project testing, linting, publishing etc...

It's benenficial from my POV, because it ends up that we can always just run `scripts/install`, or `scripts/test` from *any* project and expect that to perform the same kind of thing, even if we're using different tooling between projects. (eg. started adopting `nox` in some places, but not yet there accross the board.)

I'd like to do the same with `httpx`, while still keeping the niceness of `nox` (So eg. reintroduce a `scripts/test`, `scripts/lint` and `scripts/publish`.) but figure it's worth raising this for discussion first.

I'd also be quite keen on having a fast-feedback test suite being the default, with nox's run against multiple environments as an explicit case?

Any general thoughts here or should I just dive in and take a crack at this?


Discussion:
Sharing my personal workflow here:

I'd say the `scripts/install` and `scripts/lint` scripts are rather straightforward and would be very helpful to have.

As for tests, I've been running `$ pytest` instead of nox to run tests against my virtual environment. Nox is too heavy for quick feedback, but running a complete pytest suite is moderately cheap (~15s). I also sometimes filter tests based on which ones I'm trying to get to pass, e.g. `pytest -k "test_something"` or `pytest tests/test_foo.py`.

So not sure whether `scripts/test` should default to `pytest`, or if it should also forward extra args for finer control?
We can add `session.posargs` to the `test` nox session so that you can be narrower in your test executions. :)

I have no issue with having the extra scripts, I didn't realize it was an encode org-wide thing.
> I have no issue with having the extra scripts, I didn't realize it was an encode org-wide thing.

Totally not a problem - I think `nox` is a fantastic addition here, so not a big issue having to do a bit of rejigging to get there.

Resolving patch:
diff --git a/noxfile.py b/noxfile.py
deleted file mode 100644
--- a/noxfile.py
+++ /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)


Test patch:
diff --git a/scripts/test b/scripts/test
--- a/scripts/test
+++ b/scripts/test
@@ -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 $@