-
Notifications
You must be signed in to change notification settings - Fork 0
136 lines (114 loc) · 3.19 KB
/
coding-interview_ci.yml
File metadata and controls
136 lines (114 loc) · 3.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
name: CI for Coding Interview Platform
on:
workflow_dispatch:
pull_request:
branches:
- main
paths:
- '02-coding-interview/**'
push:
branches:
- main
paths:
- '02-coding-interview/**'
defaults:
run:
working-directory: 02-coding-interview
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: 02-coding-interview/package-lock.json
- name: Install dependencies
run: npm ci
- name: Run ESLint (Frontend)
run: npm run lint -w @interview/frontend
- name: Run TypeScript compiler check
run: npm run build
test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:15-alpine
env:
POSTGRES_DB: interview_platform
POSTGRES_USER: admin
POSTGRES_PASSWORD: password
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
docker:
image: docker:dind
options: --privileged
ports:
- 2375:2375
env:
DOCKER_TLS_CERTDIR: ""
env:
DOCKER_HOST: tcp://localhost:2375
steps:
- uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: 02-coding-interview/package-lock.json
- name: Install dependencies
run: npm ci
- name: Set up environment
run: |
cd packages/backend
cp .env.example .env
- name: Generate Prisma Client
run: |
cd packages/backend
npx prisma generate
- name: Run database migrations
run: |
cd packages/backend
echo "Running migrations..."
npx prisma migrate deploy
echo "Migration exit code: $?"
echo "Verifying tables..."
npx prisma db execute --stdin <<< "SELECT tablename FROM pg_tables WHERE schemaname = 'public';"
env:
DATABASE_URL: postgresql://admin:password@localhost:5432/interview_platform
- name: Wait for Docker and pull images
run: |
echo "Waiting for Docker daemon..."
timeout 60 sh -c 'until docker info > /dev/null 2>&1; do sleep 2; done'
echo "Docker is ready. Pulling test images..."
docker pull node:20-alpine
docker pull python:3.11-alpine
- name: Run integration tests
run: npm test -- --verbose
env:
DATABASE_URL: postgresql://admin:password@localhost:5432/interview_platform
REDIS_URL: redis://localhost:6379
NODE_ENV: test
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results
path: 02-coding-interview/packages/backend/coverage/