Update README.md #32
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Integrity Test Suite | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| workflow_dispatch: | |
| env: | |
| FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| services: | |
| postgres: | |
| image: postgres:18 | |
| env: | |
| POSTGRES_DB: ledger_db | |
| POSTGRES_USER: postgres | |
| POSTGRES_PASSWORD: password123 | |
| ports: | |
| - 5432:5432 | |
| options: >- | |
| --health-cmd "pg_isready -U postgres -d ledger_db" | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install PostgreSQL Client | |
| run: sudo apt-get update && sudo apt-get install -y postgresql-client | |
| - name: Run Migrations | |
| env: | |
| PGPASSWORD: password123 | |
| run: | | |
| # We use a fail-safe loop to apply V1-V6 | |
| for file in db/migration/V*.sql; do | |
| echo "Processing $file..." | |
| if [[ "$file" == *"V5"* ]]; then | |
| # Skip V5 if pg_cron library isn't preloaded (common in CI services) | |
| psql -h localhost -U postgres -d ledger_db -c "SHOW shared_preload_libraries;" | grep -q "pg_cron" && \ | |
| psql -h localhost -U postgres -d ledger_db -f "$file" || echo "⚠️ Skipping V5 (pg_cron library not loaded in CI environment)" | |
| else | |
| psql -h localhost -U postgres -d ledger_db -f "$file" || exit 1 | |
| fi | |
| done | |
| - name: Execute Integrity Test Suite | |
| env: | |
| PGPASSWORD: password123 | |
| run: | | |
| # Execute the pure SQL test suite | |
| psql -h localhost -U postgres -d ledger_db -f tests/integrity_suite.sql > test_output.log 2>&1 | |
| cat test_output.log | |
| # Validation Logic | |
| if grep -q "PASSED" test_output.log && ! grep -iq "failed" test_output.log; then | |
| echo "✅ Ledger Integrity Confirmed." | |
| exit 0 | |
| else | |
| echo "❌ Integrity Check Failed." | |
| exit 1 | |
| fi |