Files
telecom-platform/.github/workflows/ci.yml
T
nutcas3 87dd487d48 refactor: Replace custom migration runner with goose CLI tool in CI and deployment workflows
- Install goose CLI tool using go install in CI and deploy workflows
- Replace custom migration command (go run cmd/migrate/main.go --action=up) with goose postgres command
- Remove working-directory specification from CI migration step
- Update commented kubectl exec commands in deploy workflow to use goose instead of custom runner
- Simplify migration execution by using standardized goose tool across all environments
2026-04-29 02:54:08 +03:00

351 lines
9.6 KiB
YAML

name: CI
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
jobs:
api-server-test:
name: API Server Tests
runs-on: ubuntu-latest
services:
postgres:
image: postgres:15
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
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
cache: true
cache-dependency-path: apps/api-server/go.sum
- name: Install dependencies
working-directory: apps/api-server
run: go mod download
- 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 linter
working-directory: apps/api-server
run: |
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
golangci-lint run --timeout 5m || true
- name: Run tests
working-directory: apps/api-server
env:
DB_HOST: localhost
DB_PORT: 5432
DB_USER: test_user
DB_PASSWORD: test_password
DB_NAME: test_db
run: go test -v -race -coverprofile=coverage.out ./internal/services/...
- name: Upload coverage
uses: codecov/codecov-action@v4
with:
files: apps/api-server/coverage.out
flags: api-server
continue-on-error: true
- name: Build API server
working-directory: apps/api-server
run: go build -o bin/api-server ./cmd/
carrier-connector-test:
name: Carrier Connector Tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
cache: true
cache-dependency-path: apps/carrier-connector/go.sum
- name: Install dependencies
working-directory: apps/carrier-connector
run: go mod download
- name: Run linter
working-directory: apps/carrier-connector
run: |
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
golangci-lint run --timeout 5m || true
- name: Run tests
working-directory: apps/carrier-connector
run: go test -v -race ./... || true
- name: Build carrier connector
working-directory: apps/carrier-connector
run: go build -o bin/carrier-connector .
charging-engine-test:
name: Charging Engine Tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@v1
with:
toolchain: '1.94'
- name: Cache Rust dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Install dependencies
working-directory: apps/charging-engine
run: cargo fetch
- name: Run tests
working-directory: apps/charging-engine
run: cargo test --release || true
- name: Build charging engine
working-directory: apps/charging-engine
run: cargo build --release
packet-gateway-test:
name: Packet Gateway Tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@v1
with:
toolchain: '1.94'
- name: Cache Rust dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Install dependencies
working-directory: apps/packet-gateway
run: cargo fetch
- name: Run tests
working-directory: apps/packet-gateway
run: cargo test --release || true
- name: Build packet gateway
working-directory: apps/packet-gateway
run: cargo build --release
cli-test:
name: CLI Tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
cache: true
cache-dependency-path: apps/cli/go.sum
- name: Install dependencies
working-directory: apps/cli
run: go mod download
- name: Run linter
working-directory: apps/cli
run: |
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
golangci-lint run --timeout 5m || true
- name: Run tests
working-directory: apps/cli
run: go test -v -race ./... || true
- name: Build CLI
working-directory: apps/cli
run: go build -o bin/telecom-cli .
web-dashboard-test:
name: Web Dashboard Tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '24'
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Setup pnpm cache
uses: actions/cache@v4
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
working-directory: apps/web-dashboard
run: pnpm install --no-frozen-lockfile
- name: Run linter
working-directory: apps/web-dashboard
run: pnpm run lint || true
- name: Run type check
working-directory: apps/web-dashboard
run: npx tsc --noEmit || true
- name: Build
working-directory: apps/web-dashboard
run: pnpm run build
docker-build:
name: Docker Build
runs-on: ubuntu-latest
needs: [api-server-test, carrier-connector-test, charging-engine-test, packet-gateway-test, cli-test, web-dashboard-test]
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build API server image
uses: docker/build-push-action@v5
with:
context: .
file: ./deployments/docker/api-server.Dockerfile
push: false
tags: telecom-platform/api-server:latest
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build carrier connector image
uses: docker/build-push-action@v5
with:
context: .
file: ./deployments/docker/carrier-connector.Dockerfile
push: false
tags: telecom-platform/carrier-connector:latest
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build charging engine image
uses: docker/build-push-action@v5
with:
context: .
file: ./deployments/docker/charging-engine.Dockerfile
push: false
tags: telecom-platform/charging-engine:latest
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build packet gateway image
uses: docker/build-push-action@v5
with:
context: .
file: ./deployments/docker/packet-gateway.Dockerfile
push: false
tags: telecom-platform/packet-gateway:latest
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build CLI image
uses: docker/build-push-action@v5
with:
context: .
file: ./deployments/docker/cli.Dockerfile
push: false
tags: telecom-platform/cli:latest
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build web dashboard image
uses: docker/build-push-action@v5
with:
context: .
file: ./deployments/docker/web-dashboard.Dockerfile
push: false
tags: telecom-platform/web-dashboard:latest
cache-from: type=gha
cache-to: type=gha,mode=max
security-scan:
name: Security Scan
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
scan-ref: '.'
format: 'sarif'
output: 'trivy-results.sarif'
continue-on-error: true
- name: Upload Trivy scan results
uses: github/codeql-action/upload-sarif@v3
if: always()
with:
sarif_file: 'trivy-results.sarif'
continue-on-error: true