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 →
- 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"] - Point the app at
localhost(job on host) withenv: DATABASE_URL: postgres://postgres:test@localhost:5432/app. - 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.
More on Pipeline Design & Triggers
You join a team whose single 900-line workflow runs everything on every push to every branch. How do you restructure it?IntermediatePushing to a PR branch runs CI twice (once for push, once for pull_request). How do you fix it?BeginnerProduct wants a "Deploy to staging" button that lets QA pick a version. Design it.BeginnerA nightly security scan should run at 02:00 India time on weekdays and also be runnable on demand. Write it.BeginnerYour team wants preview environments per PR on EKS, destroyed when the PR closes. Design the workflow.AdvancedTwo workflows must run in sequence: CI then a separate deploy workflow owned by another team. How do you link them?Intermediate