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 adc767e32f
commit 4eb0f3bb8a
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 ex=0
# Linting ./prepare
echo "Linting..."
./lint
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
echo "Aborting commit due to linting errors." echo "Aborting commit due to formatting or linting errors."
ex=1 ex=1
fi fi

View File

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

1
format
View File

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

1
lint
View File

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

6
prepare Executable file
View File

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