From 2aefaa3c56b678e047530289ef3d2d595bab901d Mon Sep 17 00:00:00 2001 From: Felipe Andrade Date: Mon, 18 Nov 2024 20:50:33 -0300 Subject: [PATCH] ci: fix cucumber tests --- .github/workflows/ci.yml | 30 ++++++++++++++++++++++-------- config/database.yml.github-actions | 1 + 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 00a3072..070f8aa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,13 +18,17 @@ jobs: ruby-version: [2.6, 2.7, 3.0] services: postgres: - image: postgres:12.1-alpine + image: postgres:12 ports: - 5432:5432 env: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres - options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 steps: - name: Checkout Project uses: actions/checkout@v3 @@ -41,15 +45,25 @@ jobs: - name: Setup Database run: | cp config/database.yml.github-actions config/database.yml - env: - RAILS_ENV: test - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - - name: Test with RSpec + # - name: Test with RSpec + # env: + # RAILS_ENV: "test" + # POSTGRES_USER: postgres + # POSTGRES_PASSWORD: postgres + # run: | + # bundle exec rspec + + - name: Test with Cucumber env: RAILS_ENV: "test" POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres run: | - bundle exec rspec + until psql --user=postgres --dbname=postgres --command "\q" >/dev/null 2>&1 || [ "$RETRIES" -eq "$MAX_RETRIES" ]; do + echo >&2 "Waiting $((RETRIES += 1))s for the \"$PGHOST\" PostgreSQL server to start. $((MAX_RETRIES - RETRIES)) remaining attempts..." + sleep "$RETRIES" + false + done || exit 1 + echo "> Postgres is ready!" + bundle exec cucumber diff --git a/config/database.yml.github-actions b/config/database.yml.github-actions index 0724691..e12f307 100644 --- a/config/database.yml.github-actions +++ b/config/database.yml.github-actions @@ -1,6 +1,7 @@ test: adapter: postgresql host: localhost + port: 5432 encoding: unicode database: github-actions pool: 20