Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
aeadd54
chore: ignores local todo files
jonrandahl Jan 20, 2026
7090af4
fix(exceptions): corrects error message wording
jonrandahl Jan 20, 2026
a77ef72
fix(hooks): updates git hooks for code quality and workflow
jonrandahl Jan 20, 2026
f2ea23a
refactor(sentry): Improves sentry initialisation.
jonrandahl Jan 22, 2026
c35ab83
refactor(error-handling): Improves error logging
jonrandahl Jan 22, 2026
02cd441
chore(deps): updates dependency checks
jonrandahl Jan 22, 2026
4dda6fc
chore(assets): Updates precompile message
jonrandahl Jan 22, 2026
7d0ceca
chore(deps): bump rails and dependencies
jonrandahl Jan 22, 2026
f43a921
chore(deps): update puma dependencies
jonrandahl Jan 22, 2026
f1bc0a9
chore(deps): update jquery-rails
jonrandahl Jan 22, 2026
b80d327
chore(deps): upgrade sentry gems
jonrandahl Jan 22, 2026
bedaa08
refactor(sentry): Updates sentry logger config
jonrandahl Jan 22, 2026
9ad165e
chore(deps): update solargraph & ruby-lsp gems
jonrandahl Jan 22, 2026
7936cba
fix: handles bundle outdated command non-zero exit codes
jonrandahl Jan 22, 2026
6a3aa95
chore(deps): bumps byebug version
jonrandahl Jan 22, 2026
a07b831
chore(deps): updates rubocop-rails gem version
jonrandahl Jan 22, 2026
3d6c1db
chore(build): unify Makefile changes
jonrandahl Jan 30, 2026
6cd7502
fix(hooks): updates API service URL
jonrandahl Jan 30, 2026
19a410a
chore(rubocop): updates rubocop configuration
jonrandahl Jan 30, 2026
5023b65
feat(test): adds test coverage
jonrandahl Jan 30, 2026
1426c39
docs: updates CHANGELOG
jonrandahl Jan 30, 2026
744aa62
chore(deps): upgrade `lr_common_styles` to v3.0.1
jonrandahl Jan 30, 2026
e9dcf7f
chore(deps): pins jquery-datatables-rails
jonrandahl Feb 2, 2026
3f0d845
chore(deps): updates jquery-datatables-rails gem
jonrandahl Feb 2, 2026
72a39ef
chore(deps): update locked dependencies
jonrandahl Feb 2, 2026
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
79 changes: 79 additions & 0 deletions .githooks/common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/bin/bash
# Common utilities and functions for git hooks
#
# Environment variables:
# NO_COLOR - Set to any value to disable colored output (e.g., NO_COLOR=1 git commit)

# Check if color output is disabled (set NO_COLOR=1 to disable)
: "${NO_COLOR:=}"

# Initialize branch name from filtered branch list
init_branch_name() {
local list="issue spike task"
local listRE="^($(printf '%s\n' "$list" | tr ' ' '|'))/"

BRANCH_NAME=$(git branch --show-current | grep -E "$listRE" | sed 's/* //')
}

# Check if hook should be skipped based on branch, reflog action, or flags
should_skip_hook() {
# Skip on specific branches
if echo "$BRANCH_NAME" | grep -qE '^(hotfix|rebase|prod(uction)?)$'; then
return 0
fi

# Skip if Git reflog indicates an amend (reliable for GUI flows)
if [ "${GIT_REFLOG_ACTION:-}" = "commit (amend)" ]; then
return 0
fi

# Fallback: check parent process for --no-verify or --amend flags
local ppid_cmd
ppid_cmd=$(ps -ocommand= -p $PPID 2>/dev/null || echo "")
if [[ "$ppid_cmd" == *"--no-verify"* ]] || [[ "$ppid_cmd" == *"--amend"* ]]; then
return 0
fi

return 1
}

# Print colored status messages (respects NO_COLOR environment variable)
print_header() {
if [ -z "$NO_COLOR" ]; then
printf '\n\033[0;105m%s\033[0m\n' "$1"
else
printf '\n%s\n' "$1"
fi
}

print_success() {
if [ -z "$NO_COLOR" ]; then
printf '\n\033[0;32m%s\033[0m\n' "$1"
else
printf '\n%s\n' "$1"
fi
}

print_warning() {
if [ -z "$NO_COLOR" ]; then
printf '\n\033[0;33m%s\033[0m\n' "$1"
else
printf '\n%s\n' "$1"
fi
}

