Better integration test.
Some checks failed
CI / Test (1.25) (push) Successful in -25m30s
CI / Lint (push) Successful in -25m32s
CI / Build (push) Successful in -26m1s
Integration Tests / Integration Tests (push) Failing after -26m1s
CI / Test (1.24) (push) Successful in 3m1s

This commit is contained in:
2025-12-28 15:37:21 +02:00
parent 0fb3469dbd
commit 27da24f575
7 changed files with 33 additions and 53 deletions

View File

@@ -1,5 +1,5 @@
name: CI
run-name: "Test on master branch"
on:
push:
branches: [ master ]

View File

@@ -1,5 +1,5 @@
name: Integration Tests
run-name: "Integration Tests"
on:
push:
branches: [ master ]
@@ -11,6 +11,21 @@ jobs:
name: Integration Tests
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_USER: relspec
POSTGRES_PASSWORD: relspec_test_password
POSTGRES_DB: relspec_test
ports:
- 5439:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout code
uses: actions/checkout@v4
@@ -31,41 +46,18 @@ jobs:
- name: Download dependencies
run: go mod download
- name: Start PostgreSQL container
run: |
docker run -d \
--name relspec-test-postgres \
--network host \
-e POSTGRES_USER=relspec \
-e POSTGRES_PASSWORD=relspec_test_password \
-e POSTGRES_DB=relspec_test \
postgres:16-alpine
- name: Wait for PostgreSQL to be ready
run: |
echo "Waiting for PostgreSQL to start..."
for i in {1..30}; do
if docker exec relspec-test-postgres pg_isready -U relspec -d relspec_test > /dev/null 2>&1; then
echo "PostgreSQL is ready!"
break
fi
echo "Waiting... ($i/30)"
sleep 1
done
sleep 2
- name: Copy init script into container
run: |
docker cp tests/postgres/init.sql relspec-test-postgres:/tmp/init.sql
- name: Initialize test database
env:
PGPASSWORD: relspec_test_password
run: |
docker exec relspec-test-postgres psql -U relspec -d relspec_test -f /tmp/init.sql
psql -h localhost -U relspec -d relspec_test -f tests/postgres/init.sql
- name: Verify database setup
env:
PGPASSWORD: relspec_test_password
run: |
echo "Verifying database initialization..."
docker exec relspec-test-postgres psql -U relspec -d relspec_test -c "
psql -h localhost -U relspec -d relspec_test -c "
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_tables WHERE schemaname NOT IN ('pg_catalog', 'information_schema')) as tables,
@@ -75,17 +67,5 @@ jobs:
- name: Run integration tests
env:
RELSPEC_TEST_PG_CONN: postgres://relspec:relspec_test_password@localhost:5432/relspec_test
RELSPEC_TEST_PG_CONN: postgres://relspec:relspec_test_password@localhost:5439/relspec_test
run: make test-integration
- name: Stop PostgreSQL container
if: always()
run: |
docker stop relspec-test-postgres || true
docker rm relspec-test-postgres || true
- name: Summary
if: always()
run: |
echo "Integration tests completed."
echo "PostgreSQL container has been cleaned up."

View File

@@ -1,5 +1,5 @@
name: Release
run-name: "Making Release"
on:
push:
tags: