mirror of
https://github.com/opdavies/build-configs.git
synced 2025-09-06 19:35:33 +01:00
feat: add and enable pre-push Git hooks
This commit is contained in:
parent
c419332bad
commit
2afdf43cd2
4 changed files with 54 additions and 1 deletions
5
templates/git-hooks/pre-push.twig
Executable file
5
templates/git-hooks/pre-push.twig
Executable file
|
@ -0,0 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
just test-commit
|
|
@ -19,7 +19,7 @@ composer *args:
|
|||
alias phpunit := test
|
||||
|
||||
test *args:
|
||||
{{ "just _run php phpunit {{ args }}" | raw }}
|
||||
{{ "just _run php phpunit --colors=always {{ args }}" | raw }}
|
||||
{% endif %}
|
||||
|
||||
{% if "drupal-project" is same as type %}
|
||||
|
@ -58,6 +58,39 @@ artisan *args:
|
|||
{{ "just _run artisan {{ args }}" | raw }}
|
||||
{% endif %}
|
||||
|
||||
{% if experimental.runGitHooksBeforePush %}
|
||||
# Enable or disable Git hooks
|
||||
git-hooks command:
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
case "{{ '{{ command }}'|raw }}" in
|
||||
"on")
|
||||
echo "Enabling Git hooks..."
|
||||
git config core.hooksPath .githooks
|
||||
;;
|
||||
"off")
|
||||
echo "Disabling Git hooks..."
|
||||
git config --unset core.hooksPath
|
||||
;;
|
||||
*)
|
||||
echo "Error: Invalid argument. Must be either 'on' or 'off'"
|
||||
;;
|
||||
esac
|
||||
|
||||
test-commit:
|
||||
{% if "phpcs" in php|keys -%}
|
||||
just _run php phpcs
|
||||
{%- endif %}
|
||||
|
||||
{% if "phpstan" in php|keys -%}
|
||||
just _run php phpstan analyze --no-progress --memory-limit=512M
|
||||
{%- endif %}
|
||||
|
||||
just test --testdox --testsuite unit
|
||||
just test --testdox --testsuite kernel
|
||||
{% endif %}
|
||||
|
||||
_exec +args:
|
||||
{{ "docker compose exec {{ args }}" | raw }}
|
||||
|
||||
|
@ -68,3 +101,5 @@ _run service command *args:
|
|||
--rm \
|
||||
-T \
|
||||
{{ "{{ service }} {{ args }}"|raw }}
|
||||
|
||||
# vim: ft=just
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue