13 / 48 · 16 CI/CD Pipelines · Testing Pyramid in CI← prev⊞ allnext →☰ Read as one page
3.3Stage 2: On Pull Request / Merge to Develop (Minutes)
This stage runs when code is proposed for integration. It catches issues that require real infrastructure -- databases, message queues, external service contracts.
What runs here:
- Integration tests against real databases and services
- API contract tests (Pact, Schemathesis)
- Component tests (individual services or modules tested with real dependencies)
- Security scanning (SAST tools like Snyk, Semgrep)
# Example: Integration test job with database service
integration-tests:
needs: lint-and-unit
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16
env:
POSTGRES_DB: test_db
POSTGRES_PASSWORD: testpass
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
redis:
image: redis:7
ports:
- 6379:6379
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
cache: 'npm'
- run: npm ci
- run: npm run db:migrate
env:
DATABASE_URL: postgres://postgres:testpass@localhost:5432/test_db
- run: npm run test:integration
env:
DATABASE_URL: postgres://postgres:testpass@localhost:5432/test_db
REDIS_URL: redis://localhost:6379
Target time: Under 10 minutes. This is the stage most prone to slowness -- monitor it closely.