Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added helper script to run multiple tox environments #2763

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
31 changes: 31 additions & 0 deletions scripts/runtox.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash
#
# Usage:
# ./scripts/runtox.sh py312 <pytest-args>
#
# 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}"
Loading