diff --git a/{{cookiecutter.project_slug}}/scripts/bootstrap.sh b/{{cookiecutter.project_slug}}/scripts/bootstrap.sh index 8a0f4b6..0019db8 100755 --- a/{{cookiecutter.project_slug}}/scripts/bootstrap.sh +++ b/{{cookiecutter.project_slug}}/scripts/bootstrap.sh @@ -16,8 +16,17 @@ source "$(dirname "$0")/_common.sh" function project_bootstrap() { _setup_env 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 } diff --git a/{{cookiecutter.project_slug}}/scripts/run_linters.sh b/{{cookiecutter.project_slug}}/scripts/run_linters.sh new file mode 100755 index 0000000..1659177 --- /dev/null +++ b/{{cookiecutter.project_slug}}/scripts/run_linters.sh @@ -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" diff --git a/{{cookiecutter.project_slug}}/scripts/run_unit_tests.sh b/{{cookiecutter.project_slug}}/scripts/run_unit_tests.sh index 7ca34c3..d0ba374 100755 --- a/{{cookiecutter.project_slug}}/scripts/run_unit_tests.sh +++ b/{{cookiecutter.project_slug}}/scripts/run_unit_tests.sh @@ -9,4 +9,4 @@ if [ "${DRONE}" == "true" ]; then pip install -r requirements.txt -r dev-requirements.txt fi -exec "${VIRTUAL_ENV}/bin/python" -m pytest -vv --cov "$@" +exec "${VIRTUAL_ENV}/bin/python3" -m pytest -vv --cov "$@"