spiff-arena/bin/run_pyl

83 lines
2.1 KiB
Plaintext
Raw Normal View History

#!/usr/bin/env bash
function error_handler() {
echo >&2 "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
python_projects=(
spiffworkflow-backend
)
react_projects=(
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() {
(git ls-tree -r HEAD --name-only | grep -E '\.py$' | awk -F '/' '{print $1}' | sort | uniq | grep -v '\.' | grep -Ev '^(bin|migrations)$') || echo ''
}
function run_autofixers() {
python_dirs="$(get_python_dirs) bin"
Feature/business end states (#333) * WIP: some updates to support new spiff w/ burnettk * unit tests are passing * all tests except message tests are passing * fixed usage of catch message event w/ burnettk * messages are working again w/ burnettk * uncommented remaining message tests w/ burnettk * fixed cypress tests w/ burnettk * use main for spiffworkflow * translated mysql last milestone query to sqlalchemy w/ burnettk * fixed last milestone query so instances still return if no milestone found and moved some code from the main report method to own methods * added some comments * added last milestone column to process instances table * display last milestone in instance list table w/ burnettk * remove 3 characters when truncating last milestone for ellipsis * make sure we have a current processor so we don't return null * remove sleep * The background processor now only picks up processes that were last updated more than a minute ago to avoid conflicting with the interstitial page. With the understanding that we can rmeove this limitation when we can refactor to allow the backend processes to provide updates on what they are doing. * pyl w/ burnettk * cache last milestone on instances * pyl * added test for last milestone and added it to the proces instance show page w/ burnettk * fixed broken test w/ burnettk * fixed last milestone header * removed duplicated column * fixed broken test --------- Co-authored-by: jasquat <jasquat@users.noreply.github.com> Co-authored-by: Kevin Burnett <18027+burnettk@users.noreply.github.com> Co-authored-by: danfunk <daniel.h.funk@gmail.com> Co-authored-by: burnettk <burnettk@users.noreply.github.com>
2023-09-07 14:10:44 +00:00
# shellcheck disable=2086
poetry run ruff --fix $python_dirs || echo ''
}
function run_pre_commmit() {
poetry run pre-commit run --verbose --all-files
}
for react_project in "${react_projects[@]}"; do
# if pre, only do stuff when there are changes
if [[ -n "$(git status --porcelain "$react_project")" ]]; then
pushd "$react_project"
npm run lint:fix
popd
fi
done
for python_project in "${python_projects[@]}"; do
# if pre, only do stuff when there are changes
if [[ "$subcommand" != "pre" ]] || [[ -n "$(git status --porcelain "$python_project")" ]]; then
pushd "$python_project"
run_autofixers || run_autofixers
popd
fi
done
if [[ "$subcommand" != "pre" ]] || [[ -n "$(git status --porcelain "spiffworkflow-backend")" ]]; then
# rune_pre_commit only applies to spiffworkflow-backend at the moment
run_pre_commmit || run_pre_commmit
fi
function clear_log_file() {
unit_testing_log_file="./log/unit_testing.log"
if [[ -f "$unit_testing_log_file" ]]; then
>"$unit_testing_log_file"
fi
}
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)
clear_log_file
./bin/tests-par
popd
fi
done