diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..1e964a3 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,35 @@ +name: CI + +on: + pull_request: + branches: [main, preview] + push: + branches: [preview] + workflow_dispatch: # allows manual trigger from GitHub Actions tab + +jobs: + build: + name: Build check + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: npm + + - name: Install dependencies + run: npm ci + + - name: Build + run: npm run build + env: + DATABASE_URL: ${{ secrets.DATABASE_URL }} + NEXTAUTH_SECRET: ${{ secrets.NEXTAUTH_SECRET }} + NEXTAUTH_URL: https://dbirecoding.vercel.app + RUNNER_URL: https://code-runner-cpqt.onrender.com + RUNNER_API_KEY: dummy diff --git a/README.md b/README.md index 1235e45..688b636 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Recoding — Exercise Platform -A controlled environment for running timed coding and writing exercises with live anti-cheat monitoring. +A controlled environment for running timed coding and writing exercises with live anti-cheat monitoring. --- diff --git a/lib/db.ts b/lib/db.ts index 3f42606..3234a9d 100644 --- a/lib/db.ts +++ b/lib/db.ts @@ -13,7 +13,8 @@ if (!process.env.DATABASE_URL) { } if (!process.env.DATABASE_URL) { - throw new Error('DATABASE_URL environment variable is not set'); + // Don't throw at module load (breaks Next.js build) — throw at query time instead + console.warn('[db] DATABASE_URL is not set — queries will fail at runtime'); } // Use @neondatabase/serverless in Next.js (works over HTTPS, no port 5432 needed) @@ -37,8 +38,6 @@ async function getQueryFn() { return _queryFn; } catch { /* fall through to pg */ } } - - // pg fallback — works in scripts and when port 5432 is accessible const { Pool } = await import('pg'); const pool = new Pool({ connectionString: process.env.DATABASE_URL }); pool.on('error', (err) => console.error('[db] Pool error:', err.message));