Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
135 commits
Select commit Hold shift + click to select a range
b5d8cf4
Upgrade to Next 15.5 and React 19
Ben-K-Jordan Oct 12, 2026
20e2644
Add postinstall and typecheck scripts
Ben-K-Jordan Oct 12, 2026
795747c
Keep pdf-parse out of the server bundle
Ben-K-Jordan Oct 12, 2026
401beff
Target ES2022 in tsconfig
Ben-K-Jordan Oct 12, 2026
634196f
Drop any casts from route handlers
Ben-K-Jordan Oct 12, 2026
aca3a7b
Remove unused imports and a dead reflow helper
Ben-K-Jordan Oct 12, 2026
c88bb9d
Keep upload paths out of build file tracing
Ben-K-Jordan Oct 12, 2026
054a971
Upgrade to Next 16 and ESLint 9
Ben-K-Jordan Oct 12, 2026
8d21753
Rename middleware to proxy
Ben-K-Jordan Oct 12, 2026
c1f0ccb
Stop next dev from writing AGENTS.md
Ben-K-Jordan Oct 12, 2026
dbaf2ef
Remove bundled research PDFs and link citations by DOI
Ben-K-Jordan Oct 12, 2026
3a3cdda
Remove unused design exports and stale index script
Ben-K-Jordan Oct 12, 2026
1acddc7
Group .gitignore entries and ignore local tool and editor files
Ben-K-Jordan Oct 12, 2026
d3185d4
Send the Google OAuth callback back to /settings
Ben-K-Jordan Oct 12, 2026
b4ebf55
Run only the database in Docker and apply pgvector in setup
Ben-K-Jordan Oct 12, 2026
cc6dd96
Schedule plans and reflow in the plan's timezone
Ben-K-Jordan Oct 12, 2026
c78426e
Run unit tests in UTC unless TZ is set
Ben-K-Jordan Oct 12, 2026
6ee7e2a
Pass e2e server settings through Playwright's webServer.env
Ben-K-Jordan Oct 12, 2026
fc6a5c7
Delete API routes nothing calls
Ben-K-Jordan Oct 12, 2026
bd3fbe9
Remove the unused calendar provider abstraction
Ben-K-Jordan Oct 12, 2026
5764fa3
Import token encryption from token-vault directly
Ben-K-Jordan Oct 12, 2026
b156bd7
Remove unused exports and helpers that only tests called
Ben-K-Jordan Oct 12, 2026
cf3ffe2
Fix PDF extraction for small files and keep page numbers
Ben-K-Jordan Oct 12, 2026
d114221
Build email and OAuth links from BASE_URL
Ben-K-Jordan Oct 12, 2026
e5eae37
Read Google publish concurrency from GOOGLE_SYNC_CONCURRENCY
Ben-K-Jordan Oct 12, 2026
0bcd480
Read the token encryption key only from TOKEN_ENC_KEY
Ben-K-Jordan Oct 12, 2026
a093ddc
Document every environment variable in .env.example
Ben-K-Jordan Oct 12, 2026
6c5ab30
Import zod from its root entry
Ben-K-Jordan Oct 12, 2026
68dde96
Drop @vitejs/plugin-react and use @types/node 22
Ben-K-Jordan Oct 12, 2026
dca0e33
Add the MIT license
Ben-K-Jordan Oct 12, 2026
d6e02f3
Trust the X-User-Id test header only outside production
Ben-K-Jordan Oct 12, 2026
bbcf3d7
Make session pages owner-only and narrow the static file bypass
Ben-K-Jordan Oct 12, 2026
5926446
Reject cross-site API writes in the proxy
Ben-K-Jordan Oct 12, 2026
1d72f20
Gate every admin route with a shared requireAdmin
Ben-K-Jordan Oct 12, 2026
f4576a7
Drop unsafe-eval from the production CSP and hide X-Powered-By
Ben-K-Jordan Oct 12, 2026
df933e6
Note the CI condition on ALLOW_TEST_AUTH in .env.example
Ben-K-Jordan Oct 12, 2026
3142305
Silence the logger during vitest runs
Ben-K-Jordan Oct 12, 2026
589dbf9
Move the payload budget test to the integration suite
Ben-K-Jordan Oct 12, 2026
d08f68e
Tighten CI permissions, pin Node from .nvmrc and cache Next builds
Ben-K-Jordan Oct 12, 2026
66c4d05
Add Dependabot for npm and GitHub Actions
Ben-K-Jordan Oct 12, 2026
aa568bf
Add a security policy
Ben-K-Jordan Oct 12, 2026
117617a
Rename the __test-seed route so Next routes it
Ben-K-Jordan Oct 12, 2026
9fd3555
Fix the calendar publish and reflow specs now that they run
Ben-K-Jordan Oct 12, 2026
34bf9a4
Act as the session owner in the error repair e2e spec
Ben-K-Jordan Oct 12, 2026
6045665
Wait for the attempt to save in the knowledge layer e2e spec
Ben-K-Jordan Oct 12, 2026
bf12bb0
Upgrade Playwright to 1.64
Ben-K-Jordan Oct 12, 2026
f848d6d
Tidy .gitignore
Ben-K-Jordan Oct 12, 2026
67ef71a
Add Tailwind CSS v4 and move legacy tokens to an sb- prefix
Ben-K-Jordan Oct 12, 2026
fdd57ae
Set up shadcn/ui on Radix with the maia style and lucide icons
Ben-K-Jordan Oct 12, 2026
e92472f
Add GM3 colour roles, lesson palette, type scale and M3 component styles
Ben-K-Jordan Oct 12, 2026
b72dd66
Self-host Google Sans Flex and add theme, session, tooltip and toast …
Ben-K-Jordan Oct 12, 2026
20229c2
Add a demo data seed and a screenshot harness
Ben-K-Jordan Oct 12, 2026
e94339a
Split routes into app, auth and lesson layouts with an M3 shell
Ben-K-Jordan Oct 12, 2026
7c595e0
Add Intl formatting helpers, the active course hook and SWR data fetc…
Ben-K-Jordan Oct 12, 2026
5527b64
Add shared app components and the not-found, error and loading screens
Ben-K-Jordan Oct 12, 2026
dad4932
Add the lesson primitives for study sessions
Ben-K-Jordan Oct 12, 2026
e262145
Add a development-only design system page at /design
Ben-K-Jordan Oct 12, 2026
1bfb25c
Redraw the app icon and PWA manifest in the new palette
Ben-K-Jordan Oct 12, 2026
2c2ce6d
Format design page times through Intl
Ben-K-Jordan Oct 12, 2026
41670a1
Pin the spaces inside formatted times
Ben-K-Jordan Oct 12, 2026
87ca3c9
Add demo seed and screenshot scripts, hide the dev badge
Ben-K-Jordan Oct 12, 2026
ea5a562
Add markdown rendering and the chart component
Ben-K-Jordan Oct 12, 2026
972164c
Say how long to wait in rate limit responses
Ben-K-Jordan Oct 15, 2026
73b5ed1
Use sentence-case mode names in calendar events
Ben-K-Jordan Oct 15, 2026
8a094e2
Keep the query string when sending visitors to sign in
Ben-K-Jordan Oct 15, 2026
d29dfea
Wrap stat lines and topic names cleanly
Ben-K-Jordan Oct 15, 2026
8ed6942
Rebuild Home and Progress around exams and weak spots
Ben-K-Jordan Oct 15, 2026
3f3dd65
Reschedule missed sessions and read plan dates as calendar days
Ben-K-Jordan Oct 15, 2026
f9ab85d
Rebuild Plan and add a materials manager
Ben-K-Jordan Oct 15, 2026
e86c843
Require an answer before revealing the model answer
Ben-K-Jordan Oct 15, 2026
a95c6b1
Rebuild the study loop as a lesson
Ben-K-Jordan Oct 15, 2026
e3bea46
Rebuild the session shell as a lesson
Ben-K-Jordan Oct 15, 2026
fd410b3
Rebuild Study and study guides
Ben-K-Jordan Oct 15, 2026
d04f576
Rebuild Cards and Chat
Ben-K-Jordan Oct 15, 2026
0468b50
Rebuild Settings with account and calendar controls
Ben-K-Jordan Oct 15, 2026
d4e5034
Rebuild the sign-in screens
Ben-K-Jordan Oct 15, 2026
702c0b3
Remove legacy styles and dead components
Ben-K-Jordan Oct 15, 2026
326ded9
Answer 404 for sessions that aren't yours before the page streams
Ben-K-Jordan Oct 15, 2026
0594325
Keep the Study Bot suffix in every tab title
Ben-K-Jordan Oct 15, 2026
3d2296f
Add axe for accessibility checks in Playwright
Ben-K-Jordan Oct 15, 2026
a09b2b2
Resolve the student's time zone one way and cache day formatters
Ben-K-Jordan Oct 16, 2026
bb245b6
Harden the gateway, proxy and answer length limits
Ben-K-Jordan Oct 16, 2026
374ea00
Write prompts and mock text in the student voice
Ben-K-Jordan Oct 16, 2026
7047b6e
Harden sign-in limits, reset tokens and session revocation
Ben-K-Jordan Oct 16, 2026
01cd91b
Harden account deletion and the Google Calendar connection
Ben-K-Jordan Oct 16, 2026
153550d
Add a start session button and fix shared focus, motion and contrast
Ben-K-Jordan Oct 16, 2026
ff67a8e
Fix Home and Progress layout and copy, and award XP after the response
Ben-K-Jordan Oct 16, 2026
0662149
Fix plan scheduling, calendar text and material uploads
Ben-K-Jordan Oct 16, 2026
df26ba1
Load Study and guides faster and tighten their copy
Ben-K-Jordan Oct 16, 2026
d5030bd
Fix card review and chat at high zoom, focus and time zones
Ben-K-Jordan Oct 16, 2026
542c42b
Speed up answers and fix follow-up dates on the session screens
Ben-K-Jordan Oct 16, 2026
97f8dd5
Shorten the feedback sheet and split the question screen
Ben-K-Jordan Oct 16, 2026
2e646ce
Update the README, screenshots and security headers
Ben-K-Jordan Oct 16, 2026
f9bc7e8
Remove unused variables from integration tests
Ben-K-Jordan Oct 16, 2026
421e4ee
Restructure the e2e harness around fixtures and a signed-in setup pro…
Ben-K-Jordan Oct 16, 2026
ce1d02a
Update the e2e specs to the redesigned screens
Ben-K-Jordan Oct 16, 2026
0cda613
Run both e2e projects in CI and keep the HTML report
Ben-K-Jordan Oct 16, 2026
f81caea
Keep the shared session out of the test identity's page
Ben-K-Jordan Oct 16, 2026
14b9a8e
Wait for loading states to clear before the shell axe checks
Ben-K-Jordan Oct 16, 2026
37e6183
Submit the auth forms with POST so a password never lands in the URL
Ben-K-Jordan Oct 16, 2026
44c7b10
Return focus to the opener or the next control when confirm dialogs c…
Ben-K-Jordan Oct 16, 2026
03d9b7c
Keep the last exam answer on screen after it is scored
Ben-K-Jordan Oct 16, 2026
1df4f68
Keep the follow-ups' Open plan link after a reload
Ben-K-Jordan Oct 16, 2026
5bd52ea
Share e2e helpers through the fixtures and give each test its own cli…
Ben-K-Jordan Oct 16, 2026
268f8f6
Add end-to-end tests for sign-in and settings
Ben-K-Jordan Oct 16, 2026
94a43ec
Add end-to-end tests for plans, study and progress
Ben-K-Jordan Oct 16, 2026
d004df0
Add end-to-end tests for lessons, cards and chat
Ben-K-Jordan Oct 16, 2026
6eb9f2d
Run the e2e suite in two CI shards and update the e2e guide
Ben-K-Jordan Oct 16, 2026
65524a3
Bound session requests, cap AI spend across accounts and redact logs
Ben-K-Jordan Oct 16, 2026
b31d122
Answer signed-out requests with one body and use upper-case error codes
Ben-K-Jordan Oct 16, 2026
cf7a7f0
Keep reset links usable until the password saves and out of the logs
Ben-K-Jordan Oct 16, 2026
6ee74bf
Fit the Settings save bar to short windows and revoke Google after de…
Ben-K-Jordan Oct 16, 2026
24a6572
Recede the app bar into sessions and keep focus clear of the Start bu…
Ben-K-Jordan Oct 16, 2026
6423839
Fix the first-run steps, the heatmap region and repeat streak freezes
Ben-K-Jordan Oct 16, 2026
393f7f2
Skip past follow-up days, search each topic and cap file reading
Ben-K-Jordan Oct 16, 2026
e1c0722
Open Study, guides and Chat on the course with the nearest exam
Ben-K-Jordan Oct 16, 2026
97edec2
Return 404 for missing decks and fix card review and chat answers
Ben-K-Jordan Oct 16, 2026
4a05aff
Focus session headings on navigation and word past follow-up days
Ben-K-Jordan Oct 16, 2026
272b6f6
Match any question word in search and source correct-answer notes
Ben-K-Jordan Oct 16, 2026
ddc18e9
Load .env in the worker scripts and update the docs and e2e setup
Ben-K-Jordan Oct 16, 2026
8664469
Forbid server code from importing UI modules
Ben-K-Jordan Oct 16, 2026
8a43183
Offer Resume session on Study for a planned session under way
Ben-K-Jordan Oct 16, 2026
5ee56b5
Move the session's keyboard shortcuts button into the top bar
Ben-K-Jordan Oct 16, 2026
11fa898
Document the design system
Ben-K-Jordan Oct 16, 2026
49c1a11
Bring the learning science notes in line with the app
Ben-K-Jordan Oct 16, 2026
18aa3af
Add package metadata
Ben-K-Jordan Oct 16, 2026
7340faf
Retake the screenshots for the redesign
Ben-K-Jordan Oct 16, 2026
b5e9569
Rewrite the README for the redesigned app
Ben-K-Jordan Oct 16, 2026
885a6b9
Use the outline colour for printed guide borders
Ben-K-Jordan Oct 16, 2026
93c9d60
Document AUTH_SECRET and NEXT_PHASE in .env.example
Ben-K-Jordan Oct 16, 2026
000fa32
Replace dashes in the setup script's messages
Ben-K-Jordan Oct 16, 2026
8bd2aca
Scope the README's pretest and multiple-choice claims
Ben-K-Jordan Oct 16, 2026
11b8451
Replace dashes in the learning science notes
Ben-K-Jordan Oct 16, 2026
b4ad4ce
Store screenshot provenance under the standard Description key
Ben-K-Jordan Oct 16, 2026
36ecb47
Show multiple choice in the README's session tour
Ben-K-Jordan Oct 16, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
97 changes: 58 additions & 39 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# ==============================================================
# Study Bot environment configuration
#
# Quick start: run `npm run setup` — it copies this file to .env,
# Quick start: run `npm run setup`. It copies this file to .env,
# generates the secrets marked "auto-filled" below, starts the
# database via Docker, and applies migrations.
#
# The defaults run fully offline: mock AI, console email, and a
# fake Google Calendar client.
# ==============================================================