print_error() {
if [ -z "$NO_COLOR" ]; then
printf '\n\033[0;31m%s\033[0m\n' "$1"
else
printf '\n%s\n' "$1"
fi
}

print_info() {
if [ -z "$NO_COLOR" ]; then
printf '\033[0;33m%s\033[0m\n' "$1"
else
printf '%s\n' "$1"
fi
}
70 changes: 26 additions & 44 deletions .githooks/post-commit
Original file line number Diff line number Diff line change
Expand Up @@ -5,84 +5,66 @@
# aborted. The hook can be bypassed by using the --no-verify option
# when running "git commit".

# ! This could ask for user input to sign the commit as it's now using
# ! the `git commit` command instead of `git commit -m` which is
# ! the default behavior of the `git commit` command. This could be
# ! a problem if the user is not expecting it. This should be fixed
# ! in the future.
if [[ $(ps -ocommand= -p $PPID) == *"git"*"commit"*"--no-verify"* ]] || [[ $(ps -ocommand= -p $PPID) == *"git"*"commit"*"--amend"* ]]; then
printf '\n\033[0;33mSkipping post-commit hook... 🤨\033[0m\n'
exit 0
fi

list="issue spike task"

listRE="^($(printf '%s\n' "$list" | tr ' ' '|'))/"
# Source common hook utilities
. "$(dirname "$0")/common.sh"

BRANCH_NAME=$(git branch --show-current | grep -E "$listRE" | sed 's/* //')
# Initialize branch name
init_branch_name

printf '\n\033[0;105mChecking "%s"... \033[0m\n' "$BRANCH_NAME"
print_header "Checking \"$BRANCH_NAME\"..."

if echo "$BRANCH_NAME" | grep -q '^(hotfix)|(rebase)|(production)*$'; then
printf '\n\033[0;32mNo checks necessary on "%s", skipping hooks... 🎉\033[0m\n' "$BRANCH_NAME"
exit 0
# Skip if on specific branches, or when amending or --no-verify flag is set
if should_skip_hook; then
print_warning "Skipping post-commit hook... 🤨"
exit 0
fi

# Check for existence of "new or modified" test files
NEW_TEST_FILES="$(git diff --diff-filter=ACDM --name-only --cached | grep -E '(./test/*)$')"
# Get all test files to run tests
CURRENT_TEST_FILES="$(git ls-files | grep -i -E '(_test\.rb)$')"

RAILS_TEST_EXIT_CODE=0
WORK_DONE=0

if [ -z "$NEW_TEST_FILES" ]; then
printf '\n\033[0;31mThere are currently no new tests found in "%s". 🤨\033[0m\n' "$BRANCH_NAME"
printf '\n\033[0;31mContinuing without new tests... 😖\033[0m\n'
fi

if [ -n "$NEW_TEST_FILES" ]; then
#Count the number of new test files
file_count=$(echo "$NEW_TEST_FILES" | wc -l)
# Check if there are any new test files
if [ "$file_count" -ne 0 ]; then
printf '\n\033[0;33mFound %d new test files in "%s" 🎉.\033[0m\n' "$file_count" "$BRANCH_NAME"
print_warning "Found $file_count new test files in \"$BRANCH_NAME\" 🎉."
fi

for file in $NEW_TEST_FILES; do
# if file is system test file run rake test:system filename
if [[ "$file" == *"./test/system/*_test.rb" ]]; then
printf '\n\033[0;33mRunning system test for "%s"...\033[0m\n', "$file"
print_warning "Running system test for \"$file\"..."
bundle exec rake test:system "$file"
else
printf '\n\033[0;33mRunning unit test on "%s"...\033[0m\n', "$file"
print_warning "Running unit test on \"$file\"..."
bundle exec rake test "$file"
fi
# Capture the exit code from the test command to determine if it passed or failed
if [ $? -ne 0 ]; then
RAILS_TEST_EXIT_CODE=1
fi
done
WORK_DONE=1
elif [ -n "$CURRENT_TEST_FILES" ]; then
print_warning "No new tests found, running all Rails Tests ..."
make test
RAILS_TEST_EXIT_CODE=$?
WORK_DONE=1
fi

if [ -n "$CURRENT_TEST_FILES" ] && [ "$WORK_DONE" -eq 0 ]; then
printf '\nRunning all Rails Tests ...\n'
# make test
# RAILS_TEST_EXIT_CODE=$?
WORK_DONE=2
else
RAILS_TEST_EXIT_CODE=0
print_error "No tests found in \"$BRANCH_NAME\". 🤨"
RAILS_TEST_EXIT_CODE=1
fi

