Claude/cranky johnson #4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - dev | |
| pull_request: | |
| # Run on all PRs, regardless of target branch | |
| jobs: | |
| lint-and-test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "22" | |
| cache: "npm" | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Install web dependencies | |
| run: cd web && npm ci | |
| - name: Build backend | |
| run: npm run build | |
| - name: Build frontend | |
| run: npm run build:web | |
| - name: Run typecheck | |
| run: npm run typecheck | |
| - name: Run linter | |
| run: npm run lint | |
| - name: Audit production dependencies | |
| run: npm audit --omit=dev --audit-level=high | |
| - name: Run tests with coverage | |
| run: npm run test:coverage | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| files: coverage/lcov.info | |
| fail_ci_if_error: false | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| validate-commits: | |
| runs-on: ubuntu-latest | |
| # Skip validation for PRs from dev to main (release PRs) since dev accumulates merge commit history | |
| if: github.event_name == 'pull_request' && !(github.head_ref == 'dev' && github.base_ref == 'main') | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "22" | |
| cache: "npm" | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Validate PR commits | |
| run: npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose | |
| integration-tests: | |
| runs-on: ubuntu-latest | |
| services: | |
| postgres: | |
| image: postgres:16-alpine | |
| env: | |
| POSTGRES_USER: cascade_test | |
| POSTGRES_PASSWORD: cascade_test | |
| POSTGRES_DB: cascade_test | |
| ports: | |
| - 5433:5432 | |
| options: >- | |
| --health-cmd "pg_isready -U cascade_test -d cascade_test" | |
| --health-interval 2s | |
| --health-timeout 5s | |
| --health-retries 10 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "22" | |
| cache: "npm" | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build backend | |
| run: npm run build | |
| - name: Run integration tests | |
| run: npm run test:integration | |
| env: | |
| TEST_DATABASE_URL: postgresql://cascade_test:cascade_test@localhost:5433/cascade_test | |
| docker-build-check: | |
| name: Validate Docker builds | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Build router image | |
| run: docker build -f Dockerfile.router -t cascade-router:ci-check . | |
| - name: Build worker image | |
| run: docker build -f Dockerfile.worker -t cascade-worker:ci-check . | |
| enforce-dev-to-main: | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'pull_request' && github.base_ref == 'main' | |
| steps: | |
| - name: Check source branch | |
| run: | | |
| if [ "${{ github.head_ref }}" != "dev" ]; then | |
| echo "::error::PRs to main must come from the dev branch, not '${{ github.head_ref }}'" | |
| exit 1 | |
| fi | |
| echo "Source branch is dev - OK" |