Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SETUP] Implement Git Hooks #26

Merged
merged 1 commit into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading