GoofyCubes
18

Chapter 18

CI/CD for GenAI Projects

Learning Objective

Learn how code moves safely from developer machines to production environments.

What it means

CI/CD stands for Continuous Integration and Continuous Delivery or Deployment. CI automatically builds and tests code. CD automates deployment to environments such as development, QA, UAT, and production.

Why it matters

GenAI services must be tested, packaged, scanned, and deployed consistently. CI/CD reduces manual errors and improves release control. It can also run prompt evaluation tests and check for security issues.

Architecture Flow

Developer CommitPull RequestBuildUnit TestsLintSecurity ScanDocker BuildDeploy to DevApprovalDeploy to Production

Code: GitHub Actions Workflow

name: genai-ci

on:
  pull_request:
    branches: [ develop, main ]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: '3.11'
      - name: Install dependencies
        run: pip install -r requirements.txt
      - name: Run tests
        run: pytest
      - name: Lint
        run: python -m py_compile app.py

Common Mistakes

  • Manual deployments.
  • Skipping tests for prompt changes.
  • No rollback strategy.
  • Secrets stored in repository.
  • No environment separation.

Interview Q&A

Q: What is CI/CD?

A: CI/CD automates build, test, validation, packaging, and deployment so software can move safely and consistently across environments.

Q: What would you include in GenAI CI/CD?

A: Unit tests, prompt tests, retrieval tests, security scanning, Docker builds, dependency checks, and controlled deployments.

Architect Takeaway

CI/CD is not just faster deployment. It is release governance, repeatability, and risk reduction.