ci: add explicit wait for PostgreSQL and database creation step

- Add pg_isready wait loop to ensure PostgreSQL service is fully ready
- Run mix ecto.create explicitly before tests to prevent connection errors
- Fixes 'connection refused' errors when database service is still starting
This commit is contained in:
Graham McIntire 2026-03-05 10:02:39 -06:00
parent 139348f2a0
commit 56d9878130
No known key found for this signature in database

View file

@ -58,6 +58,20 @@ jobs:
- name: Install dependencies
run: mix deps.get
- name: Wait for PostgreSQL
run: |
until pg_isready -h localhost -p 5432 -U postgres; do
echo "Waiting for PostgreSQL..."
sleep 2
done
echo "PostgreSQL is ready!"
- name: Setup database
run: mix ecto.create
env:
MIX_ENV: test
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/towerops_test
- name: Check code formatting
run: mix format --check-formatted