Skip to content
Merged

Dev #53

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
24 changes: 22 additions & 2 deletions .github/workflows/backend-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,23 @@ jobs:
build-and-test:
runs-on: ubuntu-latest

# Add PostgreSQL service container
services:
postgres:
image: postgres:15-alpine
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: time_booking
ports:
- 5432:5432
# Health check to ensure PostgreSQL is ready
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5

defaults:
run:
working-directory: ./backend
Expand All @@ -32,8 +49,11 @@ jobs:
- name: Install dependencies
run: npm install # Using install instead of ci

# Continue with other steps as before

# Create .env file with DATABASE_URL
- name: Create .env file
run: |
echo "DATABASE_URL=postgresql://postgres:password@localhost:5432/time_booking?schema=public" > .env

- name: Fix linting issues
run: npm run lint:fix

Expand Down
6 changes: 5 additions & 1 deletion backend/src/tests/db-connection.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { PrismaClient } from '@prisma/client';
import * as dotenv from 'dotenv';

// Load environment variables
dotenv.config();

describe('Database Connection', () => {
let prisma: PrismaClient;
Expand All @@ -13,7 +17,7 @@ describe('Database Connection', () => {

it('should connect to the database successfully', async () => {
if (!process.env.DATABASE_URL) {
// Remove console.log and use return to skip test
console.warn('DATABASE_URL not found, skipping test');
return;
}

Expand Down