diff --git a/.gitignore b/.gitignore index 0098a47..2b99cc0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .idea tampermonkey_scripts +.annertech_tests_timestamps diff --git a/commands/web/behat b/commands/web/behat index 8888048..7b6e8b9 100755 --- a/commands/web/behat +++ b/commands/web/behat @@ -26,3 +26,7 @@ fi # Run behat with the provided flags/arguments bin/behat "$@" + +# Create/update timestamp file +cd ../.. +touch ${DDEV_APPROOT}/.ddev/.annertech_tests_timestamps \ No newline at end of file diff --git a/scripts/git-hooks/pre-push b/scripts/git-hooks/pre-push new file mode 100755 index 0000000..a81ae03 --- /dev/null +++ b/scripts/git-hooks/pre-push @@ -0,0 +1,24 @@ +#!/bin/sh + +# Annertech's tests timestamps file +TIMESTAMP_FILE=.ddev/.annertech_tests_timestamps + +# Check if the timestamp is more recent than 1 hour +one_hour_ago=$(date -d '-1 hour' "+%s") +last_test_run=$(date -r $TIMESTAMP_FILE "+%s") +if [ $one_hour_ago -gt $last_test_run ]; +then + read -r -p "You haven't run tests recently. Do you want to run them now? [y/N] " response < /dev/tty + case "$response" in [yY][eE][sS]|[yY]) + # Disallow the push + echo git push aborted. Run your testing suite and git push again + exit 1 + ;; + *) + echo pushing... + ;; + esac +fi + +# Allow the push. +exit 0 diff --git a/scripts/git-hooks/pre-push.wip b/scripts/git-hooks/pre-push.wip deleted file mode 100755 index da93aaa..0000000 --- a/scripts/git-hooks/pre-push.wip +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env bash -#ddev-generated - -# Abort a push if no backstop test have been found - -# Directory to check -BASE_DIR="tests/backstop/backstop_data/bitmaps_test" - -# Today's date in YYYYMMDD format -TODAY=$(date +%Y%m%d) - -# Look for any folder that starts with today's date -MATCH=$(find "$BASE_DIR" -maxdepth 1 -type d -name "${TODAY}-*") - -if [ -z "$MATCH" ]; then - echo - echo "==================================================================================================" - echo "❌ Push aborted ❌" - echo "No folder found in $BASE_DIR starting with today's date ($TODAY)" - echo "Did you run Backstop tests?" - echo "==================================================================================================" - echo - exit 1 -fi - -# If a folder is found, allow the push -exit 0