Unify formatting and linting

Ensures optimal formatting in addition to linting during manual deploys
and during pre-commit actions.
This commit is contained in:
Joshua Boniface 2021-11-06 03:10:17 -04:00
parent 9b12cc0236
commit b9c30baf80
5 changed files with 13 additions and 7 deletions

View File

@ -4,11 +4,9 @@ pushd $( git rev-parse --show-toplevel ) &>/dev/null
ex=0
# Linting
echo "Linting..."
./lint
./prepare
if [[ $? -ne 0 ]]; then
echo "Aborting commit due to linting errors."
echo "Aborting commit due to formatting or linting errors."
ex=1
fi

View File

@ -27,9 +27,9 @@ fi
HOSTS=( ${@} )
echo "> Deploying to host(s): ${HOSTS[@]}"
# Lint to prevent deploying bad code
echo -n "Linting code for errors... "
./lint || exit
# Prepare code
echo "Preparing code (format and lint)..."
./prepare || exit
# Build the packages
echo -n "Building packages... "

1
format
View File

@ -5,6 +5,7 @@ if ! which black &>/dev/null; then
exit 1
fi
echo "Formatting..."
black --safe --exclude api-daemon/migrations .
ret=$?
if [[ $ret -eq 0 ]]; then

1
lint
View File

@ -5,6 +5,7 @@ if ! which flake8 &>/dev/null; then
exit 1
fi
echo "Linting..."
flake8
ret=$?
if [[ $ret -eq 0 ]]; then

6
prepare Executable file
View File

@ -0,0 +1,6 @@
#!/usr/bin/env bash
#set -o errexit
./format
./lint