Skip to content

Conversation

@paudley
Copy link
Owner

@paudley paudley commented Nov 14, 2025

This pull request adds a smoke test for the Docker image in the CI workflow and improves the PostgreSQL configuration rendering script to better handle initial and subsequent renders. The main changes focus on increasing reliability and correctness during container initialization and configuration updates.

CI Workflow Improvements:

  • Added a smoke test step to the CI workflow (.github/workflows/ci.yml) that starts a PostgreSQL Docker container, checks its readiness, and runs a simple query to verify the image works as expected. The container is always cleaned up after the test.

PostgreSQL Initialization Script Enhancements:

  • Introduced a first_render flag in postgres/initdb/00-render-config.sh to distinguish between initial configuration and refresh scenarios, improving the logic for rendering configs.
  • Updated the config rendering logic to reload PostgreSQL on initial render and restart it only when refreshing configuration, reducing unnecessary restarts and improving reliability.

@paudley paudley self-assigned this Nov 14, 2025
Copilot AI review requested due to automatic review settings November 14, 2025 00:06
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI review requested due to automatic review settings November 14, 2025 01:41
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +23 to +39
attempts=${PGHERO_DB_WAIT_ATTEMPTS:-90}
delay=2
attempt=1
while [ "${attempt}" -le "${attempts}" ]; do
if DATABASE_URL="${DATABASE_URL}" bundle exec ruby -e "require 'pg'; conn = PG.connect(ENV['DATABASE_URL']); conn.exec('SELECT 1'); conn.close" >/dev/null 2>&1; then
return 0
fi
echo "[pghero] waiting for PostgreSQL at ${POSTGRES_HOST}:${POSTGRES_PORT} (attempt ${attempt})" >&2
sleep "${delay}"
if [ $((attempt % 10)) -eq 0 ] && [ "${delay}" -lt 10 ]; then
delay=$((delay + 1))
fi
attempt=$((attempt + 1))
done
echo "[pghero] timed out waiting for PostgreSQL" >&2
exit 1
}
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The wait_for_database function body is incorrectly indented with tabs. The function body should have consistent indentation aligned with typical shell function conventions. Remove the extra indentation from lines 23-39.

Suggested change
attempts=${PGHERO_DB_WAIT_ATTEMPTS:-90}
delay=2
attempt=1
while [ "${attempt}" -le "${attempts}" ]; do
if DATABASE_URL="${DATABASE_URL}" bundle exec ruby -e "require 'pg'; conn = PG.connect(ENV['DATABASE_URL']); conn.exec('SELECT 1'); conn.close" >/dev/null 2>&1; then
return 0
fi
echo "[pghero] waiting for PostgreSQL at ${POSTGRES_HOST}:${POSTGRES_PORT} (attempt ${attempt})" >&2
sleep "${delay}"
if [ $((attempt % 10)) -eq 0 ] && [ "${delay}" -lt 10 ]; then
delay=$((delay + 1))
fi
attempt=$((attempt + 1))
done
echo "[pghero] timed out waiting for PostgreSQL" >&2
exit 1
}
attempts=${PGHERO_DB_WAIT_ATTEMPTS:-90}
delay=2
attempt=1
while [ "${attempt}" -le "${attempts}" ]; do
if DATABASE_URL="${DATABASE_URL}" bundle exec ruby -e "require 'pg'; conn = PG.connect(ENV['DATABASE_URL']); conn.exec('SELECT 1'); conn.close" >/dev/null 2>&1; then
return 0
fi
echo "[pghero] waiting for PostgreSQL at ${POSTGRES_HOST}:${POSTGRES_PORT} (attempt ${attempt})" >&2
sleep "${delay}"
if [ $((attempt % 10)) -eq 0 ] && [ "${delay}" -lt 10 ]; then
delay=$((delay + 1))
fi
attempt=$((attempt + 1))
done
echo "[pghero] timed out waiting for PostgreSQL" >&2
exit 1
}

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings November 14, 2025 05:39
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +132 to +134
set -euo pipefail
cleanup() { ./scripts/manage.sh down >/dev/null 2>&1 || true; }
trap cleanup EXIT
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The trap cleanup EXIT will execute when this step finishes, immediately tearing down the stack after it's brought up. This means the next step "Run marker tests" will try to interact with a stack that has already been brought down, causing tests to fail.

Remove the cleanup trap and the set -euo pipefail line from this preflight step, or remove the preflight step entirely if the test suite handles stack bring-up itself.

Suggested change
set -euo pipefail
cleanup() { ./scripts/manage.sh down >/dev/null 2>&1 || true; }
trap cleanup EXIT

Copilot uses AI. Check for mistakes.
Comment on lines +180 to +181
env:
PGPASSWORD: thinice-test
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exposing credentials in plaintext environment variables is a security risk. While this is a test environment, it's better practice to avoid plaintext passwords in CI configuration files.

Consider using GitHub secrets or at minimum, use the PGPASSFILE mechanism instead of PGPASSWORD.

Copilot uses AI. Check for mistakes.
Comment on lines +81 to +82
containers=$(docker ps -a --format '{{.Names}}' 2>/dev/null | grep -E 'core_data|postgres' || true)
for name in ${containers}; do
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The unquoted variable in the for loop can cause word splitting issues if container names contain spaces or special characters. While container names typically don't contain spaces, it's a best practice to properly quote variables in shell scripts.

Change line 82 to use a while read loop for safer iteration:

docker ps -a --format '{{.Names}}' 2>/dev/null | grep -E 'core_data|postgres' | while IFS= read -r name; do
	collect_container_artifacts "${name}"
done
Suggested change
containers=$(docker ps -a --format '{{.Names}}' 2>/dev/null | grep -E 'core_data|postgres' || true)
for name in ${containers}; do
docker ps -a --format '{{.Names}}' 2>/dev/null | grep -E 'core_data|postgres' | while IFS= read -r name; do

Copilot uses AI. Check for mistakes.
Comment on lines +55 to +57
set -euo pipefail
cleanup() { ./scripts/manage.sh down >/dev/null 2>&1 || true; }
trap cleanup EXIT
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The trap cleanup EXIT will execute when this step finishes, immediately tearing down the stack after it's brought up. This means the next step "Run core_data smoke workflow" will try to interact with a stack that has already been brought down, causing the test to fail.

Remove the cleanup trap and the set -euo pipefail line from this preflight step, or remove the preflight step entirely if the test suite handles stack bring-up itself.

Suggested change
set -euo pipefail
cleanup() { ./scripts/manage.sh down >/dev/null 2>&1 || true; }
trap cleanup EXIT

Copilot uses AI. Check for mistakes.
@paudley paudley merged commit 5445c28 into main Nov 14, 2025
18 checks passed
@paudley paudley deleted the is_ready_fails branch November 14, 2025 05:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants