Skip to content

Commit

Permalink
Improve PostgreSQL setup in GitHub Actions workflow
Browse files Browse the repository at this point in the history
Updated the PostgreSQL service configuration in the GitHub Actions workflow for better reliability. Enhanced the 'health-cmd' option to use the correct user parameter, ensuring that health checks connect properly. Added 'DATABASE_URL' environment variable for tests to connect to PostgreSQL. This ensures that the test environment is properly configured and improves stability during CI runs. #123
  • Loading branch information
eliasjpr committed Aug 12, 2024
1 parent 925e1e6 commit f2e014c
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions .github/workflows/crystal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,18 @@ jobs:
services:
postgres:
image: postgres
ports:
- 5432:5432
env:
POSTGRES_PASSWORD: example
POSTGRES_USER: example
POSTGRES_PASSWORD: example
POSTGRES_DB: example
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432
--health-cmd="pg_isready -U postgres"
--health-interval=10s
--health-timeout=5s
--health-retries=5
steps:
- uses: actions/checkout@v3
- name: Update package list and install SQLite and development files
Expand All @@ -78,6 +77,8 @@ jobs:
- name: Check code style
run: crystal tool format --check
- name: Run tests
env:
DATABASE_URL: "postgres://example:example@localhost:5432/example"
run: crystal spec

release:
Expand Down

0 comments on commit f2e014c

Please sign in to comment.