Manual docker
This commit is contained in:
44
.github/workflows/integration-tests.yml
vendored
44
.github/workflows/integration-tests.yml
vendored
@@ -11,21 +11,6 @@ jobs:
|
|||||||
name: Integration Tests
|
name: Integration Tests
|
||||||
runs-on: ubuntu-latest
|
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:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -46,18 +31,21 @@ jobs:
|
|||||||
- name: Download dependencies
|
- name: Download dependencies
|
||||||
run: go mod download
|
run: go mod download
|
||||||
|
|
||||||
- name: Install PostgreSQL client
|
- name: Start PostgreSQL container
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update
|
docker run -d \
|
||||||
sudo apt-get install -y postgresql-client
|
--name relspec-test-postgres \
|
||||||
|
-e POSTGRES_USER=relspec \
|
||||||
|
-e POSTGRES_PASSWORD=relspec_test_password \
|
||||||
|
-e POSTGRES_DB=relspec_test \
|
||||||
|
-p 5439:5432 \
|
||||||
|
postgres:16-alpine
|
||||||
|
|
||||||
- name: Wait for PostgreSQL to be ready
|
- name: Wait for PostgreSQL to be ready
|
||||||
env:
|
|
||||||
PGPASSWORD: relspec_test_password
|
|
||||||
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 pg_isready -h localhost -p 5439 -U relspec > /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!"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
@@ -68,17 +56,13 @@ jobs:
|
|||||||
sleep 2
|
sleep 2
|
||||||
|
|
||||||
- name: Initialize test database
|
- name: Initialize test database
|
||||||
env:
|
|
||||||
PGPASSWORD: relspec_test_password
|
|
||||||
run: |
|
run: |
|
||||||
psql -h localhost -p 5439 -U relspec -d relspec_test -f 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
|
||||||
env:
|
|
||||||
PGPASSWORD: relspec_test_password
|
|
||||||
run: |
|
run: |
|
||||||
echo "Verifying database initialization..."
|
echo "Verifying database initialization..."
|
||||||
psql -h localhost -p 5439 -U relspec -d relspec_test -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,
|
||||||
@@ -90,3 +74,9 @@ jobs:
|
|||||||
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
|
||||||
run: make test-integration
|
run: make test-integration
|
||||||
|
|
||||||
|
- name: Stop PostgreSQL container
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
docker stop relspec-test-postgres || true
|
||||||
|
docker rm relspec-test-postgres || true
|
||||||
|
|||||||
Reference in New Issue
Block a user