# --- Database -------------------------------------------------
Expand All @@ -12,62 +15,78 @@
# If you run your own Postgres instead of Docker, point this at it.
DATABASE_URL="postgresql://postgres:postgres@localhost:5433/studybot?schema=public"

# --- App URLs -------------------------------------------------
BASE_URL="http://localhost:3000"
NEXT_PUBLIC_APP_URL="http://localhost:3000"
# --- App URL --------------------------------------------------
BASE_URL="http://localhost:3000" # public origin; used in session links, emails, and OAuth redirects

# --- Authentication (NextAuth) --------------------------------
NEXTAUTH_URL="http://localhost:3000"
NEXTAUTH_URL="http://localhost:3000" # must match the origin you browse to; https enables secure cookies
NEXTAUTH_SECRET="" # auto-filled by `npm run setup` (or: openssl rand -base64 32)
# AUTH_SECRET="" # read only when NEXTAUTH_SECRET is empty (next-auth accepts either name)

# Require users to verify their email address before signing in.
# Leave off unless real SMTP is configured below; with the console
# provider, verification links only appear in the server logs.
# REQUIRE_EMAIL_VERIFICATION="true"

# --- Admin & Security -----------------------------------------
ADMIN_USER_IDS="" # comma-separated user UUIDs allowed to access /admin
ADMIN_USER_IDS="" # comma-separated user IDs allowed to call the /api/admin/* endpoints (there is no admin page)

