Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

# Dummy URLs for install/generate only — no live DB in PR CI.
# postinstall runs `prisma generate`, which loads prisma.config.ts.
env:
DATABASE_URL: postgresql://ci:ci@127.0.0.1:5432/ci?schema=public
DIRECT_URL: postgresql://ci:ci@127.0.0.1:5432/ci?schema=public

jobs:
quality:
name: Lint, typecheck & validate
runs-on: ubuntu-latest
timeout-minutes: 15

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
cache: npm

- name: Install dependencies
run: npm ci

- name: Validate Prisma schema
run: npm run db:validate

- name: Lint
run: npm run lint

- name: Typecheck
run: npm run typecheck

build:
name: Next.js build (no DB migrate)
runs-on: ubuntu-latest
timeout-minutes: 20
needs: quality

env:
SKIP_DB_MIGRATE: "1"
NEXT_PUBLIC_ROUTE_PLANNER_LAT: "55.4038"
NEXT_PUBLIC_ROUTE_PLANNER_LNG: "10.4024"

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
cache: npm

- name: Install dependencies
run: npm ci

- name: Production build
run: npm run build
24 changes: 21 additions & 3 deletions docs/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,41 @@ Both `DATABASE_URL` and `DIRECT_URL` are required on Vercel. Prisma uses `DIRECT

## 5. Migrations On Every Deploy

Migrations run **automatically** during `npm run build` when `VERCEL=1` (set by Vercel) or `CI=true`:
Migrations run **automatically** during `npm run build` when `VERCEL=1` (set by Vercel):

1. `prisma migrate deploy` — applies any pending SQL in `prisma/migrations/`
2. `prisma generate` — generates the Prisma client
3. `next build` — builds the Next.js app

If a migration fails, the **build fails** and the bad deploy is not shipped. That is intentional: schema and code stay in lockstep.

Local builds skip migrate by default. To force it locally:
Local builds and GitHub Actions **skip migrate** by default (no production DB in PR CI). To force migrate locally:

```bash
RUN_DB_MIGRATE=1 npm run build
# or
npm run db:migrate
```

## 6. Verify
Set `SKIP_DB_MIGRATE=1` to force-skip even on Vercel (rarely needed).

## 6. GitHub Actions CI

Pushes and PRs targeting `main` run `.github/workflows/ci.yml`:

1. **quality** — `prisma validate`, `eslint`, `tsc --noEmit`
2. **build** — `npm run build` with dummy DB URLs and **no** migrate

Vercel remains the deploy path (preview on PRs, production on `main`). Enable branch protection on `main` and require the **CI** checks for a real merge gate.

Local equivalent:

```bash
npm run ci # validate + lint + typecheck
npm run build # app build (skips migrate unless VERCEL/RUN_DB_MIGRATE)
```

## 7. Verify

- Open app and complete Strava login
- Trigger run sync and verify data appears
Expand Down
Loading
Loading