if [ ! "$RAILS_TEST_EXIT_CODE" -eq 0 ]; then
git reset HEAD~
printf '\n\033[0;31mCannot commit, tests are failing. Use --no-verify to force commit. 😖\033[0m\n'
print_error "Cannot commit, tests are failing. Use --no-verify to force commit. 😖"
exit 1
fi

if [ "$WORK_DONE" -eq 1 ]; then
printf '\n\033[0;32mAll tests are green, committing... 🎉\033[0m\n'
exit 0
fi

if [ "$WORK_DONE" -eq 2 ]; then
printf '\n\033[0;41mCurrently skipping broken tests found on "%s". 🤨\033[0m\n' "$BRANCH_NAME"
exit 0
fi
print_success "All tests are green, committing... 🎉"
exit 0
43 changes: 22 additions & 21 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -3,54 +3,55 @@
# beware if you are in the habit of committing only partial modifications to a file:
# THIS HOOK WILL ADD ALL MODIFICATIONS TO A FILE TO THE COMMIT IF ANY FILE WAS CHANGED BY LINTING

list="issue spike task"
# Source common hook utilities
. "$(dirname "$0")/common.sh"

listRE="^($(printf '%s\n' "$list" | tr ' ' '|'))/"
# Initialize branch name
init_branch_name

BRANCH_NAME=$(git branch --show-current | grep -E "$listRE" | sed 's/* //')
print_header "Checking \"$BRANCH_NAME\"..."

printf '\n\033[0;105mChecking "%s"... \033[0m\n' "$BRANCH_NAME"

if echo "$BRANCH_NAME" | grep -q '^(hotfix)|(rebase)|(production)*$'; then
printf '\n\033[0;32mNo checks necessary on "%s", skipping hooks... 🎉\033[0m\n' "$BRANCH_NAME"
if should_skip_hook; then
print_success "No checks necessary on \"$BRANCH_NAME\", pushing now... 🎉"
exit 0
fi

# Identify staged Ruby-related files (including Gemfile/Rakefile) to lint before commit.
RUBY_FILES="$(git diff --diff-filter=d --name-only --cached | grep -E '(Gemfile|Rakefile|\.(rb|rake|ru))$')"
PRE_STATUS="$(git status | wc -l)"

# Initialise exit code variables to track success (0 = success)
RUBOCOP_EXIT_CODE=0
WORK_DONE=0

if [ -z "$RUBY_FILES" ]; then
printf '\n\033[0;31mThere are currently no updated files in "%s". 🤨\033[0m\n' "$BRANCH_NAME"
fi

if [ -n "$RUBY_FILES" ]; then
printf '\n\033[0;33mRunning Rubocop...\033[0m\n'
for file in $RUBY_FILES; do
git show :"$file" | bundle exec rubocop -A --stdin "$file"
done
print_error "There are currently no updated files in \"$BRANCH_NAME\". 🤨"
else
print_warning "Running Rubocop..."
# Convert space-separated file list into positional parameters for safe argument passing
set -- $RUBY_FILES
# Execute RuboCop with auto-fix enabled on the staged files that have been set
bundle exec rubocop -a --force-exclusion -- "$@"
# Capture the exit code from RuboCop command (0 = success, non-zero = errors)
RUBOCOP_EXIT_CODE=$?
# Flag that linting ran so we can report result and re-add files if needed.
WORK_DONE=1
else
printf '\n\033[0;32mContinuing as there are no changes to check... 🎉\033[0m\n'
RUBOCOP_EXIT_CODE=0
fi

POST_STATUS="$(git status | wc -l)"

if [ ! $RUBOCOP_EXIT_CODE -eq 0 ]; then
git reset HEAD
printf '\n\033[0;31mLinting has uncorrectable errors; please fix and restage your commit. 😖\033[0m\n'
print_error "Linting has uncorrectable errors; please fix and restage your commit. 😖"
exit 1
fi

if [ "$PRE_STATUS" != "$POST_STATUS" ]; then
git add "$RUBY_FILES"
fi

if [ $WORK_DONE -eq 1 ]; then
printf '\n\033[0;32mLinting completed successfully! 🎉\033[0m\n'
if [ ! $WORK_DONE -eq 0 ]; then
print_success "Linting completed successfully! 🎉"
fi

exit 0
76 changes: 38 additions & 38 deletions .githooks/pre-push
Original file line number Diff line number Diff line change
@@ -1,64 +1,64 @@
#!/bin/bash
# Source common hook utilities
. "$(dirname "$0")/common.sh"

