randomayzer/.github/workflows/ci.yml

71 lines
1.7 KiB
YAML

name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build-and-test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: randomayzer
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
DATABASE_URL: "postgresql://postgres:postgres@localhost:5432/randomayzer?schema=public"
STORAGE_DRIVER: "memory"
NODE_ENV: "test"
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Generate Prisma Client
run: npx prisma generate
- name: Apply Prisma Migrations
run: npx prisma migrate deploy
env:
DATABASE_URL: "postgresql://postgres:postgres@localhost:5432/randomayzer?schema=public"
- name: Run Unit Tests (In-Memory Storage)
run: npm test
env:
STORAGE_DRIVER: "memory"
- name: Run Integration Tests (Real PostgreSQL + Prisma Driver)
run: npm run test:integration
env:
STORAGE_DRIVER: "prisma"
DATABASE_URL: "postgresql://postgres:postgres@localhost:5432/randomayzer?schema=public"
- name: Run ESLint
run: npm run lint
- name: Run Production Build
run: npm run build
env:
DATABASE_URL: "postgresql://postgres:postgres@localhost:5432/randomayzer?schema=public"