mirror of
https://github.com/sartography/spiff-arena.git
synced 2025-01-12 10:34:17 +00:00
3f6fb4d9f5
* attempt to use the locked version of SpiffWorkflow in ci w/ burnettk * fixed regex for spiffworkflow revision replacement * make sure we also update the lockfile when getting new spiff * install poetry before we attempt to update hte pyproject * hardcoding spiffworkflow revision as a test w/ burnettk * try running tests in ci from bash script w/ burnettk * print working dir in ci w/ burnettk * fixed location of instance dir w/ burnettk * run with mysql in ci * run typeguard with bash script as well w/ burnettk * fixed postgres test w/ burnettk * clean up github action file w/ burnettk * fixed postgres test again w/ burnettk * pyl * attempt to remove nox from ci completely * omit safety for now to test coverage * fixed how coverage is being called from not nox * allow running safety and macos again * renamed run_not_nox to run_ci_session w/ burnettk * attempt to only upload if matrix says to w/ burnettk * attempt to install mysqlclient prereqs for mac and remove noxfile stuff w/ burnettk * added back the constraints file w/ burnettk * moved the contributing file to the root of arena w/ burnettk --------- Co-authored-by: jasquat <jasquat@users.noreply.github.com>
42 lines
1.5 KiB
Bash
Executable File
42 lines
1.5 KiB
Bash
Executable File
#!/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
|
|
|
|
# HELP: remove all unused functions from python files
|
|
|
|
if ! command -v dead >/dev/null 2>&1; then
|
|
echo "dead is not installed. installing..."
|
|
echo "pip install dead"
|
|
fi
|
|
|
|
list_of_unused_things="$(dead | grep -E '^[a-z].*is never read')"
|
|
|
|
filename_patterns_to_ignore="(codemod|migrations/versions|conftest.py)"
|
|
|
|
while read -r line; do
|
|
function_name="$(echo "$line" | awk '{print $1}')"
|
|
echo "possible function_name: ${function_name}"
|
|
file_name_and_line_number="$(echo "$line" | perl -p -e "s/.*is never read, defined in //g")"
|
|
file_name="$(echo "$file_name_and_line_number" | awk -F ':' '{print $1}')"
|
|
if ! grep "def $function_name" "$file_name" >/dev/null 2>&1; then
|
|
echo "skipping $function_name in ${file_name} because it's not a function"
|
|
continue
|
|
fi
|
|
if grep -E "$filename_patterns_to_ignore" <<< "$file_name" >/dev/null 2>&1; then
|
|
echo "skipping ${file_name} because it's in the list of files to ignore (probably because it is a false positive and actually used)"
|
|
continue
|
|
fi
|
|
echo "trying to remove $function_name from: ${file_name}"
|
|
|
|
if python bin/codemod/update_file_to_remove_function.py "$file_name" "$function_name"; then
|
|
# TODO: run exhaustive tests, and if they pass, report success
|
|
echo "function ${function_name} removed from ${file_name}. yay!"
|
|
exit 0
|
|
fi
|
|
done <<< "$list_of_unused_things"
|