Really?
Some checks failed
CI / Test (1.24) (push) Successful in -25m36s
CI / Test (1.25) (push) Successful in -25m30s
CI / Build (push) Successful in -25m52s
CI / Lint (push) Successful in -25m36s
Integration Tests / Integration Tests (push) Failing after -25m57s

This commit is contained in:
2025-12-28 19:21:15 +02:00
parent 7c6a355458
commit 1d627c74b1

View File

@@ -31,11 +31,28 @@ jobs:
- name: Download dependencies
run: go mod download
- name: Create Docker network and connect runner
run: |
# Create network
docker network create relspec-test-network || true
# Get current container ID (the runner)
RUNNER_CONTAINER_ID=$(cat /proc/self/cgroup | grep 'docker\|kubepods' | head -1 | sed 's/^.*\///' | cut -d':' -f3 | sed 's/^.*\///')
if [ -z "$RUNNER_CONTAINER_ID" ]; then
# Alternative method: use hostname which is often the container ID
RUNNER_CONTAINER_ID=$(hostname)
fi
echo "Runner container ID: $RUNNER_CONTAINER_ID"
# Connect runner to the network so tests can access PostgreSQL by hostname
docker network connect relspec-test-network "$RUNNER_CONTAINER_ID" 2>/dev/null || echo "Already connected or unable to connect"
- name: Start PostgreSQL container
run: |
docker run -d \
--name relspec-test-postgres \
-p 5439:5432 \
--network relspec-test-network \
-e POSTGRES_USER=relspec \
-e POSTGRES_PASSWORD=relspec_test_password \
-e POSTGRES_DB=relspec_test \
@@ -58,19 +75,10 @@ jobs:
- name: Get PostgreSQL connection details
id: pg_connection
run: |
# Get container IP address from Docker bridge network
# This is needed because the runner itself is in a Docker container
CONTAINER_IP=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' relspec-test-postgres)
if [ -z "$CONTAINER_IP" ]; then
echo "ERROR: Could not get container IP address"
docker inspect relspec-test-postgres
exit 1
fi
echo "Container IP: $CONTAINER_IP"
echo "Using container IP: $CONTAINER_IP:5432"
echo "pg_host=$CONTAINER_IP" >> $GITHUB_OUTPUT
# Use container name for DNS resolution on the Docker network
# This works because both containers are on the same custom network
echo "Using container hostname: relspec-test-postgres:5432"
echo "pg_host=relspec-test-postgres" >> $GITHUB_OUTPUT
echo "pg_port=5432" >> $GITHUB_OUTPUT
echo ""
@@ -93,11 +101,11 @@ jobs:
"
- name: Test Go connection to PostgreSQL
env:
RELSPEC_TEST_PG_CONN: postgres://relspec:relspec_test_password@${{ steps.pg_connection.outputs.pg_host }}:${{ steps.pg_connection.outputs.pg_port }}/relspec_test
run: |
echo "Testing connection using Go (same as integration tests will use)..."
echo "Connection string: postgres://relspec:***@${{ steps.pg_connection.outputs.pg_host }}:${{ steps.pg_connection.outputs.pg_port }}/relspec_test"
# Create test program
mkdir -p /tmp/testconn
cat > /tmp/testconn/test_conn.go << 'EOF'
package main
@@ -123,7 +131,17 @@ jobs:
fmt.Printf("SUCCESS! Connected to: %s\n", version)
}
EOF
cd /tmp/testconn && go mod init testconn && go mod tidy && go run test_conn.go
# Build the test program
cd /tmp/testconn && go mod init testconn && go mod tidy && go build -o test_conn
# Run in a container on the same network
docker run --rm \
--network relspec-test-network \
-e RELSPEC_TEST_PG_CONN="postgres://relspec:relspec_test_password@${{ steps.pg_connection.outputs.pg_host }}:${{ steps.pg_connection.outputs.pg_port }}/relspec_test" \
-v /tmp/testconn:/app \
golang:1.25-alpine \
/app/test_conn
- name: Run integration tests
env:
@@ -135,3 +153,4 @@ jobs:
run: |
docker stop relspec-test-postgres || true
docker rm relspec-test-postgres || true
docker network rm relspec-test-network || true