From f1c834f614fff24cb7a67e7bc7f6a1aad362860c Mon Sep 17 00:00:00 2001 From: Kurt McKee Date: Tue, 29 Mar 2022 16:46:56 -0500 Subject: [PATCH 1/2] Move lint tests to their own tox environments In this model, linters are only run once. --- tox.ini | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/tox.ini b/tox.ini index 502c677a83..ae06dac9eb 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,9 @@ [tox] -envlist = py{36,37,38,39,310} +envlist = + flake8 + black + mypy + py{36,37,38,39,310} [flake8] extend-exclude = build,examples/issue_*.py,src/readthedocs-sphinx-search/ @@ -11,24 +15,29 @@ per-file-ignores = [testenv] deps = codecov - flake8 mock retry pyquery cryptography - black==22.3.0 - mypy allowlist_externals = bash timeout grep commands = - flake8 . --count --show-source --statistics coverage run -m unittest discover [] - black --check . - mypy locust/ bash -ec 'PYTHONUNBUFFERED=1 timeout 2s python3 examples/debugging.py >out.txt 2>err.txt || true' grep -qm 1 '/hello' out.txt bash -ec '! grep . err.txt' # should be empty bash -ec 'PYTHONUNBUFFERED=1 python3 examples/debugging_advanced.py | grep done' +[testenv:black] +deps = black==22.3.0 +commands = black --check . + +[testenv:flake8] +deps = flake8 +commands = flake8 . --count --show-source --statistics + +[testenv:mypy] +deps = mypy +commands = mypy locust/ From bae85d91196f00e9bab7d616b4b1b06decf60889 Mon Sep 17 00:00:00 2001 From: Kurt McKee Date: Wed, 30 Mar 2022 06:29:20 -0500 Subject: [PATCH 2/2] Run the linters in GitHub Actions --- .github/workflows/tests.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e81e78d580..a6f437ea29 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,6 +14,9 @@ jobs: #- {name: Linux, python: '3.9', os: ubuntu-latest, tox: py39} #- {name: Windows, python: '3.9', os: windows-latest, tox: py39} #- {name: Mac, python: '3.9', os: macos-latest, tox: py39} + - { name: "flake8", python: "3.10", os: ubuntu-latest, tox: "flake8" } + - { name: "black", python: "3.10", os: ubuntu-latest, tox: "black" } + - { name: "mypy", python: "3.10", os: ubuntu-latest, tox: "mypy" } - { name: "3.10", python: "3.10", os: ubuntu-latest, tox: py310 } - { name: "3.9", python: "3.9", os: ubuntu-latest, tox: py39 } - { name: "3.8", python: "3.8", os: ubuntu-latest, tox: py38 }