Feature/org rate limiting #190
Workflow file for this run
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: Backend CI | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| paths: | |
| - 'app/backend/**' | |
| pull_request: | |
| branches: [ "main" ] | |
| paths: | |
| - 'app/backend/**' | |
| jobs: | |
| build-and-test: | |
| runs-on: ubuntu-latest | |
| services: | |
| postgres: | |
| image: postgres:16-alpine | |
| env: | |
| POSTGRES_DB: chainforge_test | |
| POSTGRES_PASSWORD: postgres | |
| POSTGRES_USER: postgres | |
| ports: | |
| - 5432:5432 | |
| options: >- | |
| --health-cmd "pg_isready -U postgres -d chainforge_test" | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| redis: | |
| image: redis:7-alpine | |
| ports: | |
| - 6379:6379 | |
| options: >- | |
| --health-cmd "redis-cli ping" | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Validate package.json files | |
| run: | | |
| node -e "const fs=require('fs'); require('child_process').execSync('git ls-files \"*package.json\"',{encoding:'utf8'}).trim().split('\\n').filter(Boolean).forEach(p=>{JSON.parse(fs.readFileSync(p,'utf8')); console.log('OK',p)})" | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v2 | |
| with: | |
| version: 9 | |
| - name: Use Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'pnpm' | |
| - name: Install dependencies | |
| run: pnpm install --no-frozen-lockfile --engine-strict=false | |
| - name: Lint | |
| run: pnpm --filter backend run lint | |
| - name: Prepare coverage database | |
| working-directory: app/backend | |
| env: | |
| DATABASE_URL: postgresql://postgres:postgres@localhost:5432/chainforge_test?schema=public | |
| run: pnpm exec prisma db push --skip-generate | |
| - name: Test with coverage | |
| env: | |
| API_KEY: test-api-key-123 | |
| DATABASE_URL: postgresql://postgres:postgres@localhost:5432/chainforge_test?schema=public | |
| NODE_ENV: test | |
| REDIS_HOST: 127.0.0.1 | |
| REDIS_PORT: '6379' | |
| run: pnpm --filter backend run test:cov | |
| - name: Build | |
| run: pnpm --filter backend run build | |
| - name: Export OpenAPI spec | |
| working-directory: app/backend | |
| env: | |
| DATABASE_URL: postgresql://postgres:postgres@localhost:5432/chainforge_test?schema=public | |
| NODE_ENV: development | |
| run: npm run spec:export | |
| - name: Check for Prisma schema without migration | |
| run: chmod +x app/backend/scripts/check-prisma-migration.sh && app/backend/scripts/check-prisma-migration.sh | |
| - name: Check for OpenAPI spec drift | |
| run: | | |
| git diff --exit-code app/frontend/openapi.json || \ | |
| (echo "ERROR: openapi.json is out of date. Run 'npm run spec:export' in app/backend and commit app/frontend/openapi.json." && exit 1) |