: "${CLIENT_PROFILE:=hmlr}"
: "${API_SERVICE_URL:=http://data-api:8080}"
: "${RUN_VARS:=--detach --publish}"

list="issue spike task"

listRE="^($(printf '%s\n' "$list" | tr ' ' '|'))/"

BRANCH_NAME=$(git branch --show-current | grep -E "$listRE" | sed 's/* //')

printf '\n\033[0;105mChecking "%s"... \033[0m\n' "$BRANCH_NAME"

if echo "$BRANCH_NAME" | grep -q '^(hotfix)|(rebase)|(production)*$'; then
printf '\n\033[0;32mNo checks necessary on "%s", skipping hooks... 🎉\033[0m\n' "$BRANCH_NAME"
exit 0
fi
# Initialize branch name
init_branch_name

# Skip hook if all staged files only markdown (.md) files
files=$(git diff --cached --name-only)
files_to_check=$(echo "$files" | grep '\.md$')
print_header "Checking \"$BRANCH_NAME\"..."

if [ -n "$files_to_check" ] && [ -z "$(echo "$files" | grep -v '\.md$')" ]; then
printf '\n\033[0;32mOnly markdown files staged (%s), skipping hook.\033[0m\n' "$files_to_check"
# Skip on specific branches, with --no-verify flag, or when amending
if should_skip_hook; then
print_success "Skipping pre-push hook... 🎉"
exit 0
fi

# Check for existence of "new or modified" files
DOCKER_BUILD_EXIT_CODE=0
DOCKER_RUN_EXIT_CODE=0

if ! git update-index -q --ignore-submodules --refresh; then
printf '\n\033[0;31mUp-to-date check failed😖\033[0m\n'
print_error "Up-to-date check failed 😖"
DOCKER_BUILD_EXIT_CODE=1
else
printf '\n\033[0;33mBuilding Docker image with "%s" profile... \033[0m\n' "$CLIENT_PROFILE"
print_warning "Building Docker image with \"$CLIENT_PROFILE\" profile... "
AWS_PROFILE=$CLIENT_PROFILE make image
DOCKER_BUILD_EXIT_CODE=$?
fi

if [ $DOCKER_BUILD_EXIT_CODE -ne 0 ]; then
printf '\n\033[0;31mDocker image build failed. Please check your changes. 😖\033[0m\n'
print_error "Docker image build failed. Please check your changes. 😖"
exit 1
else
printf '\n\033[0;32mDocker image build succeeded. 🎉\033[0m\n'
CONTAINER_ID=$(make name)
printf '\n\033[0;33mRunning Docker image %s ... \033[0m\n' "$CONTAINER_ID"
AWS_PROFILE=$CLIENT_PROFILE API_SERVICE_URL=$API_SERVICE_URL RUN_VARS=$RUN_VARS make run
secs=5
while [ $secs -gt -1 ]; do
echo -ne "$secs\033[0K\r"
sleep 1
: $((secs--))
done
docker inspect --format="{{.State.Running}}" "$CONTAINER_ID" | grep 'true' -q
DOCKER_RUN_EXIT_CODE=$?
printf '\n\033[0;33mStopping Docker image with exit code %s ... \033[0m\n' "$DOCKER_RUN_EXIT_CODE"
make stop
fi

# Build succeeded, now run the container
print_success "Docker image build succeeded. 🎉"
CONTAINER_ID=$(make name)
print_warning "Running Docker image $CONTAINER_ID ... "
AWS_PROFILE=$CLIENT_PROFILE API_SERVICE_URL=$API_SERVICE_URL RUN_VARS=$RUN_VARS make run

# Wait for container to stabilize
secs=5
while [ $secs -gt -1 ]; do
echo -ne "$secs\033[0K\r"
sleep 1
: $((secs--))
done

# Check if container is running
docker inspect --format="{{.State.Running}}" "$CONTAINER_ID" | grep 'true' -q
DOCKER_RUN_EXIT_CODE=$?

print_warning "Stopping Docker image with exit code $DOCKER_RUN_EXIT_CODE ... "
make stop

if [ $DOCKER_RUN_EXIT_CODE -ne 0 ]; then
printf '\n\033[0;31mDocker image run failed. Please check your changes. 😖\033[0m\n'
print_error "Docker image run failed. Please check your changes. 😖"
exit 1
else
printf '\n\033[0;32mDocker image run succeeded. 🎉\033[0m\n'
print_success "Docker image run succeeded. 🎉"
exit 0
fi
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,6 @@ tags
# Ignore local configuration files
.env*
!.env.development

# Ignore local TODO files
TODO.md
Loading