+39
-12
@@ -2,41 +2,68 @@ name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
branches: [master]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
branches: [master]
|
||||
|
||||
jobs:
|
||||
build-and-test:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:16-alpine
|
||||
env:
|
||||
POSTGRES_DB: kooltap
|
||||
POSTGRES_USER: kooltap
|
||||
POSTGRES_PASSWORD: kooltap
|
||||
ports:
|
||||
- 5432:5432
|
||||
options: >-
|
||||
--health-cmd "pg_isready -U kooltap"
|
||||
--health-interval 5s
|
||||
--health-timeout 5s
|
||||
--health-retries 10
|
||||
|
||||
env:
|
||||
DATABASE_URL: postgresql://kooltap:kooltap@localhost:5432/kooltap
|
||||
JWT_SECRET: ci-secret
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: pnpm/action-setup@v2
|
||||
- uses: pnpm/action-setup@v4
|
||||
with:
|
||||
version: 8
|
||||
version: 9
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
cache: 'pnpm'
|
||||
|
||||
- run: pnpm install
|
||||
- run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: Generate Prisma client
|
||||
run: cd apps/api && npx prisma generate
|
||||
|
||||
- name: Lint
|
||||
run: pnpm lint
|
||||
continue-on-error: true
|
||||
- name: Build shared package
|
||||
run: pnpm --filter @kooltap/shared run build
|
||||
|
||||
- name: TypeScript check
|
||||
run: pnpm typecheck
|
||||
continue-on-error: true
|
||||
|
||||
- name: Run migrations
|
||||
run: cd apps/api && npx prisma migrate dev --name ci-init
|
||||
# Uses the still-empty database as shadow database, so it must run before the migrations
|
||||
- name: Check schema matches migrations
|
||||
run: cd apps/api && npx prisma migrate diff --from-migrations prisma/migrations --to-schema-datamodel prisma/schema.prisma --shadow-database-url "$DATABASE_URL" --exit-code
|
||||
|
||||
- name: Apply migrations
|
||||
run: cd apps/api && npx prisma migrate deploy
|
||||
|
||||
- name: Unit tests
|
||||
run: pnpm test
|
||||
|
||||
- name: E2E tests
|
||||
run: pnpm test:e2e
|
||||
|
||||
- name: Build
|
||||
run: pnpm build
|
||||
run: pnpm build
|
||||
|
||||
Reference in New Issue
Block a user