diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml new file mode 100644 index 00000000..7d45f766 --- /dev/null +++ b/.github/workflows/copilot-setup-steps.yml @@ -0,0 +1,117 @@ +name: "Copilot Setup Steps" + +on: + workflow_dispatch: + push: + paths: + - .github/workflows/copilot-setup-steps.yml + pull_request: + paths: + - .github/workflows/copilot-setup-steps.yml + +jobs: + copilot-setup-steps: + runs-on: ubuntu-latest + timeout-minutes: 30 + permissions: + contents: read + + steps: + - name: Checkout code + uses: actions/checkout@v5 + + # Engines: Node >=20, npm >=10 + - name: Set up Node 20 + uses: actions/setup-node@v4 + with: + node-version: "20" + cache: "npm" + + - name: Use npm 10 (per package.json engines) + run: npm i -g npm@10 + + - name: Copy env file + run: | + if [ -f ".env.example" ]; then + cp .env.example .env + fi + + - name: Install dependencies + run: npm ci + + # ---------- Playwright MCP (system deps + browsers) ---------- + - name: Install Playwright deps & browsers + if: ${{ hashFiles('playwright.config.*') != '' || hashFiles('.playwright-mcp/**') != '' }} + run: | + npx playwright install-deps + npx playwright install + + - name: Cache Playwright browsers + if: ${{ hashFiles('playwright.config.*') != '' || hashFiles('.playwright-mcp/**') != '' }} + uses: actions/cache@v4 + with: + path: ~/.cache/ms-playwright + key: ${{ runner.os }}-playwright-${{ hashFiles('playwright.config.*', '.playwright-mcp/**') }} + + # ---------- Prisma + SQLite (prisma/dev.db) ---------- + - name: Generate Prisma client (SQLite) + env: + DATABASE_URL: "file:./prisma/dev.db" + run: | + mkdir -p prisma + npx prisma generate + + - name: Init SQLite schema (db push) + env: + DATABASE_URL: "file:./prisma/dev.db" + run: npx prisma db push --accept-data-loss + + - name: Apply migrations (optional if present) + env: + DATABASE_URL: "file:./prisma/dev.db" + run: | + if [ -f "prisma/schema.prisma" ] && [ -d "prisma/migrations" ]; then + npx prisma migrate deploy || true + fi + + - name: Seed database (uses your npm script) + env: + DATABASE_URL: "file:./prisma/dev.db" + run: | + if [ -f "prisma/seed.ts" ]; then + npm run db:seed + else + echo "No prisma/seed.ts found; skipping." + fi + + # ---------- Type checking ---------- + - name: Type check + run: npm run type-check + + - name: Save type-check errors to JSON (PowerShell script with Linux fallback) + run: | + npm run type-check:save || pwsh -File ./scripts/collect-type-errors.ps1 + shell: bash + + # ---------- Next.js MCP warm start (guarded) ---------- + - name: Warm-start Next.js dev server (time-boxed) + if: ${{ hashFiles('app/**','pages/**','src/app/**','src/pages/**') != '' }} + env: + NODE_ENV: development + run: | + (npm run dev & echo $! > /tmp/next_pid) || true + sleep 15 || true + if [ -f /tmp/next_pid ]; then + kill $(cat /tmp/next_pid) || true + fi + + # ---------- Optional caches ---------- + - name: Cache Next.js build artifacts + uses: actions/cache@v4 + with: + path: | + ~/.npm + .next/cache + key: ${{ runner.os }}-next-${{ hashFiles('package-lock.json') }} + restore-keys: | + ${{ runner.os }}-next-