From 8c1731b3739e3438a7381c3cede861b9396426bc Mon Sep 17 00:00:00 2001 From: Rezwana Karim <126201034+rezwana-karim@users.noreply.github.com> Date: Sun, 2 Nov 2025 00:41:24 +0600 Subject: [PATCH 1/8] Add Copilot setup workflow This workflow sets up the environment for Copilot, including Node.js, dependencies, Prisma client generation, database seeding, type checking, and caching for Playwright and Next.js. --- .github/workflows/copilot-setup-steps.yml | 117 ++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 .github/workflows/copilot-setup-steps.yml diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml new file mode 100644 index 00000000..72750718 --- /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 + + - name: Set up Node 22 (upgrade npm to 11 as required by engines) + uses: actions/setup-node@v4 + with: + node-version: "22" + cache: "npm" + - name: Use npm 11 + run: npm i -g npm@11 + + - name: Copy env file + run: | + if [ -f ".env.example" ]; then + cp .env.example .env + fi + + - name: Install OS packages (Playwright/Next image pipeline) + run: | + sudo apt-get update + sudo apt-get install -y libnss3 libatk1.0-0 libatk-bridge2.0-0 \ + libxcomposite1 libxdamage1 libxfixes3 libxrandr2 libgbm1 \ + libasound2 libxshmfence1 libpangocairo-1.0-0 libx11-xcb1 \ + libpango-1.0-0 libcups2 libx11-6 libxext6 libxrender1 \ + libxi6 libxtst6 libdrm2 libdbus-1-3 libgtk-3-0 libvips + + - name: Install dependencies + run: npm ci + + # ---------- Prisma + SQLite ---------- + - name: Generate Prisma client (SQLite) + env: + DATABASE_URL: "file:./dev.db" + run: | + mkdir -p prisma + npx prisma generate + + - name: Apply migrations (create prisma/dev.db if needed) + env: + DATABASE_URL: "file:./dev.db" + run: | + if [ -f "prisma/schema.prisma" ]; then + npx prisma migrate deploy || true + fi + + - name: Seed database (uses your npm script) + env: + DATABASE_URL: "file:./dev.db" + run: | + if [ -f "prisma/seed.ts" ]; then + npm run db:seed || (npx tsx prisma/seed.ts || npx ts-node prisma/seed.ts || npx prisma 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) + run: | + # Try your exact script (calls `powershell ...`), then fall back to pwsh + npm run type-check:save || pwsh -File ./scripts/collect-type-errors.ps1 + shell: bash + + # ---------- Playwright MCP ---------- + - name: Install Playwright browsers (+ deps) + if: ${{ hashFiles('playwright.config.*') != '' || hashFiles('.playwright-mcp/**') != '' }} + run: npx playwright install --with-deps + + - 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/**') }} + + # ---------- Next.js MCP warm start ---------- + - name: Warm-start Next.js dev server (time-boxed) + 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- From 4881ad9a95ba811c1b71b8fd93450998e4bd25fa Mon Sep 17 00:00:00 2001 From: Rezwana Karim <126201034+rezwana-karim@users.noreply.github.com> Date: Sun, 2 Nov 2025 00:45:30 +0600 Subject: [PATCH 2/8] Update .github/workflows/copilot-setup-steps.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/copilot-setup-steps.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index 72750718..bcba64ee 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -20,10 +20,10 @@ jobs: - name: Checkout code uses: actions/checkout@v5 - - name: Set up Node 22 (upgrade npm to 11 as required by engines) + - name: Set up Node 20 (upgrade npm to 11 as required by engines) uses: actions/setup-node@v4 with: - node-version: "22" + node-version: "20" cache: "npm" - name: Use npm 11 run: npm i -g npm@11 From c07702363125a6a63dd290115102f4a460bd31b6 Mon Sep 17 00:00:00 2001 From: Rezwana Karim <126201034+rezwana-karim@users.noreply.github.com> Date: Sun, 2 Nov 2025 02:26:49 +0600 Subject: [PATCH 3/8] Update Playwright installation steps in workflow --- .github/workflows/copilot-setup-steps.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index bcba64ee..c98996c4 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -34,14 +34,11 @@ jobs: cp .env.example .env fi - - name: Install OS packages (Playwright/Next image pipeline) + - name: Install Playwright browsers + system deps + if: ${{ hashFiles('playwright.config.*') != '' || hashFiles('.playwright-mcp/**') != '' }} run: | - sudo apt-get update - sudo apt-get install -y libnss3 libatk1.0-0 libatk-bridge2.0-0 \ - libxcomposite1 libxdamage1 libxfixes3 libxrandr2 libgbm1 \ - libasound2 libxshmfence1 libpangocairo-1.0-0 libx11-xcb1 \ - libpango-1.0-0 libcups2 libx11-6 libxext6 libxrender1 \ - libxi6 libxtst6 libdrm2 libdbus-1-3 libgtk-3-0 libvips + npx playwright install-deps + npx playwright install - name: Install dependencies run: npm ci From 3e6a3c6868829f94c738529827bb2f4a456491a7 Mon Sep 17 00:00:00 2001 From: Rezwana Karim <126201034+rezwana-karim@users.noreply.github.com> Date: Sun, 2 Nov 2025 02:42:48 +0600 Subject: [PATCH 4/8] Update .github/workflows/copilot-setup-steps.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/copilot-setup-steps.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index c98996c4..31bf9b79 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -34,12 +34,6 @@ jobs: cp .env.example .env fi - - name: Install Playwright browsers + system deps - if: ${{ hashFiles('playwright.config.*') != '' || hashFiles('.playwright-mcp/**') != '' }} - run: | - npx playwright install-deps - npx playwright install - - name: Install dependencies run: npm ci From 69eb45b2e2283496da3cc96495783f021e7645cb Mon Sep 17 00:00:00 2001 From: Rezwana Karim <126201034+rezwana-karim@users.noreply.github.com> Date: Sun, 2 Nov 2025 02:43:01 +0600 Subject: [PATCH 5/8] Update .github/workflows/copilot-setup-steps.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/copilot-setup-steps.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index 31bf9b79..c00de73d 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -20,7 +20,7 @@ jobs: - name: Checkout code uses: actions/checkout@v5 - - name: Set up Node 20 (upgrade npm to 11 as required by engines) + - name: Set up Node 20 (project supports 18.x+, using 20 in CI for consistency and latest features) uses: actions/setup-node@v4 with: node-version: "20" From ec136be39677f0e64af790fa885b6159483cff70 Mon Sep 17 00:00:00 2001 From: Rezwana Karim <126201034+rezwana-karim@users.noreply.github.com> Date: Sun, 2 Nov 2025 02:43:20 +0600 Subject: [PATCH 6/8] Update .github/workflows/copilot-setup-steps.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/copilot-setup-steps.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index c00de73d..6895fd66 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -58,7 +58,7 @@ jobs: DATABASE_URL: "file:./dev.db" run: | if [ -f "prisma/seed.ts" ]; then - npm run db:seed || (npx tsx prisma/seed.ts || npx ts-node prisma/seed.ts || npx prisma db seed) + npm run db:seed else echo "No prisma/seed.ts found; skipping." fi From c37956a6548e1fd1bea79044cd5d4ec09ca26d4a Mon Sep 17 00:00:00 2001 From: Rezwana Karim <126201034+rezwana-karim@users.noreply.github.com> Date: Sun, 2 Nov 2025 02:43:33 +0600 Subject: [PATCH 7/8] Update .github/workflows/copilot-setup-steps.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/copilot-setup-steps.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index 6895fd66..1d7efe6d 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -69,7 +69,7 @@ jobs: - name: Save type-check errors to JSON (PowerShell script) run: | - # Try your exact script (calls `powershell ...`), then fall back to pwsh + # Run npm script first; if it fails, fall back to direct PowerShell execution npm run type-check:save || pwsh -File ./scripts/collect-type-errors.ps1 shell: bash From e330b10a1af1903fd27f73607414c46d4429e014 Mon Sep 17 00:00:00 2001 From: Rezwana Karim <126201034+rezwana-karim@users.noreply.github.com> Date: Sun, 2 Nov 2025 02:57:26 +0600 Subject: [PATCH 8/8] Update copilot-setup-steps.yml --- .github/workflows/copilot-setup-steps.yml | 57 +++++++++++++---------- 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index 1d7efe6d..7d45f766 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -20,13 +20,15 @@ jobs: - name: Checkout code uses: actions/checkout@v5 - - name: Set up Node 20 (project supports 18.x+, using 20 in CI for consistency and latest features) + # Engines: Node >=20, npm >=10 + - name: Set up Node 20 uses: actions/setup-node@v4 with: node-version: "20" cache: "npm" - - name: Use npm 11 - run: npm i -g npm@11 + + - name: Use npm 10 (per package.json engines) + run: npm i -g npm@10 - name: Copy env file run: | @@ -37,25 +39,44 @@ jobs: - name: Install dependencies run: npm ci - # ---------- Prisma + SQLite ---------- + # ---------- 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:./dev.db" + DATABASE_URL: "file:./prisma/dev.db" run: | mkdir -p prisma npx prisma generate - - name: Apply migrations (create prisma/dev.db if needed) + - name: Init SQLite schema (db push) env: - DATABASE_URL: "file:./dev.db" + 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" ]; then + 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:./dev.db" + DATABASE_URL: "file:./prisma/dev.db" run: | if [ -f "prisma/seed.ts" ]; then npm run db:seed @@ -67,26 +88,14 @@ jobs: - name: Type check run: npm run type-check - - name: Save type-check errors to JSON (PowerShell script) + - name: Save type-check errors to JSON (PowerShell script with Linux fallback) run: | - # Run npm script first; if it fails, fall back to direct PowerShell execution npm run type-check:save || pwsh -File ./scripts/collect-type-errors.ps1 shell: bash - # ---------- Playwright MCP ---------- - - name: Install Playwright browsers (+ deps) - if: ${{ hashFiles('playwright.config.*') != '' || hashFiles('.playwright-mcp/**') != '' }} - run: npx playwright install --with-deps - - - 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/**') }} - - # ---------- Next.js MCP warm start ---------- + # ---------- 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: |