Update scripts for better env setup and linting

pull/3/head
Drew Bednar 1 year ago
parent 1d544043f8
commit f72e0082d8

@ -16,8 +16,17 @@ source "$(dirname "$0")/_common.sh"
function project_bootstrap() { function project_bootstrap() {
_setup_env _setup_env
pip install -U pip pip-tools=='7.3.0' pip install -U pip pip-tools=='7.3.0'
pip-compile requirements.in
pip-compile dev-requirements.in # Check if requirements.txt exists, if not, compile it from requirements.in
if [ ! -f requirements.txt ]; then
pip-compile requirements.in
fi
# Check if dev-requirements.txt exists, if not, compile it from dev-requirements.in
if [ ! -f dev-requirements.txt ]; then
pip-compile dev-requirements.in
fi
pip-sync requirements.txt dev-requirements.txt pip-sync requirements.txt dev-requirements.txt
} }

@ -0,0 +1,28 @@
#! /usr/bin/env bash
# shellcheck source=/dev/null
source "$(dirname "$0")/_common.sh"
if [ "${DRONE}" == "true" ]; then
_setup_env
pip install -r requirements.txt -r dev-requirements.txt
fi
# Run linting commands and capture their return codes
"${VIRTUAL_ENV}/bin/python3" -m isort --check ./speech_collect ./tests ./tasks.py
ISORT_EXIT_CODE=$?
"${VIRTUAL_ENV}/bin/python3" -m black --check ./speech_collect ./tests ./tasks.py
BLACK_EXIT_CODE=$?
"${VIRTUAL_ENV}/bin/python3" -m ruff ./speech_collect ./tests ./tasks.py
RUFF_EXIT_CODE=$?
# Check if any linting command failed
if [ $ISORT_EXIT_CODE -ne 0 ] || [ $BLACK_EXIT_CODE -ne 0 ] || [ $RUFF_EXIT_CODE -ne 0 ]; then
echo "Some linting checks failed"
# Exit with a non-zero status, you can choose which error code to return
exit 1
fi
echo "All linting checks passed"

@ -9,4 +9,4 @@ if [ "${DRONE}" == "true" ]; then
pip install -r requirements.txt -r dev-requirements.txt pip install -r requirements.txt -r dev-requirements.txt
fi fi
exec "${VIRTUAL_ENV}/bin/python" -m pytest -vv --cov "$@" exec "${VIRTUAL_ENV}/bin/python3" -m pytest -vv --cov "$@"

Loading…
Cancel
Save