Add git hooks
This commit is contained in:
parent
e3f53839d5
commit
c22a5ffac2
|
@ -0,0 +1,4 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
ln .git-hooks/pre-commit .git/hooks/pre-commit
|
||||||
|
chmod +x .git/hooks/pre-commit
|
|
@ -0,0 +1,24 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
GREEN='\033[0;32m'
|
||||||
|
AMBER='\033[0;33m'
|
||||||
|
RED='\033[0;31m'
|
||||||
|
CLEAR_COLOR='\033[0m'
|
||||||
|
|
||||||
|
function run_command {
|
||||||
|
local COMMAND=$1
|
||||||
|
local COMMAND_NAME=$2
|
||||||
|
|
||||||
|
echo -e "${AMBER}Running $COMMAND_NAME…${AMBER}"
|
||||||
|
$COMMAND &>/dev/null
|
||||||
|
if [[ $? -ne 0 ]] ; then
|
||||||
|
echo -e "${RED}❌ $COMMAND_NAME failed${CLEAR_COLOR}"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo -e "${GREEN}✓ $COMMAND_NAME passed${CLEAR_COLOR}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
run_command "brakeman --format html -o ../tmp/brakeman.html" "Brakeman"
|
||||||
|
run_command "bundle exec rubocop" "Rubocop"
|
||||||
|
run_command "bundle exec rails test" "test suite"
|
16
README.md
16
README.md
|
@ -8,3 +8,19 @@ the video chat software of your choice or offline at a physical table.
|
||||||
Spin up the application with `./bin/setup`.
|
Spin up the application with `./bin/setup`.
|
||||||
|
|
||||||
Run tests with `rails test`.
|
Run tests with `rails test`.
|
||||||
|
|
||||||
|
### Git hooks
|
||||||
|
|
||||||
|
There is a pre-commit git hook stored in .git-hooks which can be installed by running `.git-hooks/install.bash`.
|
||||||
|
|
||||||
|
The hooks:
|
||||||
|
- Run Rubocop
|
||||||
|
- Run tests
|
||||||
|
- Run Brakeman
|
||||||
|
|
||||||
|
### Brakeman
|
||||||
|
|
||||||
|
If Brakeman issues are introduced, they should be immediately fixed or ignored with a note as to why it
|
||||||
|
is not a real issue. To do so, run `bundle exec brakeman -I`.
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue