python-mylib/tests.sh
Benjamin Renard 83ce6b9d1b
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
CI now run pylint & flake8
2023-01-06 22:18:46 +01:00

43 lines
809 B
Bash
Executable file

#!/bin/bash
QUIET_ARG=""
[ "$1" == "--quiet" ] && QUIET_ARG="--quiet"
# Enter source directory
cd $( dirname $0 )
if [ -d venv ]
then
VENV=$( realpath venv )
TEMP_VENV=0
else
# Create a temporary venv
VENV=$(mktemp -d)
echo "Create a temporary virtualenv in $VENV to install dependencies..."
TEMP_VENV=1
python3 -m venv $VENV
fi
echo "Install package with dev dependencies using pip..."
$VENV/bin/python3 -m pip install -e ".[dev]" $QUIET_ARG
RES=0
# Run tests
$VENV/bin/python3 -m pytest tests
[ $? -ne 0 ] && RES=1
# Run pylint
echo "Run pylint..."
$VENV/bin/pylint --extension-pkg-whitelist=cx_Oracle mylib tests
[ $? -ne 0 ] && RES=1
# Run flake8
echo "Run flake8..."
$VENV/bin/flake8 mylib tests
[ $? -ne 0 ] && RES=1
# Clean temporary venv
[ $TEMP_VENV -eq 1 ] && rm -fr $VENV
exit $RES