Interview Prep/GitHub Actions/Pipeline Design & Triggers

You need to run integration tests against Postgres and Redis in CI. How do you set it up?

BeginnerScenarioPipeline Design & Triggers
Answer

Situation read → Service containers are the native fit.

What I'd do →

  1. Declare services with health checks:
    services:
      postgres:
        image: postgres:16
        env: { POSTGRES_PASSWORD: test, POSTGRES_DB: app }
        ports: ["5432:5432"]
        options: --health-cmd "pg_isready -U postgres" --health-interval 5s --health-retries 10
      redis:
        image: redis:7
        ports: ["6379:6379"]
    
  2. Point the app at localhost (job on host) with env: DATABASE_URL: postgres://postgres:test@localhost:5432/app.
  3. Run migrations then tests.

Why → Services start before steps and are torn down automatically; health options prevent "connection refused" races.

Interview tip → Explain localhost vs service-name networking for host vs container jobs.

All GitHub Actions questions Roadmap: GitHub Actions

More on Pipeline Design & Triggers