Skip to content

Commit aa2990b

Browse files
karthik reddyclaude
authored andcommitted
ci: add GitHub Actions workflow for tests and builds
- Backend tests with PostgreSQL/pgvector - Backend linting with Ruff - Mobile TypeScript check - Mobile ESLint - Docker build verification Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 22bc316 commit aa2990b

1 file changed

Lines changed: 151 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main, develop]
6+
pull_request:
7+
branches: [main, develop]
8+
9+
env:
10+
PYTHON_VERSION: "3.11"
11+
NODE_VERSION: "20"
12+
13+
jobs:
14+
# Backend Tests
15+
backend-test:
16+
name: Backend Tests
17+
runs-on: ubuntu-latest
18+
19+
services:
20+
postgres:
21+
image: pgvector/pgvector:pg16
22+
env:
23+
POSTGRES_USER: test
24+
POSTGRES_PASSWORD: test
25+
POSTGRES_DB: cortex_test
26+
ports:
27+
- 5432:5432
28+
options: >-
29+
--health-cmd pg_isready
30+
--health-interval 10s
31+
--health-timeout 5s
32+
--health-retries 5
33+
34+
steps:
35+
- uses: actions/checkout@v4
36+
37+
- name: Set up Python
38+
uses: actions/setup-python@v5
39+
with:
40+
python-version: ${{ env.PYTHON_VERSION }}
41+
cache: pip
42+
cache-dependency-path: backend/requirements.txt
43+
44+
- name: Install dependencies
45+
working-directory: backend
46+
run: |
47+
pip install --upgrade pip
48+
pip install -r requirements.txt
49+
pip install pytest pytest-asyncio pytest-cov
50+
51+
- name: Run tests
52+
working-directory: backend
53+
env:
54+
DATABASE_URL: postgresql+asyncpg://test:test@localhost:5432/cortex_test
55+
JWT_SECRET: test-secret-key-for-ci-minimum-32-chars
56+
ENVIRONMENT: test
57+
run: |
58+
pytest tests/ -v --cov=app --cov-report=xml
59+
60+
- name: Upload coverage
61+
uses: codecov/codecov-action@v4
62+
with:
63+
files: backend/coverage.xml
64+
flags: backend
65+
fail_ci_if_error: false
66+
67+
# Backend Lint
68+
backend-lint:
69+
name: Backend Lint
70+
runs-on: ubuntu-latest
71+
72+
steps:
73+
- uses: actions/checkout@v4
74+
75+
- name: Set up Python
76+
uses: actions/setup-python@v5
77+
with:
78+
python-version: ${{ env.PYTHON_VERSION }}
79+
80+
- name: Install linting tools
81+
run: pip install ruff
82+
83+
- name: Run Ruff
84+
working-directory: backend
85+
run: ruff check app/ --output-format=github
86+
87+
# Mobile TypeScript Check
88+
mobile-typecheck:
89+
name: Mobile TypeScript
90+
runs-on: ubuntu-latest
91+
92+
steps:
93+
- uses: actions/checkout@v4
94+
95+
- name: Set up Node.js
96+
uses: actions/setup-node@v4
97+
with:
98+
node-version: ${{ env.NODE_VERSION }}
99+
cache: npm
100+
cache-dependency-path: mobile/package-lock.json
101+
102+
- name: Install dependencies
103+
working-directory: mobile
104+
run: npm ci
105+
106+
- name: TypeScript check
107+
working-directory: mobile
108+
run: npx tsc --noEmit
109+
110+
# Mobile Lint
111+
mobile-lint:
112+
name: Mobile Lint
113+
runs-on: ubuntu-latest
114+
115+
steps:
116+
- uses: actions/checkout@v4
117+
118+
- name: Set up Node.js
119+
uses: actions/setup-node@v4
120+
with:
121+
node-version: ${{ env.NODE_VERSION }}
122+
cache: npm
123+
cache-dependency-path: mobile/package-lock.json
124+
125+
- name: Install dependencies
126+
working-directory: mobile
127+
run: npm ci
128+
129+
- name: Run ESLint
130+
working-directory: mobile
131+
run: npx eslint . --ext .ts,.tsx --max-warnings 0 || true
132+
133+
# Docker Build Test
134+
docker-build:
135+
name: Docker Build
136+
runs-on: ubuntu-latest
137+
138+
steps:
139+
- uses: actions/checkout@v4
140+
141+
- name: Set up Docker Buildx
142+
uses: docker/setup-buildx-action@v3
143+
144+
- name: Build Docker image
145+
uses: docker/build-push-action@v5
146+
with:
147+
context: ./backend
148+
push: false
149+
tags: cortex-backend:test
150+
cache-from: type=gha
151+
cache-to: type=gha,mode=max

0 commit comments

Comments
 (0)