Merge pull request #883 from success-OG/feat/governance #241
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 Governance | |
| on: | |
| pull_request: | |
| paths: | |
| - 'backend/**' | |
| - 'docs/api/**' | |
| - 'frontend/src/types/**' | |
| - '.github/workflows/backend-governance.yml' | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'backend/**' | |
| - 'docs/api/**' | |
| - 'frontend/src/types/**' | |
| - '.github/workflows/backend-governance.yml' | |
| jobs: | |
| backend-governance: | |
| runs-on: ubuntu-latest | |
| services: | |
| postgres: | |
| image: postgres:16 | |
| env: | |
| POSTGRES_DB: yieldvault_ci | |
| POSTGRES_USER: postgres | |
| POSTGRES_PASSWORD: postgres | |
| ports: | |
| - 5432:5432 | |
| options: >- | |
| --health-cmd "pg_isready -U postgres -d yieldvault_ci" | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| env: | |
| DATABASE_URL: postgres://postgres:postgres@localhost:5432/yieldvault_ci | |
| defaults: | |
| run: | |
| working-directory: backend | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: npm | |
| cache-dependency-path: backend/package-lock.json | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Apply PostgreSQL migrations | |
| run: npm run db:migrate | |
| - name: Run npm audit | |
| run: npm audit --audit-level=high | |
| - name: Run unit tests | |
| run: npm test | |
| - name: Run governance checks | |
| run: npm run ci:governance | |
| - name: Verify OpenAPI documentation | |
| run: | | |
| npm run generate:openapi | |
| if [ -n "$(git status --porcelain openapi.json)" ]; then | |
| echo "❌ openapi.json is out of date. Run 'npm run generate:openapi' locally and commit the changes." | |
| git diff openapi.json | |
| exit 1 | |
| fi | |
| - name: Check API contract schema snapshots | |
| run: npm run snapshots:check | |
| - name: Check for database schema drift | |
| run: npm run db:check-drift |