Files
relspecgo/.github/workflows/integration-tests.yml
Hein b55737ab4c
Some checks failed
CI / Test (1.24) (push) Successful in -25m42s
CI / Test (1.25) (push) Successful in -25m40s
CI / Build (push) Successful in -25m54s
CI / Lint (push) Successful in -25m27s
Integration Tests / Integration Tests (push) Failing after -25m48s
Fixed linting issues
2025-12-28 14:51:19 +02:00

92 lines
2.8 KiB
YAML

name: Integration Tests
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
integration-tests:
name: Integration Tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.25'
- name: Cache Go modules
uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- 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
run: |
docker exec relspec-test-postgres psql -U relspec -d relspec_test -f /tmp/init.sql
- name: Verify database setup
run: |
echo "Verifying database initialization..."
docker exec relspec-test-postgres psql -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,
(SELECT COUNT(*) FROM pg_views WHERE schemaname NOT IN ('pg_catalog', 'information_schema')) as views,
(SELECT COUNT(*) FROM pg_sequences WHERE schemaname NOT IN ('pg_catalog', 'information_schema')) as sequences;
"
- name: Run integration tests
env:
RELSPEC_TEST_PG_CONN: postgres://relspec:relspec_test_password@localhost:5432/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."