|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + branches: [main] |
| 8 | + |
| 9 | +env: |
| 10 | + NODE_VERSION: "20" |
| 11 | + PNPM_VERSION: "10" |
| 12 | + DATABASE_URL: "postgresql://postgres:postgres@localhost:5432/mathitem_test?schema=public" |
| 13 | + DIRECT_URL: "postgresql://postgres:postgres@localhost:5432/mathitem_test?schema=public" |
| 14 | + TEST_DATABASE_URL: "postgresql://postgres:postgres@localhost:5432/mathitem_test?schema=public" |
| 15 | + REDIS_URL: "redis://localhost:6379" |
| 16 | + MEILISEARCH_HOST: "http://localhost:7700" |
| 17 | + MEILISEARCH_MASTER_KEY: "ci-master-key" |
| 18 | + AUTH_SECRET: "ci-auth-secret-at-least-32-chars-long-value" |
| 19 | + NEXTAUTH_URL: "http://localhost:3000" |
| 20 | + |
| 21 | +jobs: |
| 22 | + lint: |
| 23 | + name: Lint |
| 24 | + runs-on: ubuntu-latest |
| 25 | + steps: |
| 26 | + - uses: actions/checkout@v4 |
| 27 | + - uses: pnpm/action-setup@v4 |
| 28 | + with: |
| 29 | + version: ${{ env.PNPM_VERSION }} |
| 30 | + - uses: actions/setup-node@v4 |
| 31 | + with: |
| 32 | + node-version: ${{ env.NODE_VERSION }} |
| 33 | + cache: "pnpm" |
| 34 | + - run: pnpm install --frozen-lockfile |
| 35 | + - run: pnpm --filter @math-item-os/db exec prisma generate |
| 36 | + - run: pnpm lint |
| 37 | + |
| 38 | + typecheck: |
| 39 | + name: Typecheck |
| 40 | + runs-on: ubuntu-latest |
| 41 | + steps: |
| 42 | + - uses: actions/checkout@v4 |
| 43 | + - uses: pnpm/action-setup@v4 |
| 44 | + with: |
| 45 | + version: ${{ env.PNPM_VERSION }} |
| 46 | + - uses: actions/setup-node@v4 |
| 47 | + with: |
| 48 | + node-version: ${{ env.NODE_VERSION }} |
| 49 | + cache: "pnpm" |
| 50 | + - run: pnpm install --frozen-lockfile |
| 51 | + - run: pnpm --filter @math-item-os/db exec prisma generate |
| 52 | + - run: pnpm --filter @math-item-os/web exec tsc --noEmit |
| 53 | + |
| 54 | + test-unit: |
| 55 | + name: Unit Tests + Coverage |
| 56 | + runs-on: ubuntu-latest |
| 57 | + services: |
| 58 | + postgres: |
| 59 | + image: pgvector/pgvector:pg17 |
| 60 | + env: |
| 61 | + POSTGRES_DB: mathitem_test |
| 62 | + POSTGRES_USER: postgres |
| 63 | + POSTGRES_PASSWORD: postgres |
| 64 | + ports: |
| 65 | + - 5432:5432 |
| 66 | + options: >- |
| 67 | + --health-cmd "pg_isready -U postgres -d mathitem_test" |
| 68 | + --health-interval 10s |
| 69 | + --health-timeout 5s |
| 70 | + --health-retries 10 |
| 71 | + redis: |
| 72 | + image: redis:7 |
| 73 | + ports: |
| 74 | + - 6379:6379 |
| 75 | + options: >- |
| 76 | + --health-cmd "redis-cli ping" |
| 77 | + --health-interval 10s |
| 78 | + --health-timeout 5s |
| 79 | + --health-retries 5 |
| 80 | + steps: |
| 81 | + - uses: actions/checkout@v4 |
| 82 | + - uses: pnpm/action-setup@v4 |
| 83 | + with: |
| 84 | + version: ${{ env.PNPM_VERSION }} |
| 85 | + - uses: actions/setup-node@v4 |
| 86 | + with: |
| 87 | + node-version: ${{ env.NODE_VERSION }} |
| 88 | + cache: "pnpm" |
| 89 | + - run: pnpm install --frozen-lockfile |
| 90 | + - name: Enable required Postgres extensions |
| 91 | + run: | |
| 92 | + PGPASSWORD=postgres psql -h localhost -U postgres -d mathitem_test \ |
| 93 | + -c "CREATE EXTENSION IF NOT EXISTS vector;" \ |
| 94 | + -c "CREATE EXTENSION IF NOT EXISTS ltree;" \ |
| 95 | + -c "CREATE EXTENSION IF NOT EXISTS pg_trgm;" |
| 96 | + - name: Prisma generate + migrate + push schema drift |
| 97 | + run: | |
| 98 | + pnpm --filter @math-item-os/db exec prisma generate |
| 99 | + pnpm --filter @math-item-os/db exec prisma migrate deploy |
| 100 | + pnpm --filter @math-item-os/db exec prisma db push --skip-generate --accept-data-loss |
| 101 | + - name: Run vitest with coverage |
| 102 | + run: pnpm --filter @math-item-os/web test:coverage |
| 103 | + - name: Upload coverage artifact |
| 104 | + if: always() |
| 105 | + uses: actions/upload-artifact@v4 |
| 106 | + with: |
| 107 | + name: web-coverage |
| 108 | + path: apps/web/coverage/ |
| 109 | + retention-days: 14 |
| 110 | + |
| 111 | + test-e2e: |
| 112 | + name: E2E Tests (Playwright) |
| 113 | + runs-on: ubuntu-latest |
| 114 | + needs: test-unit |
| 115 | + services: |
| 116 | + postgres: |
| 117 | + image: pgvector/pgvector:pg17 |
| 118 | + env: |
| 119 | + POSTGRES_DB: mathitem_test |
| 120 | + POSTGRES_USER: postgres |
| 121 | + POSTGRES_PASSWORD: postgres |
| 122 | + ports: |
| 123 | + - 5432:5432 |
| 124 | + options: >- |
| 125 | + --health-cmd "pg_isready -U postgres -d mathitem_test" |
| 126 | + --health-interval 10s |
| 127 | + --health-timeout 5s |
| 128 | + --health-retries 10 |
| 129 | + redis: |
| 130 | + image: redis:7 |
| 131 | + ports: |
| 132 | + - 6379:6379 |
| 133 | + options: >- |
| 134 | + --health-cmd "redis-cli ping" |
| 135 | + --health-interval 10s |
| 136 | + --health-timeout 5s |
| 137 | + --health-retries 5 |
| 138 | + meilisearch: |
| 139 | + image: getmeili/meilisearch:v1.12 |
| 140 | + env: |
| 141 | + MEILI_MASTER_KEY: ci-master-key |
| 142 | + MEILI_ENV: development |
| 143 | + ports: |
| 144 | + - 7700:7700 |
| 145 | + steps: |
| 146 | + - uses: actions/checkout@v4 |
| 147 | + - uses: pnpm/action-setup@v4 |
| 148 | + with: |
| 149 | + version: ${{ env.PNPM_VERSION }} |
| 150 | + - uses: actions/setup-node@v4 |
| 151 | + with: |
| 152 | + node-version: ${{ env.NODE_VERSION }} |
| 153 | + cache: "pnpm" |
| 154 | + - run: pnpm install --frozen-lockfile |
| 155 | + - name: Enable required Postgres extensions |
| 156 | + run: | |
| 157 | + PGPASSWORD=postgres psql -h localhost -U postgres -d mathitem_test \ |
| 158 | + -c "CREATE EXTENSION IF NOT EXISTS vector;" \ |
| 159 | + -c "CREATE EXTENSION IF NOT EXISTS ltree;" \ |
| 160 | + -c "CREATE EXTENSION IF NOT EXISTS pg_trgm;" |
| 161 | + - run: pnpm --filter @math-item-os/db exec prisma generate |
| 162 | + - run: pnpm --filter @math-item-os/db exec prisma db push --skip-generate --accept-data-loss |
| 163 | + - name: Install Playwright browsers |
| 164 | + run: pnpm --filter @math-item-os/web exec playwright install --with-deps chromium |
| 165 | + - name: Run Playwright |
| 166 | + run: pnpm --filter @math-item-os/web test:e2e |
| 167 | + - name: Upload Playwright report |
| 168 | + if: always() |
| 169 | + uses: actions/upload-artifact@v4 |
| 170 | + with: |
| 171 | + name: playwright-report |
| 172 | + path: apps/web/playwright-report/ |
| 173 | + retention-days: 14 |
| 174 | + |
| 175 | + test-python: |
| 176 | + name: Python (math-ai) Tests |
| 177 | + runs-on: ubuntu-latest |
| 178 | + defaults: |
| 179 | + run: |
| 180 | + working-directory: services/math-ai |
| 181 | + steps: |
| 182 | + - uses: actions/checkout@v4 |
| 183 | + - uses: actions/setup-python@v5 |
| 184 | + with: |
| 185 | + python-version: "3.11" |
| 186 | + cache: "pip" |
| 187 | + cache-dependency-path: services/math-ai/requirements.txt |
| 188 | + - name: Install dependencies |
| 189 | + run: | |
| 190 | + python -m pip install --upgrade pip |
| 191 | + pip install -r requirements.txt |
| 192 | + if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi |
| 193 | + - name: Run pytest |
| 194 | + run: | |
| 195 | + if [ -d tests ]; then |
| 196 | + pytest tests --tb=short |
| 197 | + else |
| 198 | + echo "No tests directory — skipping" |
| 199 | + fi |
0 commit comments