Skip to content

Commit

Permalink
Adding test file to perform run in container
Browse files Browse the repository at this point in the history
  • Loading branch information
susan-pgedge committed Jan 16, 2025
1 parent 83e5403 commit 645903c
Showing 1 changed file with 31 additions and 42 deletions.
73 changes: 31 additions & 42 deletions tests_in_docker.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,23 @@
name: Test PostgreSQL Matrix with Python
run-name: ${{ github.actor }} is running the test schedules.
name: Test PostgreSQL in Docker

on:
push:
branches:
- GH_actions_test
- main

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
pgver: [14, 15, 16, 17] # PostgreSQL versions to test
container:
image: python:3.10 # Use a Python Docker image for the job
options: --network host # Use host networking to allow PostgreSQL access

services:
postgres:
image: postgres:${{ matrix.pgver }}
image: postgres:${{ matrix.postgres-version }}
ports:
- 6432:5432
- 6433:5433
- 6434:5434
- 6435:5435
- 6436:5436
- 6437:5437
- 6438:5438
- 6439:5439
- 5432:5432
env:
POSTGRES_USER: lcusr
POSTGRES_PASSWORD: password
Expand All @@ -35,48 +28,44 @@ jobs:
--health-timeout 5s
--health-retries 5
steps:
# Step 1: Checkout Code
- name: Checkout code
uses: actions/checkout@v4

# Step 2: Set up Python
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: 3.10
strategy:
matrix:
postgres-version: [14, 15, 16, 17]

# Step 3: Install Dependencies
steps:
# Step 1: Install Dependencies
- name: Install Python Dependencies
run: |
python -m pip install --upgrade pip
apt-get update
apt-get install -y build-essential
pip install --upgrade pip
pip install psycopg psycopg2
# Step 4: Verify PostgreSQL Connection
# Step 2: Verify PostgreSQL Connection
- name: Verify PostgreSQL Connection
run: |
echo "Testing connection to PostgreSQL (Version: ${{ matrix.pgver }})..."
echo "Testing connection to PostgreSQL (Version: ${{ matrix.postgres-version }})..."
python -c "
import psycopg2
conn = psycopg2.connect(
dbname='lcdb',
user='lcusr',
password='password',
host='localhost',
port=6432
)
print('Successfully connected to PostgreSQL version ${{ matrix.pgver }}!')
import psycopg2
conn = psycopg2.connect(
dbname='lcdb',
user='lcusr',
password='password',
host='localhost',
port=5432
)
print('Successfully connected to PostgreSQL version ${{ matrix.postgres-version }}!')
conn.close()
"
# Step 5: Run Test Harness
# Step 3: Run Test Harness
- name: Run Test Harness (runner.py)
run: |
python runner.py -c test/t/lib/${{ matrix.pgver }}config.env -s test/schedule_files/script_file -k
python runner.py
# Step 6: Publish Test Logs to Artifacts
# Step 4: Publish Test Logs
- name: Upload Test Log
uses: actions/upload-artifact@v3
with:
name: latest-test-log-${{ matrix.pgver }}
name: latest-test-log-${{ matrix.postgres-version }}
path: latest.log

0 comments on commit 645903c

Please sign in to comment.