name: Backend API CI on: push: paths: - "veza-backend-api/**" - ".github/workflows/backend-ci.yml" pull_request: paths: - "veza-backend-api/**" - ".github/workflows/backend-ci.yml" jobs: test-unit: runs-on: ubuntu-latest defaults: run: working-directory: veza-backend-api steps: - uses: actions/checkout@v4 - name: Set up Go uses: actions/setup-go@v5 with: go-version: "1.23" cache: true - name: Download deps run: go mod download - name: Run govulncheck run: | go install golang.org/x/vuln/cmd/govulncheck@latest govulncheck ./... - name: Run unit tests run: go test ./internal/handlers/... ./internal/services/... -short -coverprofile=coverage.out -covermode=atomic -timeout 5m - name: Upload coverage report uses: actions/upload-artifact@v4 with: name: go-coverage path: veza-backend-api/coverage.out test-integration: runs-on: ubuntu-latest services: postgres: image: postgres:16-alpine env: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres POSTGRES_DB: veza_test ports: - 5432:5432 options: >- --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 redis: image: redis:7-alpine ports: - 6379:6379 options: >- --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5 env: DATABASE_URL: postgresql://postgres:postgres@localhost:5432/veza_test?sslmode=disable REDIS_URL: redis://localhost:6379 JWT_SECRET: test-jwt-secret-for-ci APP_ENV: test defaults: run: working-directory: veza-backend-api steps: - uses: actions/checkout@v4 - name: Set up Go uses: actions/setup-go@v5 with: go-version: "1.23" cache: true - name: Download deps run: go mod download - name: Run migrations run: go run cmd/migrate_tool/main.go continue-on-error: true - name: Run integration tests run: go test -tags=integration ./internal/... -timeout 15m