#!/usr/bin/env bash set -euo pipefail install_deps_dev() { python -m pip install --upgrade pip pip install -e .[test] if [ -f requirements.txt ]; then pip install -r requirements.txt; fi if [ -f docs/requirements.txt ]; then pip install -r docs/requirements.txt; fi if [ -f examples/requirements.txt ]; then pip install -r examples/requirements.txt; fi } unit_tests() { pytest --pspec tests/unit } integ_tests() { pytest --pspec tests/integration } lint() { echo "" echo "Lint checks" echo -e "===========\n" echo "1. pre-commit hooks" echo "===================" pre-commit run -v -a echo "" echo "2. Flake8" echo "=========" flake8 . --count --show-source --statistics echo "" echo "3. Mypy" echo "=======" mypy --junit-xml reports/typecheck.xml --html-report reports --config-file setup.cfg src/ echo "" echo "Lint: SUCCESS" } test_with_coverage() { scripts/run_examples.py coverage run -m pytest --pspec tests/unit coverage report -m --fail-under=88 } docs() { cd docs make html } create_commit_hash_file(){ if [[ -z "${CODEBUILD_RESOLVED_SOURCE_VERSION:-}" ]]; then echo $(git rev-parse HEAD) > src/smclarify/COMMIT_HASH else echo "${CODEBUILD_RESOLVED_SOURCE_VERSION}" > src/smclarify/COMMIT_HASH fi } build_package() { create_commit_hash_file python3 setup.py bdist_wheel rm src/smclarify/COMMIT_HASH } install_package(){ wheel_name=$(ls -t dist | head -n 1) pip install --upgrade dist/$wheel_name } all() { lint test_with_coverage build_package docs } ############################################################## # MAIN # # Run function passed as argument set +x if [ $# -gt 0 ] then SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" echo "CD -> $SCRIPTPATH" cd $SCRIPTPATH $@ else cat<