..
Some checks failed
CI / Test (1.24) (push) Failing after 38s
CI / Lint (push) Successful in -25m51s
CI / Test (1.25) (push) Successful in -25m45s
CI / Build (push) Successful in 31s
Integration Tests / Integration Tests (push) Failing after -26m1s

This commit is contained in:
2025-12-28 16:20:44 +02:00
parent beb1100d86
commit 196d87bc29

View File

@@ -35,21 +35,18 @@ jobs:
run: | run: |
docker run -d \ docker run -d \
--name relspec-test-postgres \ --name relspec-test-postgres \
--network host \ -p 5439:5432 \
-e POSTGRES_USER=relspec \ -e POSTGRES_USER=relspec \
-e POSTGRES_PASSWORD=relspec_test_password \ -e POSTGRES_PASSWORD=relspec_test_password \
-e POSTGRES_DB=relspec_test \ -e POSTGRES_DB=relspec_test \
-e POSTGRES_HOST_AUTH_METHOD=trust \ postgres:16-alpine
-e PGPORT=5439 \
postgres:16-alpine \
-p 5439
- name: Wait for PostgreSQL to be ready - name: Wait for PostgreSQL to be ready
run: | run: |
echo "Waiting for PostgreSQL to be ready..." echo "Waiting for PostgreSQL to be ready..."
for i in {1..30}; do for i in {1..30}; do
if docker exec relspec-test-postgres pg_isready -U relspec -d relspec_test -p 5439 > /dev/null 2>&1; then if docker exec relspec-test-postgres pg_isready -U relspec -d relspec_test > /dev/null 2>&1; then
echo "PostgreSQL is ready!" echo "PostgreSQL is ready inside container!"
break break
fi fi
echo "Attempt $i/30: Waiting..." echo "Attempt $i/30: Waiting..."
@@ -57,17 +54,24 @@ jobs:
done done
# Give it one more second to fully initialize # Give it one more second to fully initialize
sleep 2 sleep 2
echo "Testing connection from host..."
docker exec relspec-test-postgres psql -U relspec -d relspec_test -p 5439 -c "SELECT version();" || echo "Warning: Connection test failed" - name: Debug network connectivity
run: |
echo "=== Checking port on host ==="
ss -tlnp | grep 5439 || netstat -tlnp | grep 5439 || lsof -i :5439 || echo "Checking with docker..."
docker port relspec-test-postgres
echo ""
echo "=== Testing connection from inside container ==="
docker exec relspec-test-postgres psql -U relspec -d relspec_test -c "SELECT version();"
- name: Initialize test database - name: Initialize test database
run: | run: |
docker exec -i relspec-test-postgres psql -U relspec -d relspec_test -p 5439 < tests/postgres/init.sql docker exec -i relspec-test-postgres psql -U relspec -d relspec_test < tests/postgres/init.sql
- name: Verify database setup - name: Verify database setup
run: | run: |
echo "Verifying database initialization..." echo "Verifying database initialization..."
docker exec relspec-test-postgres psql -U relspec -d relspec_test -p 5439 -c " docker exec relspec-test-postgres psql -U relspec -d relspec_test -c "
SELECT SELECT
(SELECT COUNT(*) FROM pg_namespace WHERE nspname NOT IN ('pg_catalog', 'information_schema', 'pg_toast') AND nspname NOT LIKE 'pg_%') as schemas, (SELECT COUNT(*) FROM pg_namespace WHERE nspname NOT IN ('pg_catalog', 'information_schema', 'pg_toast') AND nspname NOT LIKE 'pg_%') as schemas,
(SELECT COUNT(*) FROM pg_tables WHERE schemaname NOT IN ('pg_catalog', 'information_schema')) as tables, (SELECT COUNT(*) FROM pg_tables WHERE schemaname NOT IN ('pg_catalog', 'information_schema')) as tables,
@@ -75,6 +79,37 @@ jobs:
(SELECT COUNT(*) FROM pg_sequences WHERE schemaname NOT IN ('pg_catalog', 'information_schema')) as sequences; (SELECT COUNT(*) FROM pg_sequences WHERE schemaname NOT IN ('pg_catalog', 'information_schema')) as sequences;
" "
- name: Test Go connection to PostgreSQL
env:
RELSPEC_TEST_PG_CONN: postgres://relspec:relspec_test_password@localhost:5439/relspec_test
run: |
echo "Testing connection using Go (same as integration tests will use)..."
cat > /tmp/test_conn.go << 'EOF'
package main
import (
"context"
"fmt"
"os"
"github.com/jackc/pgx/v5"
)
func main() {
conn, err := pgx.Connect(context.Background(), os.Getenv("RELSPEC_TEST_PG_CONN"))
if err != nil {
fmt.Printf("Connection failed: %v\n", err)
os.Exit(1)
}
defer conn.Close(context.Background())
var version string
err = conn.QueryRow(context.Background(), "SELECT version()").Scan(&version)
if err != nil {
fmt.Printf("Query failed: %v\n", err)
os.Exit(1)
}
fmt.Printf("SUCCESS! Connected to: %s\n", version)
}
EOF
cd /tmp && go mod init testconn && go get github.com/jackc/pgx/v5 && go run test_conn.go
- name: Run integration tests - name: Run integration tests
env: env:
RELSPEC_TEST_PG_CONN: postgres://relspec:relspec_test_password@localhost:5439/relspec_test RELSPEC_TEST_PG_CONN: postgres://relspec:relspec_test_password@localhost:5439/relspec_test