# WARNING: ALLOW_TEST_AUTH makes the app trust the X-User-Id header
# as the authenticated identity. It exists ONLY for automated tests.
# It must NEVER be set in production — leave it commented out.
# as the signed-in user. It exists ONLY for automated tests, and a
# production build ignores it unless CI=true. It also needs NEXTAUTH_URL
# on a loopback host (localhost, 127.0.0.1). Leave it commented out.
# ALLOW_TEST_AUTH="true"

# Sign-in and sign-up limits key on the client's address. In production run
# behind a reverse proxy that appends X-Forwarded-For, and set this to the
# number of proxies that append to it (for example 2 for a CDN plus nginx).
# TRUSTED_PROXY_HOPS="1"

# --- Logging --------------------------------------------------
LOG_LEVEL="info" # debug | info | warn | error
LOG_LEVEL="info" # debug | info | warn | error | silent

# --- Email ----------------------------------------------------
EMAIL_PROVIDER="console" # console | smtp
SMTP_HOST=""
SMTP_PORT="587"
SMTP_USER=""
SMTP_PASS=""
SMTP_FROM="Study Bot <noreply@studybot.app>"
EMAIL_PROVIDER="console" # console (print to server logs outside production) | smtp; production without smtp turns reset links off
SMTP_HOST="" # SMTP server host, required when EMAIL_PROVIDER="smtp"
SMTP_PORT="587" # SMTP port; 465 uses TLS from the start
SMTP_USER="" # SMTP username
SMTP_PASS="" # SMTP password
SMTP_FROM="Study Bot <noreply@studybot.app>" # From header on outgoing mail

