Skip to content

ci: verify if psql is installed #4

ci: verify if psql is installed

ci: verify if psql is installed #4

Workflow file for this run

name: postgres tests
on:
push:
pull_request:
types: [opened, synchronize, reopened]
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: reasn
jobs:
postgres-tests:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./Database
services:
postgres:
image: postgres:16
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
env:
POSTGRES_PASSWORD: ${{ env.POSTGRES_PASSWORD }}
steps:
- uses: actions/checkout@v4
- run: psql --help
- name: Initialize database
run: |
psql -U ${{ env.POSTGRES_USER }} -d ${{ env.POSTGRES_DB }} -f init-db.sql
psql -U ${{ env.POSTGRES_USER }} -d ${{ env.POSTGRES_DB }} -f init-constraints.sql
- name: Initialize development data
run: |
psql -U ${{ env.POSTGRES_USER }} -d ${{ env.POSTGRES_DB }} -f init-dev-data.sql
- name: Verify data initialization correctness
run: |
docker logs "${{ job.services.postgres.id }}" 2>&1 | tee "postgres-logs-commit-${{ github.sha }}.log"
if grep -q -i error postgres-logs-commit-${{ github.sha }}.log; then exit 1; fi
- name: Upload captured logs
uses: actions/upload-artifact@v4
if: ${{ failure() }}
with:
name: postgres-logs-commit-${{ github.sha }}
path: postgres-logs-commit-${{ github.sha }}.log
retention-days: 14