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
21 changes: 21 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,24 @@ jobs:
- run: npx tsc --noEmit
- run: npm run build
- run: npm test --if-present

integration:
name: Integration tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: npm
- run: npm ci || npm install
- run: npx prisma generate
- run: docker compose -f docker-compose.test.yml up -d --build
- run: npm run test:integration
env:
DATABASE_URL: postgresql://wraith:wraith@localhost:55432/wraith_test
DIRECT_DATABASE_URL: postgresql://wraith:wraith@localhost:55432/wraith_test
INTEGRATION_API_URL: http://localhost:3300
- name: Tear down integration stack
if: always()
run: docker compose -f docker-compose.test.yml down -v
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ FROM node:20-alpine AS runner

WORKDIR /app

# Install production dependencies only (excludes typescript, ts-node-dev, @types/*)
# The app runs Prisma schema sync on startup, so the runtime image needs the
# Prisma CLI available without downloading it via npx at container boot.
COPY package*.json ./
RUN npm ci --omit=dev
RUN npm ci

# Copy built output + Prisma schema from builder
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/prisma ./prisma

# Run migrations then start the app
CMD ["sh", "-c", "npx prisma migrate deploy && node dist/index.js"]
CMD ["node", "dist/index.js"]
36 changes: 36 additions & 0 deletions docker-compose.test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
services:
db:
image: postgres:16-alpine
container_name: wraith_test_db
environment:
POSTGRES_USER: wraith
POSTGRES_PASSWORD: wraith
POSTGRES_DB: wraith_test
ports:
- "55432:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U wraith -d wraith_test"]
interval: 2s
timeout: 5s
retries: 20

wraith:
build: .
container_name: wraith_test_api
depends_on:
db:
condition: service_healthy
environment:
DATABASE_URL: postgresql://wraith:wraith@db:5432/wraith_test
DIRECT_DATABASE_URL: postgresql://wraith:wraith@db:5432/wraith_test
NODE_ENV: test
PORT: 3000
RATE_LIMIT_MAX: 1000
SKIP_INDEXER: "true"
ports:
- "3300:3000"
healthcheck:
test: ["CMD-SHELL", "wget -qO- http://localhost:3000/healthz >/dev/null 2>&1"]
interval: 2s
timeout: 5s
retries: 30
Loading