diff --git a/bin/nodejs b/bin/nodejs index 1b54139..46a3de6 100755 --- a/bin/nodejs +++ b/bin/nodejs @@ -1,2 +1,2 @@ #!/usr/bin/env bash -docker-compose run --rm nodejs "$@" +docker-compose run --rm -T nodejs "$@" diff --git a/bin/php b/bin/php index 87f4bc5..43fd04f 100755 --- a/bin/php +++ b/bin/php @@ -1,2 +1,2 @@ #!/usr/bin/env bash -docker-compose run --rm php "$@" +docker-compose run --rm -T php "$@" diff --git a/docker-compose.yml b/docker-compose.yml index 103a7d7..e4f5443 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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: @@ -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 + diff --git a/docker/githooks/Dockerfile b/docker/githooks/Dockerfile new file mode 100644 index 0000000..5a29d47 --- /dev/null +++ b/docker/githooks/Dockerfile @@ -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'" diff --git a/hooks/Readme.md b/hooks/Readme.md new file mode 100755 index 0000000..ad5319a --- /dev/null +++ b/hooks/Readme.md @@ -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! diff --git a/hooks/pre-commit b/hooks/pre-commit new file mode 100755 index 0000000..998ed2a --- /dev/null +++ b/hooks/pre-commit @@ -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