Running Tests in CI/CD Pipeline
GitHub Actions Strategy
Overview
Tests are required gates before code merges. Unit tests run on every pull request to catch issues early and ensure code quality.
NOTE
E2E tests are currently excluded from the pipeline. They require additional setup (API/database configuration) and will be integrated in a future phase once those dependencies are established.
Approach
A dedicated test workflow (test.yml) that runs on:
- Pull requests - blocks merge if tests fail
- Push to main - validates code quality before deployment
- Manual trigger - for debugging
Workflow Structure
.github/workflows/test.yml
source
yml
name: Tests
on:
pull_request:
workflow_dispatch:
workflow_call:
permissions:
contents: read
jobs:
unit-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
with:
package_json_file: "apps/package.json"
- uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
cache-dependency-path: "apps/pnpm-lock.yaml"
- run: cd apps && pnpm install --frozen-lockfile
- run: cd apps && pnpm test:unit