Skip to content

Fix CI not resetting db after test, causing failing seeding for runs on other branches #119

Fix CI not resetting db after test, causing failing seeding for runs on other branches

Fix CI not resetting db after test, causing failing seeding for runs on other branches #119

Workflow file for this run

name: CI/CD - Linter, formatter and tests
on:
push:
branches:
- main
pull_request:
types:
- opened
- synchronize
env:
# Test database on the self-hosted runner
DATABASE_URL: postgresql://ci:ci@localhost:5432/ci
jobs:
lint-format-and-test:
runs-on: [self-hosted]
timeout-minutes: 10
steps:
- name: Check out source
uses: actions/checkout@v4
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Write env files
run: |
printf 'DATABASE_URL="%s"\n' "$DATABASE_URL" > apps/backend/.env
cp apps/backend/.env packages/db/.env
- name: Generate Prisma client
run: pnpm --filter @t09-project-2/db run db:generate
- name: Apply database migrations
run: pnpm --filter @t09-project-2/db run db:deploy
- name: Seed test database
run: pnpm --filter @t09-project-2/db run db:seed
- name: Check formatting
run: pnpm check
- name: Lint
run: pnpm lint
- name: Typecheck
run: pnpm typecheck
- name: Test
run: pnpm test
- name: Reset test database
if: always()
run: pnpm --filter @t09-project-2/db run db:blank