From 85012f380f034a6ee0d242329234b5a52fb008ae Mon Sep 17 00:00:00 2001 From: nutcas3 Date: Wed, 29 Apr 2026 02:58:48 +0300 Subject: [PATCH] feat: Add PostgreSQL service and database migrations to Rust component test jobs in CI workflow - Upgrade PostgreSQL service from version 15 to 18 in api-server-test job - Add PostgreSQL 18 service configuration to charging-engine-test and packet-gateway-test jobs - Configure database health checks with pg_isready command for all Postgres services - Add goose installation step to charging-engine-test and packet-gateway-test jobs - Add database migration execution step before running tests in Rust components --- .github/workflows/ci.yml | 46 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9bc6fc4..b05af06 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest services: postgres: - image: postgres:15 + image: postgres:18 env: POSTGRES_USER: test_user POSTGRES_PASSWORD: test_password @@ -110,6 +110,20 @@ jobs: charging-engine-test: name: Charging Engine Tests runs-on: ubuntu-latest + services: + postgres: + image: postgres:18 + env: + POSTGRES_USER: test_user + POSTGRES_PASSWORD: test_password + POSTGRES_DB: test_db + ports: + - 5432:5432 + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 steps: - name: Checkout code uses: actions/checkout@v4 @@ -134,6 +148,14 @@ jobs: working-directory: apps/charging-engine run: cargo fetch + - name: Install goose + run: go install github.com/pressly/goose/v3/cmd/goose@latest + + - name: Run database migrations + env: + DATABASE_URL: postgresql://test_user:test_password@localhost:5432/test_db?sslmode=disable + run: goose postgres $DATABASE_URL up migrations + - name: Run tests working-directory: apps/charging-engine run: cargo test --release || true @@ -145,6 +167,20 @@ jobs: packet-gateway-test: name: Packet Gateway Tests runs-on: ubuntu-latest + services: + postgres: + image: postgres:18 + env: + POSTGRES_USER: test_user + POSTGRES_PASSWORD: test_password + POSTGRES_DB: test_db + ports: + - 5432:5432 + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 steps: - name: Checkout code uses: actions/checkout@v4 @@ -169,6 +205,14 @@ jobs: working-directory: apps/packet-gateway run: cargo fetch + - name: Install goose + run: go install github.com/pressly/goose/v3/cmd/goose@latest + + - name: Run database migrations + env: + DATABASE_URL: postgresql://test_user:test_password@localhost:5432/test_db?sslmode=disable + run: goose postgres $DATABASE_URL up migrations + - name: Run tests working-directory: apps/packet-gateway run: cargo test --release || true