zephinzer/annams

View on GitHub
provisioning/scripts/dot-git/pre-push

Summary

Maintainability
Test Coverage
#!/bin/sh
printf -- '\033[1mANNAMS pre-push hook\033[0m\n\n';

printf -- '> stashing un-prepared files... \n';
git stash;

DO_NOT_PUSH=0;
printf -- '> verifying deployment files integrity... \n';
yarn test deployment;
if [ "$?" != "0" ]; then DO_NOT_PUSH=1; fi;
printf -- '> linting the involved commits... \n';
yarn test lint;
if [ "$?" != "0" ]; then DO_NOT_PUSH=1; fi;
printf -- '> checking for vulnerabilities... \n';
yarn test sec;
if [ "$?" != "0" ]; then DO_NOT_PUSH=1; fi;
printf -- '> running unit tests... \n';
yarn test;
if [ "$?" != "0" ]; then DO_NOT_PUSH=1; fi;

printf -- '> restoring un-prepared files... \n';
git stash pop;

if [ ${DO_NOT_PUSH} -eq 1 ]; then
  printf -- '> \033[31m\033[1msome checks failed... NO PUSH.\033[0m\n';
  exit 1;
else
  printf -- '> \033[32m\033[1mall checks passed... PUSHING...\033[0m\n';
  exit 0;
fi;