diff --git a/readme.md b/readme.md index 15dc13e..2bdb05a 100644 --- a/readme.md +++ b/readme.md @@ -30,6 +30,7 @@ Set up your SSH key authentication in GitLab Profile Settings. Then clone the re git clone git@git.sahkoinsinoorikilta.fi:vtmk/web2.0.git cd web2.0 git checkout develop +cp scripts/git/pre-commit .git/hooks/pre-commit # install a script to test code before committing ``` ## Windows install instructions diff --git a/scripts/git/pre-commit b/scripts/git/pre-commit index 5ca0d4f..1cc7067 100755 --- a/scripts/git/pre-commit +++ b/scripts/git/pre-commit @@ -1,17 +1,24 @@ -. "VIRTUALENV_ACTIVATE" -if [ $? -ne 0 ] -then - echo "Failed to source virtualenv. Skipping pre-commit hook." - exit 0; -fi +#!/bin/bash -set -e PURPLE='\033[0;35m' NC='\033[0m' # No Color +. "${VIRTUAL_ENV}/bin/activate" + +if [ $? -ne 0 ] +then + printf "${PURPLE}Failed to find virtualenv. Skipping pre-commit hook.\n${NC}" + exit 0 +fi + +set -e + printf "${PURPLE}Running pre-commit tests.${NC}\n" +printf "${PURPLE}npm tests...${NC}\n" npm test +printf "${PURPLE}pycodestyle tests...${NC}\n" pycodestyle . +printf "${PURPLE}unit tests...${NC}\n" python manage.py test --noinput set +e