Working setup
parent
7ac43519c7
commit
8feef6906d
@ -1,9 +1,10 @@
|
|||||||
#! /usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
set -ex
|
function _setup_env() {
|
||||||
|
# build a virtual env
|
||||||
source "$(dirname "$0")/_common.sh"
|
if [ -z "${VIRTUAL_ENV}" ]; then
|
||||||
|
python3 -m venv env
|
||||||
_setup_env
|
# shellcheck source=/dev/null
|
||||||
|
source env/bin/activate
|
||||||
${VIRTUAL_ENV}/bin/python -m pytest -vv --cov "$@"
|
fi
|
||||||
|
}
|
||||||
|
@ -1,32 +1,38 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# setting -e to exit immediately on a command failure.
|
# setting -e to exit immediately on a command failure.
|
||||||
# setting -o pipefail sets the exit code of a pipeline to that of the rightmost command to exit with a non-zero status, or to zero if all commands of the pipeline exit successfully.
|
# set -o pipefail sets the exit code of a pipeline to
|
||||||
|
# that of the rightmost command to exit with a non-zero status,
|
||||||
|
# or to zero if all commands of the pipeline exit successfully.
|
||||||
|
# set -u affects variables. When set, a reference to any variable
|
||||||
|
# you haven't previously defined - with the exceptions of $* and $@ -
|
||||||
|
# is an error, and causes the program to immediately exit
|
||||||
set -eo pipefail
|
set -eo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
|
||||||
function _setup_env() {
|
# shellcheck source=/dev/null
|
||||||
# build a virtual env and install
|
source "$(dirname "$0")/_common.sh"
|
||||||
if [ -z $VIRTUAL_ENV ]; then
|
|
||||||
python3 -m venv env
|
|
||||||
source env/bin/activate
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "${DRONE}" == "true" ]; then
|
function project_bootstrap() {
|
||||||
_setup_env
|
_setup_env
|
||||||
|
pip install -U pip pip-tools=='7.3.0'
|
||||||
|
pip-compile requirements.in
|
||||||
|
pip-compile dev-requirements.in
|
||||||
|
pip-sync requirements.txt dev-requirements.txt
|
||||||
|
}
|
||||||
|
|
||||||
fi
|
function install_precommit_hooks() {
|
||||||
|
if [ ! -d ".git" ]; then
|
||||||
|
git init
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -z "${VIRTUAL_ENV}" ]; then
|
if [ -z "$VIRTUAL_ENV" ]; then
|
||||||
echo "warning: you are not in a virtualenv"
|
echo "warning: you are not in a virtualenv"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
pip install -U pip pip-tools
|
|
||||||
pip-compile requirements.in
|
|
||||||
pip-compile dev-requirements.in
|
|
||||||
pip-sync requirements.txt dev-requirements.txt
|
|
||||||
|
|
||||||
if [ ! -d ".git" ]; then
|
|
||||||
git init
|
|
||||||
pre-commit install
|
pre-commit install
|
||||||
fi
|
}
|
||||||
|
|
||||||
|
project_bootstrap
|
||||||
|
install_precommit_hooks
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
#! /usr/bin/env bash
|
#! /usr/bin/env bash
|
||||||
|
|
||||||
set -ex
|
set -ex
|
||||||
|
|
||||||
|
# shellcheck source=/dev/null
|
||||||
source "$(dirname "$0")/_common.sh"
|
source "$(dirname "$0")/_common.sh"
|
||||||
|
|
||||||
_setup_env
|
if [ "${DRONE}" == "true" ]; then
|
||||||
|
_setup_env
|
||||||
|
pip install -r requirements.txt -r dev-requirements.txt
|
||||||
|
fi
|
||||||
|
|
||||||
${VIRTUAL_ENV}/bin/python -m pytest -vv --cov "$@"
|
exec "${VIRTUAL_ENV}/bin/python" -m pytest -vv --cov "$@"
|
||||||
|
Loading…
Reference in New Issue