# Require users to verify their email address before signing in.
# Default: off (unset/false) — new accounts can sign in immediately.
# Only enable this with a real SMTP provider configured above; with the
# console provider, verification links are only printed to the server logs.
# REQUIRE_EMAIL_VERIFICATION="true"
# --- Uploads --------------------------------------------------
UPLOAD_DIR="./data/uploads" # where uploaded documents are stored, relative to the project root

# --- Google Calendar Integration ------------------------------
GOOGLE_CLIENT_ID=""
GOOGLE_CLIENT_SECRET=""
GOOGLE_REDIRECT_URI="" # defaults to BASE_URL + /api/integrations/google/callback
TOKEN_ENC_KEY="" # auto-filled by `npm run setup` — 32 bytes: 64 hex chars or 44 base64 chars (required in production)
GOOGLE_PROVIDER="fake" # fake | real — use "fake" in test/CI, "real" in production
GOOGLE_SYNC_CONCURRENCY="3" # max concurrent Google API calls during publish
GOOGLE_PROVIDER="fake" # fake (in-memory, for dev and tests) | real (calls Google)
GOOGLE_CLIENT_ID="" # OAuth client ID, required when GOOGLE_PROVIDER="real"
GOOGLE_CLIENT_SECRET="" # OAuth client secret, required when GOOGLE_PROVIDER="real"
GOOGLE_REDIRECT_URI="" # defaults to BASE_URL + /api/integrations/google/callback
TOKEN_ENC_KEY="" # auto-filled by `npm run setup`; encrypts stored OAuth tokens (32 bytes: 64 hex or 44 base64 chars)
GOOGLE_SYNC_CONCURRENCY="3" # max concurrent Google Calendar calls while publishing or unpublishing a plan

