Skip to content

Commit dd023ba

Browse files
committed
Make sure db is ready before running mutant.
1 parent 706ebd8 commit dd023ba

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

.github/workflows/rails_application.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,15 @@ jobs:
5353
subject_groups: ${{ steps.split_subjects.outputs.subject_groups }}
5454
env:
5555
WORKING_DIRECTORY: rails_application
56+
services:
57+
postgres:
58+
image: postgres:17-alpine
59+
env:
60+
POSTGRES_DB: cqrs-es-sample-with-res_test
61+
POSTGRES_PASSWORD: secret
62+
ports:
63+
- 5432:5432
64+
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
5665
steps:
5766
- uses: actions/checkout@v3
5867
- uses: ruby/setup-ruby@v1
@@ -64,6 +73,15 @@ jobs:
6473
id: split_subjects
6574
working-directory: ${{ env.WORKING_DIRECTORY }}
6675
run: |
76+
# Ensure database is ready before listing subjects
77+
echo "Waiting for PostgreSQL to be ready..."
78+
until pg_isready -h localhost -p 5432 -U "postgres" -d "cqrs-es-sample-with-res_test"; do
79+
sleep 1
80+
done
81+
echo "PostgreSQL is ready."
82+
83+
RAILS_ENV=test bundle exec rails db:prepare
84+
6785
SUBJECT_LIST_OUTPUT=$(RAILS_ENV=test bundle exec mutant environment subject list)
6886
# Skip the first line (e.g., "Subjects in environment: 47") and read subjects into an array
6987
mapfile -t subjects_array < <(echo "$SUBJECT_LIST_OUTPUT" | tail -n +2 | sed 's/\x1b\[[0-9;]*m//g' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' | awk 'NF')

0 commit comments

Comments
 (0)