From 0fcce03c20955fc67f14fb424783d301104f661b Mon Sep 17 00:00:00 2001 From: shishantbiswas Date: Fri, 25 Sep 2026 09:41:21 +0000 Subject: [PATCH] Add .github/workflows/db.test.yaml --- .github/workflows/db.test.yaml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/db.test.yaml diff --git a/.github/workflows/db.test.yaml b/.github/workflows/db.test.yaml new file mode 100644 index 00000000..6f294054 --- /dev/null +++ b/.github/workflows/db.test.yaml @@ -0,0 +1,34 @@ +name: Run Postgres Tests +on: [push] + +jobs: + test-db: + runs-on: ubuntu-latest + + # Define PostgreSQL as a service container + services: + postgres: + image: postgres:16 + env: + POSTGRES_USER: test_user + POSTGRES_PASSWORD: test_password + POSTGRES_DB: test_db + # Ensure the runner waits for the database to be fully up and ready + options: >- + --health-cmd pg_isready + --health-interval 5s + --health-retries 5 + ports: + - 5432:5432 + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Connect to Postgres + run: | + # Install postgres-client to test the connection (if using an alpine/ubuntu base runner) + sudo apt-get update && sudo apt-get install -y postgresql-client + + # Query the service using the service name 'postgres' as the host + PGPASSWORD=test_password psql -h postgres -U test_user -d test_db -c "SELECT version();"