# --- AI Control Plane -----------------------------------------
AI_PROVIDER="mock" # mock | openai
OPENAI_API_KEY="" # required when AI_PROVIDER="openai"
AI_MODEL_ANSWER="gpt-4o-mini"
AI_MODEL_EMBED="text-embedding-3-small"
AI_PROVIDER="mock" # mock (canned output, for tests) | openai
OPENAI_API_KEY="" # required when AI_PROVIDER="openai"
AI_MODEL_ANSWER="gpt-4o-mini" # model for questions, feedback, chat, and plans
AI_MODEL_EMBED="text-embedding-3-small" # model for document embeddings
AI_REQUEST_TIMEOUT_MS="60000" # abort AI provider requests after this many ms
AI_CACHE_TTL_SECONDS="3600"
AI_DAILY_COST_CAP_USD="1.0" # max spend per user per day (default $1)
AI_MONTHLY_COST_CAP_USD="10.0" # max spend per user per month (default $10)
AI_DISABLED="false" # emergency kill switch — set "true" to block all AI calls
# MOCK_AI_MALFORMED="1" # test-only: makes the mock provider emit malformed output (never set outside tests)
AI_CACHE_TTL_SECONDS="3600" # how long identical AI responses are reused
AI_DAILY_COST_CAP_USD="1.0" # max spend per user per day
AI_DAILY_EMBED_COST_CAP_USD="0.10" # max spend per user per day on embedding uploaded files
AI_MONTHLY_COST_CAP_USD="10.0" # max spend per user per month
# AI_GLOBAL_DAILY_COST_CAP_USD="25.0" # max spend per day across every account (unset: no ceiling)
AI_DISABLED="false" # emergency kill switch; "true" blocks all AI calls
# MOCK_AI_MALFORMED="1" # test-only: makes the mock provider emit malformed output

