From 30031c27fd915d8a842d6856c5747914b5a0d31f Mon Sep 17 00:00:00 2001 From: Anton Pirker Date: Wed, 31 Jul 2024 16:27:46 +0200 Subject: [PATCH 1/2] Added helper script to run multiple tox environments --- CONTRIBUTING.md | 5 +++++ scripts/runtox.sh | 31 +++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100755 scripts/runtox.sh diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8ab75ce1c6..6e0d27159d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -68,6 +68,11 @@ You can run `tox` with the following arguments: * `tox -e spellcheck` to run a spellcheck on all the code * `tox -e lint-some-package` to run lint checks on `some-package` +There is a helper script `./scripts/runtox.sh` for running multiple tox environments in one command: + +- `./scripts/runtox.sh fastapi` will run all `tox` environments containing the string `"fastapi"` (useful to run one environment in all Python versions) +- `./scripts/runtox.sh py312` will run all `tox` environments containing the string `"py312"` (useful to run all environments in one Python version) + `black` and `isort` are executed when `tox -e lint` is run. The reported errors can be tedious to fix manually. An easier way to do so is: diff --git a/scripts/runtox.sh b/scripts/runtox.sh new file mode 100755 index 0000000000..1e8fc00e66 --- /dev/null +++ b/scripts/runtox.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash +# +# Usage: +# ./scripts/runtox.sh py312 +# +# Runs all environments with substring "py312" and the given arguments for pytest +# + +# Print commands and exit on first error +set -ex + +# Find the right tox executable +if [ -n "$TOXPATH" ]; then + true +elif which tox &> /dev/null; then + TOXPATH=tox +else + TOXPATH=./.venv/bin/tox +fi + +# Find the environments matching the searchstring +searchstring="$1" +ENV="$($TOXPATH -l | grep -- "$searchstring" | tr $'\n' ',')" + +if [ -z "${ENV}" ]; then + echo "No targets found. Skipping." + exit 0 +fi + +# Run tox with all matching environments +exec $TOXPATH -e "$ENV" -- "${@:2}" From a6906b5866e95a0aa9c670a7caf4eeb989882f41 Mon Sep 17 00:00:00 2001 From: Anton Pirker Date: Wed, 31 Jul 2024 16:27:46 +0200 Subject: [PATCH 2/2] Added helper script to run multiple tox environments --- CONTRIBUTING.md | 5 +++++ scripts/runtox.sh | 31 +++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100755 scripts/runtox.sh diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 302e2e7481..cc8e7ed8e9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -68,6 +68,11 @@ You can run `tox` with the following arguments: * `tox -e spellcheck` to run a spellcheck on all the code * `tox -e lint-some-package` to run lint checks on `some-package` +There is a helper script `./scripts/runtox.sh` for running multiple tox environments in one command: + +- `./scripts/runtox.sh fastapi` will run all `tox` environments containing the string `"fastapi"` (useful to run one environment in all Python versions) +- `./scripts/runtox.sh py312` will run all `tox` environments containing the string `"py312"` (useful to run all environments in one Python version) + `black` and `isort` are executed when `tox -e lint` is run. The reported errors can be tedious to fix manually. An easier way to do so is: diff --git a/scripts/runtox.sh b/scripts/runtox.sh new file mode 100755 index 0000000000..1e8fc00e66 --- /dev/null +++ b/scripts/runtox.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash +# +# Usage: +# ./scripts/runtox.sh py312 +# +# Runs all environments with substring "py312" and the given arguments for pytest +# + +# Print commands and exit on first error +set -ex + +# Find the right tox executable +if [ -n "$TOXPATH" ]; then + true +elif which tox &> /dev/null; then + TOXPATH=tox +else + TOXPATH=./.venv/bin/tox +fi + +# Find the environments matching the searchstring +searchstring="$1" +ENV="$($TOXPATH -l | grep -- "$searchstring" | tr $'\n' ',')" + +if [ -z "${ENV}" ]; then + echo "No targets found. Skipping." + exit 0 +fi + +# Run tox with all matching environments +exec $TOXPATH -e "$ENV" -- "${@:2}"