Skip to content

Commit

Permalink
[SETUP] Implement Git Hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
jdamner committed Jun 10, 2024
1 parent abd70ec commit 8030cb2
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 4 deletions.
2 changes: 1 addition & 1 deletion bin/nodejs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env bash
docker-compose run --rm nodejs "$@"
docker-compose run --rm -T nodejs "$@"
2 changes: 1 addition & 1 deletion bin/php
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env bash
docker-compose run --rm php "$@"
docker-compose run --rm -T php "$@"
12 changes: 10 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ services:
php:
build: ./docker/php
working_dir: /var/www/html
volumes:
volumes:
- .:/var/www/html

nodejs:
build: ./docker/nodejs
working_dir: /usr/src/app
volumes:
volumes:
- .:/usr/src/app

wordpress:
Expand All @@ -22,3 +23,10 @@ services:
- ./docker/wordpress/mu-plugins/:/var/www/html/wp-content/mu-plugins/
- ./docker/wordpress/themes:/var/www/html/wp-content/themes/
- ./packages/:/var/www/html/wp-content/plugins/

githooks:
build: ./docker/githooks
volumes:
- ./.git:/tmp/.git
- ./hooks:/tmp/hooks

4 changes: 4 additions & 0 deletions docker/githooks/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

FROM busybox:latest

ENTRYPOINT sh -c "cd /tmp/hooks && ls | xargs chmod +x && cd /tmp/.git/hooks && find ../../hooks -type f -exec ln -sf {} /tmp/.git/hooks/ \; && echo 'githooks installed'"
5 changes: 5 additions & 0 deletions hooks/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Git Hoooks

These scripts run at lifecycles during git development and can be used to automate certain tasks to encourage coding standards and tests to be valid before being pushed to the remote repository.

More information can be found online seraching for Git Hooks, or [here's](https://www.atlassian.com/git/tutorials/git-hooks) a good tutorial!
21 changes: 21 additions & 0 deletions hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh

set -e

# Pre-Commit Hook

## Run Tests...

### PHP
echo "Running PHP Tests..."
./bin/composer run phpcs
./bin/composer run phpunit
./bin/composer run phpstan
./bin/composer run coverage-check

### JS
echo "Running JS Tests..."
./bin/npm run lint
./bin/npm run test
./bin/npm run type-coverage
./bin/npm run build

0 comments on commit 8030cb2

Please sign in to comment.