# --- Background Worker ----------------------------------------
JOB_WORKER_CONCURRENCY="2"
JOB_POLL_INTERVAL_MS="2000"
# --- Background Worker (npm run worker) -----------------------
JOB_WORKER_CONCURRENCY="2" # jobs processed in parallel
JOB_POLL_INTERVAL_MS="2000" # how often the worker checks for new jobs

# --- Hybrid Search --------------------------------------------
HYBRID_SEARCH_ENABLED="false"
HYBRID_SEARCH_ENABLED="false" # "true" adds embedding search to full-text search (needs pgvector and the worker)

# --- Set by tooling; do not set these here --------------------
# NODE_ENV set by next dev / next build / next start
# CI set by CI runners; lets ALLOW_TEST_AUTH work in a production build
# VITEST set by the test runner; silences the logger unless LOG_LEVEL is set
# NEXT_PHASE set by next build; the missing-email warning stays quiet during the build
6 changes: 0 additions & 6 deletions .eslintrc.json

This file was deleted.

22 changes: 22 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
version: 2
updates:
- package-ecosystem: npm
directory: /
schedule:
interval: weekly
open-pull-requests-limit: 5
groups:
# One PR a week for routine updates; major versions still get their own
npm-minor-and-patch:
update-types:
- minor
- patch

- package-ecosystem: github-actions
directory: /
schedule:
interval: monthly
groups:
github-actions:
patterns:
- "*"
91 changes: 64 additions & 27 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:

permissions:
contents: read

concurrency:
group: ci-${{ github.ref }}
Expand All @@ -13,36 +17,45 @@ concurrency:
env:
NEXT_TELEMETRY_DISABLED: "1"

# npm ci runs `prisma generate` through the postinstall script, so no job
# needs a separate generate step.

jobs:
lint-and-build:
name: Lint & Build
name: Lint, Typecheck & Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7

- uses: actions/setup-node@v4
- uses: actions/setup-node@v7
with:
node-version: 22
node-version-file: .nvmrc
cache: npm

- uses: actions/cache@v6
with:
path: .next/cache
key: nextjs-${{ runner.os }}-${{ hashFiles('package-lock.json') }}-${{ hashFiles('src/**', 'next.config.js', 'tsconfig.json') }}
restore-keys: |
nextjs-${{ runner.os }}-${{ hashFiles('package-lock.json') }}-

- run: npm ci
- run: npx prisma generate
- run: npm run lint
- run: npm run typecheck
- run: npm run build

unit-tests:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7

- uses: actions/setup-node@v4
- uses: actions/setup-node@v7
with:
node-version: 22
node-version-file: .nvmrc
cache: npm

- run: npm ci
- run: npx prisma generate
- run: npm run test:unit

