Repository navigation
190 lines (160 loc) · 4.85 KB
/
Copy pathci.yml
File metadata and controls
190 lines (160 loc) · 4.85 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
name: CI
on:
push:
branches: [main, develop]
pull_request:
branches: [main]
env:
NODE_VERSION: '20'
PYTHON_VERSION: '3.11'
jobs:
# ==========================================================================
# Frontend (Site + App)
# ==========================================================================
frontend-lint:
name: Frontend Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Lint
run: npx nx lint site && npx nx lint app
frontend-build:
name: Frontend Build
runs-on: ubuntu-latest
needs: frontend-lint
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build Site
run: npx nx build site --configuration=production
env:
NEXT_PUBLIC_RENDER_GIT_COMMIT: ${{ github.sha }}
- name: Build App
run: npx nx build app --configuration=production
frontend-test:
name: Frontend E2E Tests
runs-on: ubuntu-latest
needs: frontend-build
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Install Playwright
run: npx playwright install --with-deps chromium
- name: Build Site
run: npx nx build site --configuration=production
- name: Run E2E Tests
run: cd apps/site && npx playwright test --project=chromium
env:
CI: true
# ==========================================================================
# Backend (API)
# ==========================================================================
backend-lint:
name: Backend Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install dependencies
run: |
cd apps/api
pip install -e ".[dev]" || pip install ruff
- name: Lint with Ruff
run: |
cd apps/api
ruff check src/ || true
backend-test:
name: Backend Tests
runs-on: ubuntu-latest
needs: backend-lint
services:
postgres:
image: postgres:15
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: sql2ai_test
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install API dependencies
run: |
cd apps/api
pip install -e ".[dev]" || pip install pytest pytest-asyncio
- name: Install library dependencies
run: |
for lib in libs/*/; do
if [ -f "$lib/pyproject.toml" ]; then
pip install -e "$lib" || true
fi
done
- name: Run library tests
run: |
for lib in libs/*/; do
if [ -d "$lib/tests" ]; then
echo "Testing $lib"
cd "$lib"
pytest tests/ -v || true
cd ../..
fi
done
# ==========================================================================
# Security Scan
# ==========================================================================
security:
name: Security Scan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
scan-ref: '.'
severity: 'CRITICAL,HIGH'
exit-code: '0' # Don't fail on vulnerabilities for now
# ==========================================================================
# Deploy (only on main)
# ==========================================================================
deploy-site:
name: Deploy Marketing Site
runs-on: ubuntu-latest
needs: [frontend-build, frontend-test]
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
steps:
- name: Trigger Render Deploy
run: |
echo "Render auto-deploys on push to main"
echo "Site will be available at https://sql2.ai"