give run_pyl a pre-commit type mode where it checks to see what you changed before running checks
This commit is contained in:
parent
cb41cf7cc7
commit
0c1a1cd0d7
|
@ -0,0 +1,11 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
function error_handler() {
|
||||||
|
>&2 echo "Exited with BAD EXIT CODE '${2}' in ${0} script at line: ${1}."
|
||||||
|
exit "$2"
|
||||||
|
}
|
||||||
|
trap 'error_handler ${LINENO} $?' ERR
|
||||||
|
set -o errtrace -o errexit -o nounset -o pipefail
|
||||||
|
|
||||||
|
script_dir="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
|
||||||
|
"${script_dir}/run_pyl" pre
|
50
bin/run_pyl
50
bin/run_pyl
|
@ -16,6 +16,17 @@ react_projects=(
|
||||||
spiffworkflow-frontend
|
spiffworkflow-frontend
|
||||||
)
|
)
|
||||||
|
|
||||||
|
subcommand="${1:-}"
|
||||||
|
|
||||||
|
if [[ "$subcommand" == "pre" ]]; then
|
||||||
|
if [[ -n "$(git status --porcelain SpiffWorkflow)" ]]; then
|
||||||
|
echo "SpiffWorkflow has uncommitted changes. Running its test suite."
|
||||||
|
pushd SpiffWorkflow
|
||||||
|
make tests-par # run tests in parallel
|
||||||
|
popd
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
function get_python_dirs() {
|
function get_python_dirs() {
|
||||||
(git ls-tree -r HEAD --name-only | grep -E '\.py$' | awk -F '/' '{print $1}' | sort | uniq | grep -v '\.' | grep -Ev '^(bin|migrations)$') || echo ''
|
(git ls-tree -r HEAD --name-only | grep -E '\.py$' | awk -F '/' '{print $1}' | sort | uniq | grep -v '\.' | grep -Ev '^(bin|migrations)$') || echo ''
|
||||||
}
|
}
|
||||||
|
@ -50,23 +61,34 @@ function run_pre_commmit() {
|
||||||
}
|
}
|
||||||
|
|
||||||
for react_project in "${react_projects[@]}" ; do
|
for react_project in "${react_projects[@]}" ; do
|
||||||
pushd "$react_project"
|
# if pre, only do stuff when there are changes
|
||||||
npm run lint:fix
|
if [[ "$subcommand" != "pre" ]] || [[ -n "$(git status --porcelain "$react_project")" ]]; then
|
||||||
popd
|
pushd "$react_project"
|
||||||
|
npm run lint:fix
|
||||||
|
popd
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
for python_project in "${python_projects[@]}" ; do
|
for python_project in "${python_projects[@]}" ; do
|
||||||
pushd "$python_project"
|
if [[ "$subcommand" != "pre" ]] || [[ -n "$(git status --porcelain "$python_project")" ]]; then
|
||||||
run_fix_docstrings || run_fix_docstrings
|
pushd "$python_project"
|
||||||
run_autoflake || run_autoflake
|
run_fix_docstrings || run_fix_docstrings
|
||||||
popd
|
run_autoflake || run_autoflake
|
||||||
|
popd
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
run_pre_commmit || run_pre_commmit
|
|
||||||
|
|
||||||
for python_project in "${python_projects[@]}"; do
|
if [[ "$subcommand" != "pre" ]] || [[ -n "$(git status --porcelain "spiffworkflow-backend")" ]]; then
|
||||||
pushd "$python_project"
|
# rune_pre_commit only applies to spiffworkflow-backend at the moment
|
||||||
poetry install
|
run_pre_commmit || run_pre_commmit
|
||||||
poetry run mypy $(get_python_dirs)
|
fi
|
||||||
poetry run coverage run --parallel -m pytest
|
|
||||||
popd
|
for python_project in "${python_projects[@]}"; do
|
||||||
|
if [[ "$subcommand" != "pre" ]] || [[ -n "$(git status --porcelain "$python_project")" ]]; then
|
||||||
|
pushd "$python_project"
|
||||||
|
poetry install
|
||||||
|
poetry run mypy $(get_python_dirs)
|
||||||
|
poetry run coverage run --parallel -m pytest
|
||||||
|
popd
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in New Issue