integration-tests:
Expand All @@ -69,25 +82,31 @@ jobs:
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/studybot_test?schema=public

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7

- uses: actions/setup-node@v4
- uses: actions/setup-node@v7
with:
node-version: 22
node-version-file: .nvmrc
cache: npm

- run: npm ci
- run: npx prisma generate
- name: Apply migration history to test DB
run: npx prisma migrate deploy
- name: Apply pgvector migration
run: psql "${DATABASE_URL%%\?*}" -f prisma/manual-scripts/001_pgvector.sql
run: npx prisma db execute --file prisma/manual-scripts/001_pgvector.sql
- run: npm run test:integration

e2e-tests:
name: E2E Tests
name: E2E Tests (shard ${{ matrix.shard }} of 2)
runs-on: ubuntu-latest
needs: [lint-and-build, unit-tests, integration-tests]
timeout-minutes: 20
# Each shard builds the app and runs half the tests against its own
# server and database. The setup project runs in both.
strategy:
fail-fast: false
matrix:
shard: [1, 2]

services:
postgres:
Expand All @@ -104,32 +123,50 @@ jobs:
--health-timeout 5s
--health-retries 5

# playwright.config.ts builds the app and starts `next start -p $E2E_PORT`
# with the offline providers (mock AI, fake Google, console email) and
# ALLOW_TEST_AUTH=true. GitHub sets CI=true, which is what lets the
# production build trust the specs' X-User-Id header. The suite runs the
# setup, chromium (Desktop Chrome) and mobile (Pixel 7, @mobile tests)
# projects; all of them use Chromium. DATABASE_URL is set for the test
# runner too: a few tests write rows the API can't reach.
env:
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/studybot_e2e?schema=public
BASE_URL: http://localhost:3000
E2E_PORT: "3000"

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7

- uses: actions/setup-node@v4
- uses: actions/setup-node@v7
with:
node-version: 22
node-version-file: .nvmrc
cache: npm

- uses: actions/cache@v6
with:
path: .next/cache
key: nextjs-${{ runner.os }}-${{ hashFiles('package-lock.json') }}-${{ hashFiles('src/**', 'next.config.js', 'tsconfig.json') }}
restore-keys: |
nextjs-${{ runner.os }}-${{ hashFiles('package-lock.json') }}-

- run: npm ci
- run: npx prisma generate
- name: Apply migration history to test DB
run: npx prisma migrate deploy
- name: Apply pgvector migration
run: psql "${DATABASE_URL%%\?*}" -f prisma/manual-scripts/001_pgvector.sql
run: npx prisma db execute --file prisma/manual-scripts/001_pgvector.sql
- run: npx playwright install --with-deps chromium
- run: npm run test:e2e
- run: npm run test:e2e -- --shard=${{ matrix.shard }}/2

- uses: actions/upload-artifact@v7
if: ${{ !cancelled() }}
with:
name: playwright-report-${{ matrix.shard }}
path: playwright-report/
retention-days: 14

- uses: actions/upload-artifact@v4
- uses: actions/upload-artifact@v7
if: failure()
with:
name: playwright-report
path: |
playwright-report/
test-results/
name: playwright-test-results-${{ matrix.shard }}
path: test-results/
retention-days: 7
54 changes: 27 additions & 27 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
# dependencies
# Dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage
/test-results
/playwright-report

# next.js
# Build output
/.next/
/out/

# production
/build
*.tsbuildinfo
next-env.d.ts

# misc
.DS_Store
*.pem
# Generated code
/generated/prisma

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Tests
/coverage
playwright-report/
test-results/
# Signed-in browser state saved by the e2e setup project
e2e/.auth/

# local env files
.env*.local
.env
# Local data (uploads and other runtime files)
data/

# vercel
.vercel
# Environment and secrets
.env
.env*.local
*.pem

# typescript
*.tsbuildinfo
next-env.d.ts
# Logs
*.log

/generated/prisma
# Editors, OS files and local tool state
.idea/
.vscode/
.DS_Store
Thumbs.db

# uploaded content
/data/uploads
# Vercel
.vercel
Loading
Loading