diff --git a/.github/maintainers_guide.md b/.github/maintainers_guide.md index f19f3b9..b86b0b9 100644 --- a/.github/maintainers_guide.md +++ b/.github/maintainers_guide.md @@ -84,6 +84,14 @@ This project uses [mypy](https://mypy.readthedocs.io/en/stable/index.html) to ch ./scripts/run_mypy.sh ``` +To clean your virtual environment (useful when testing scripts in isolation): + +```sh +./scripts/uninstall_all.sh +``` + +> **Note**: Several scripts support a `--no-install` flag to prevent redundant dependency installation when scripts call other scripts internally. + #### Develop Locally If you want to test the package locally you can. diff --git a/.gitignore b/.gitignore index 0f1359b..a0a4ac7 100644 --- a/.gitignore +++ b/.gitignore @@ -122,3 +122,8 @@ cython_debug/ # and can be added to the global gitignore or merged into this file. For a more nuclear # option (not recommended) you can uncomment the following to ignore the entire idea folder. .idea/ + +# LLM +.claude/ +.cursor/ + diff --git a/requirements/format.txt b/requirements/dev-tools.txt similarity index 100% rename from requirements/format.txt rename to requirements/dev-tools.txt diff --git a/scripts/_utils.sh b/scripts/_utils.sh deleted file mode 100644 index 73ee0b6..0000000 --- a/scripts/_utils.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash - -set_prj_as_cwd() { - script_dir=`dirname $0` - cd ${script_dir}/.. -} - -clean_project() { - rm -rf dist/ build/ slack_cli_hooks.egg-info/ -} - -install_development_requirements() { - pip install -U pip - pip install -e . - pip install -r requirements/testing.txt - pip install -r requirements/format.txt -} - -build() { - pip install -r requirements/build.txt && \ - python -m build && \ - twine check dist/* -} - -format() { - black slack_cli_hooks/ tests/ -} diff --git a/scripts/build_pypi_package.sh b/scripts/build_pypi_package.sh index 1f6e893..d1f71f7 100755 --- a/scripts/build_pypi_package.sh +++ b/scripts/build_pypi_package.sh @@ -1,8 +1,14 @@ #!/bin/bash -source ./scripts/_utils.sh +script_dir=$(dirname $0) +cd ${script_dir}/.. -set_prj_as_cwd +# Clean previous builds +rm -rf dist/ build/ slack_cli_hooks.egg-info/ -clean_project +# Install build dependencies unless --no-install is specified +if [[ "$1" != "--no-install" ]]; then + pip install -r requirements/build.txt +fi -build +# Build package +python -m build && twine check dist/* diff --git a/scripts/deploy_to_test_pypi.sh b/scripts/deploy_to_test_pypi.sh index 57d2f22..ac0c0e3 100755 --- a/scripts/deploy_to_test_pypi.sh +++ b/scripts/deploy_to_test_pypi.sh @@ -1,10 +1,8 @@ #!/bin/bash -source ./scripts/_utils.sh +script_dir=$(dirname $0) +cd ${script_dir}/.. -set_prj_as_cwd - -clean_project - -build +./scripts/build_pypi_package.sh +# Upload to test PyPI twine upload --repository testpypi dist/* diff --git a/scripts/format.sh b/scripts/format.sh index d0b21ce..dd76af0 100755 --- a/scripts/format.sh +++ b/scripts/format.sh @@ -1,9 +1,11 @@ #!/bin/bash -source ./scripts/_utils.sh +script_dir=$(dirname $0) +cd ${script_dir}/.. -set_prj_as_cwd +# Install dependencies unless --no-install is specified +if [[ "$1" != "--no-install" ]]; then + pip install -U pip + pip install -r requirements/dev-tools.txt +fi -pip install -U pip -pip install -r requirements/format.txt - -format +black slack_cli_hooks/ tests/ diff --git a/scripts/install.sh b/scripts/install.sh index bf45bc9..94284f0 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -1,6 +1,8 @@ #!/bin/bash -source ./scripts/_utils.sh +script_dir=$(dirname $0) +cd ${script_dir}/.. -set_prj_as_cwd - -install_development_requirements +pip install -U pip +pip install -e . +pip install -r requirements/testing.txt +pip install -r requirements/dev-tools.txt diff --git a/scripts/install_and_run_tests.sh b/scripts/install_and_run_tests.sh index e6fdcc2..f77ee0b 100755 --- a/scripts/install_and_run_tests.sh +++ b/scripts/install_and_run_tests.sh @@ -2,19 +2,19 @@ # all: ./scripts/install_and_run_tests.sh # single: ./scripts/install_and_run_tests.sh tests/scenario_tests/test_app.py -test_target="$1" -source ./scripts/_utils.sh - -set_prj_as_cwd +script_dir=$(dirname $0) +cd ${script_dir}/.. -install_development_requirements +test_target="$1" -format +./scripts/install.sh +./scripts/format.sh --no-install +./scripts/lint.sh --no-install -if [[ $test_target != "" ]] -then - pytest -vv $1 +# Run tests +if [[ $test_target != "" ]]; then + pytest -vv $test_target else - pytest && \ - mypy --config-file pyproject.toml + pytest + ./scripts/run_mypy.sh --no-install fi diff --git a/scripts/lint.sh b/scripts/lint.sh index 0f86131..ce1efae 100755 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -1,10 +1,11 @@ #!/bin/bash - -source ./scripts/_utils.sh - -set_prj_as_cwd - -pip install -U pip -pip install -r requirements/format.txt +script_dir=$(dirname $0) +cd ${script_dir}/.. + +# Install dependencies unless --no-install is specified +if [[ "$1" != "--no-install" ]]; then + pip install -U pip + pip install -r requirements/dev-tools.txt +fi flake8 slack_cli_hooks/ && flake8 tests/ diff --git a/scripts/run_mypy.sh b/scripts/run_mypy.sh index 706b3f2..d3c9cde 100755 --- a/scripts/run_mypy.sh +++ b/scripts/run_mypy.sh @@ -1,9 +1,10 @@ #!/bin/bash +script_dir=$(dirname $0) +cd ${script_dir}/.. -source ./scripts/_utils.sh - -set_prj_as_cwd - -install_development_requirements +# Install dependencies unless --no-install is specified +if [[ "$1" != "--no-install" ]]; then + ./scripts/install.sh +fi mypy --config-file pyproject.toml diff --git a/scripts/run_tests.sh b/scripts/run_tests.sh index fd91348..3e64c7d 100755 --- a/scripts/run_tests.sh +++ b/scripts/run_tests.sh @@ -2,16 +2,16 @@ # all: ./scripts/run_tests.sh # single: ./scripts/run_tests.sh tests/scenario_tests/test_app.py -test_target="$1" -source ./scripts/_utils.sh +script_dir=$(dirname $0) +cd ${script_dir}/.. -set_prj_as_cwd +test_target="$1" -format +./scripts/format.sh --no-install -if [[ $test_target != "" ]] -then - pytest -vv $1 +# Run tests +if [[ $test_target != "" ]]; then + pytest -vv $test_target else pytest fi diff --git a/scripts/uninstall_all.sh b/scripts/uninstall_all.sh index 15f5527..9b006b6 100755 --- a/scripts/uninstall_all.sh +++ b/scripts/uninstall_all.sh @@ -1,4 +1,9 @@ #!/bin/bash -pip uninstall -y slack-cli-hooks && \ - pip freeze | grep -v "^-e" | xargs pip uninstall -y +pip uninstall -y slack-cli-hooks + +PACKAGES=$(pip freeze | grep -v "^-e" | sed 's/@.*//' | sed 's/\=\=.*//') + +for package in $PACKAGES; do + pip uninstall -y $package +done