fix(ci): stabilize database connection and Python environment
Validators (Pushes and Pull Requests) / UI & Storage Validation (push) Failing after 11s
Validators (Pushes and Pull Requests) / Database & Schema Validation (push) Successful in 11s
Validators (Pushes and Pull Requests) / Core Validators & Database Setup (push) Failing after 21s
Validators (Pushes and Pull Requests) / WBS & Audit Validations (push) Has been skipped
Validators (Pushes and Pull Requests) / .NET Contracts (push) Has been skipped
Validators (Pushes and Pull Requests) / Calibration & Performance (push) Has been skipped
Validators (Pushes and Pull Requests) / Operational Report & Decision Packet (push) Has been skipped
Validators (Pushes and Pull Requests) / Security & Secrets (push) Successful in 11s
Validators (Pushes and Pull Requests) / CI Workflow Lint (push) Failing after 11s
Validators (Pushes and Pull Requests) / Notify PR Results (push) Has been skipped
Workflow Lint & Validation / Validate Secrets Contract (push) Successful in 7s
Workflow Lint & Validation / Lint All Workflow Files (push) Failing after 11s
Workflow Lint & Validation / Notify Lint Results (push) Failing after 1s
Validators (Pushes and Pull Requests) / UI & Storage Validation (push) Failing after 11s
Validators (Pushes and Pull Requests) / Database & Schema Validation (push) Successful in 11s
Validators (Pushes and Pull Requests) / Core Validators & Database Setup (push) Failing after 21s
Validators (Pushes and Pull Requests) / WBS & Audit Validations (push) Has been skipped
Validators (Pushes and Pull Requests) / .NET Contracts (push) Has been skipped
Validators (Pushes and Pull Requests) / Calibration & Performance (push) Has been skipped
Validators (Pushes and Pull Requests) / Operational Report & Decision Packet (push) Has been skipped
Validators (Pushes and Pull Requests) / Security & Secrets (push) Successful in 11s
Validators (Pushes and Pull Requests) / CI Workflow Lint (push) Failing after 11s
Validators (Pushes and Pull Requests) / Notify PR Results (push) Has been skipped
Workflow Lint & Validation / Validate Secrets Contract (push) Successful in 7s
Workflow Lint & Validation / Lint All Workflow Files (push) Failing after 11s
Workflow Lint & Validation / Notify Lint Results (push) Failing after 1s
Add PostgreSQL connection retry logic (30 attempts, 2s intervals) to prevent flaky test failures when PostgreSQL service takes time to start. Add Python environment variables: - PYTHONUNBUFFERED: immediate log output (no buffering) - PYTHONDONTWRITEBYTECODE: skip .pyc generation - --no-cache-dir: prevent pip cache issues Fixes intermittent 'connection refused' errors in CI runs. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
+20
-3
@@ -13,6 +13,8 @@ concurrency:
|
|||||||
|
|
||||||
env:
|
env:
|
||||||
DOTNET_VERSION: '9.0.x'
|
DOTNET_VERSION: '9.0.x'
|
||||||
|
PYTHONUNBUFFERED: '1'
|
||||||
|
PYTHONDONTWRITEBYTECODE: '1'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
# ========================================================================
|
# ========================================================================
|
||||||
@@ -76,7 +78,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
# Install from requirements.txt (cache key from setup-python)
|
# Install from requirements.txt (cache key from setup-python)
|
||||||
pip install --disable-pip-version-check --quiet --upgrade pip setuptools wheel
|
pip install --disable-pip-version-check --quiet --upgrade pip setuptools wheel
|
||||||
pip install --disable-pip-version-check --quiet -r requirements.txt psycopg2-binary
|
pip install --disable-pip-version-check --quiet --no-cache-dir -r requirements.txt psycopg2-binary
|
||||||
|
|
||||||
# Verify installation
|
# Verify installation
|
||||||
python3 -c 'import requests, yaml, openpyxl, pytest, psycopg; print("✓ Python dependencies installed")'
|
python3 -c 'import requests, yaml, openpyxl, pytest, psycopg; print("✓ Python dependencies installed")'
|
||||||
@@ -89,8 +91,23 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
which psql || (sudo apt-get update -qq && sudo apt-get install -y -qq postgresql-client)
|
which psql || (sudo apt-get update -qq && sudo apt-get install -y -qq postgresql-client)
|
||||||
|
|
||||||
echo "=== Database Connection Check ==="
|
echo "=== Waiting for PostgreSQL to be ready ==="
|
||||||
psql -U quantengine_ci -d quantenginedb -c "SELECT version();" || exit 1
|
ATTEMPT=0
|
||||||
|
MAX_ATTEMPTS=30
|
||||||
|
while [ $ATTEMPT -lt $MAX_ATTEMPTS ]; do
|
||||||
|
if psql -U quantengine_ci -d quantenginedb -c "SELECT version();" 2>/dev/null; then
|
||||||
|
echo "✓ PostgreSQL is ready"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
ATTEMPT=$((ATTEMPT + 1))
|
||||||
|
echo "Attempt $ATTEMPT/$MAX_ATTEMPTS: PostgreSQL not ready, waiting..."
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ $ATTEMPT -eq $MAX_ATTEMPTS ]; then
|
||||||
|
echo "ERROR: PostgreSQL failed to start after $MAX_ATTEMPTS attempts"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
echo "=== Applying Migrations ==="
|
echo "=== Applying Migrations ==="
|
||||||
for f in $(ls src/dotnet/QuantEngine.Infrastructure/Migrations/V*.sql | sort -V); do
|
for f in $(ls src/dotnet/QuantEngine.Infrastructure/Migrations/V*.sql | sort -V); do
|
||||||
|
|||||||
Reference in New Issue
Block a user