From 5f9fd667230b4b7f3b3f7a4cf1f6f7fcb882a875 Mon Sep 17 00:00:00 2001 From: Manuel Bustillo Date: Tue, 30 Jul 2024 21:16:43 +0200 Subject: [PATCH 1/6] Increase number of retries for Postgres health checks --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 30b9997..8eb7bdd 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -17,7 +17,7 @@ jobs: --health-cmd pg_isready --health-interval 10s --health-timeout 5s - --health-retries 5 + --health-retries 30 ports: - 5432 steps: From 4ff719fa1f0715993456378cf88b0c005b15a659 Mon Sep 17 00:00:00 2001 From: Manuel Bustillo Date: Tue, 30 Jul 2024 21:26:44 +0200 Subject: [PATCH 2/6] Revert "Increase number of retries for Postgres health checks" This reverts commit 5f9fd667230b4b7f3b3f7a4cf1f6f7fcb882a875. --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8eb7bdd..30b9997 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -17,7 +17,7 @@ jobs: --health-cmd pg_isready --health-interval 10s --health-timeout 5s - --health-retries 30 + --health-retries 5 ports: - 5432 steps: From eade9f031890c84ef741ddd605290c1942fca20c Mon Sep 17 00:00:00 2001 From: Manuel Bustillo Date: Tue, 30 Jul 2024 21:30:16 +0200 Subject: [PATCH 3/6] Explicitly wait for Postgres to be ready to accept connections --- .github/workflows/tests.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 30b9997..8341f66 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -26,6 +26,13 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} - uses: ruby/setup-ruby@v1 - run: bundle install + - name: Wait until Postgres is ready to accept connections + run: | + until pg_isready -h postgres -U postgres -d postgres + do + sleep 1 + echo "Trying again" + done - run: | bundle exec rake db:create db:schema:load bundle exec rspec From 0d82ef3d40a834c222294d5163d082d05d9dbe67 Mon Sep 17 00:00:00 2001 From: Manuel Bustillo Date: Tue, 30 Jul 2024 21:33:02 +0200 Subject: [PATCH 4/6] Install psql client --- .github/workflows/tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8341f66..8b43ded 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -28,6 +28,7 @@ jobs: - run: bundle install - name: Wait until Postgres is ready to accept connections run: | + apt-get update && apt-get install -f -y postgresql-client until pg_isready -h postgres -U postgres -d postgres do sleep 1 From 424a980e69830d100437e26fe989c34c54a60ec6 Mon Sep 17 00:00:00 2001 From: Manuel Bustillo Date: Tue, 30 Jul 2024 21:37:22 +0200 Subject: [PATCH 5/6] Remove redundant creation of db --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8b43ded..5da2704 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -35,7 +35,7 @@ jobs: echo "Trying again" done - run: | - bundle exec rake db:create db:schema:load + bundle exec rake db:schema:load bundle exec rspec env: RAILS_ENV: test From 49bbea1364ad2296cbdc3bbf17c2d6d6d159f228 Mon Sep 17 00:00:00 2001 From: Manuel Bustillo Date: Wed, 31 Jul 2024 00:41:48 +0200 Subject: [PATCH 6/6] Remove optional parameters that are not needed --- .github/workflows/tests.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5da2704..eefea88 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -13,11 +13,6 @@ jobs: env: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres - options: >- - --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 ports: - 5432 steps: