-
Notifications
You must be signed in to change notification settings - Fork 0
362 lines (303 loc) · 9.63 KB
/
Copy pathci.yml
File metadata and controls
362 lines (303 loc) · 9.63 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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
name: Kagibi CI
on:
push:
branches: [ "main", "master" ]
pull_request:
branches: [ "main", "master" ]
jobs:
# Job pour le Backend (Go)
backend-test:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./backend
env:
GOTOOLCHAIN: local
services:
postgres:
image: postgres:16
env:
POSTGRES_DB: kagibi_test
POSTGRES_USER: test
POSTGRES_PASSWORD: testpassword
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
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.25.4'
cache-dependency-path: backend/go.sum
- name: Install dependencies
run: go mod download
- name: Verify Code Formatting
run: |
if [ -n "$(gofmt -l .)" ]; then
echo "Code is not formatted. Please run 'go fmt ./...'"
exit 1
fi
- name: Run Unit Tests
# Exécute les tests unitaires (Middleware, Utils, Handlers, Models)
run: go test -v ./utils/... ./middleware/... ./handlers/auth/... ./handlers/folders/... ./pkg/...
- name: Run Tests with Coverage
run: |
go test -v ./utils/... -coverprofile coverage.out -covermode atomic
go test -v ./middleware/... -coverprofile coverage_middleware.out -covermode atomic
- name: Upload Coverage
uses: codecov/codecov-action@v3
with:
file: ./backend/coverage.out
flags: backend
continue-on-error: true
- name: Build Backend
# Vérifie que le code compile correctement
run: go build -v .
# Job pour les tests d'intégration Backend
backend-integration:
runs-on: ubuntu-latest
needs: backend-test
services:
postgres:
image: postgres:16
env:
POSTGRES_DB: kagibi_test
POSTGRES_USER: test
POSTGRES_PASSWORD: testpassword
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
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.25.4'
- name: Run Integration Tests
working-directory: ./backend
env:
TEST_DB_HOST: localhost
TEST_DB_PORT: 5432
TEST_DB_USER: test
TEST_DB_PASSWORD: testpassword
TEST_DB_NAME: kagibi_test
TEST_REDIS_HOST: localhost
TEST_REDIS_PORT: 6379
run: |
go mod download
go test -v ./... -tags=integration -timeout 10m
# Job pour le Frontend (Vue.js)
frontend-test:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./frontend
steps:
- uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '22'
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- name: Install dependencies
run: npm ci
- name: Run Linter
run: npm run lint --if-present || echo "No linter configured"
- name: Run Unit Tests
run: npm run test -- --run
- name: Run Tests with Coverage
run: npm run test -- --run --coverage || npm run test -- --run
- name: Upload Coverage
if: success()
uses: codecov/codecov-action@v3
with:
file: ./frontend/coverage/coverage-final.json
flags: frontend
continue-on-error: true
- name: Build Frontend
run: npm run build
- name: Check Build Size
run: |
echo "Build size:"
du -sh dist/
# Job pour les tests E2E
e2e-tests:
runs-on: ubuntu-latest
needs: [backend-test, frontend-test]
services:
postgres:
image: postgres:16
env:
POSTGRES_DB: kagibi_test
POSTGRES_USER: test
POSTGRES_PASSWORD: testpassword
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
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.25.4'
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '22'
- name: Install Backend Dependencies
working-directory: ./backend
run: go mod download
- name: Install Frontend Dependencies
working-directory: ./frontend
run: npm ci
- name: Build Frontend
working-directory: ./frontend
run: npm run build
- name: Start Backend Server
working-directory: ./backend
env:
DATABASE_URL: postgres://test:testpassword@localhost:5432/kagibi_test
REDIS_URL: redis://localhost:6379
JWT_SECRET: test-secret-key-for-ci
EMAIL_ENCRYPTION_KEY: "0000000000000000000000000000000000000000000000000000000000000000"
PORT: 8080
run: |
go build -o server .
./server &
echo $! > server.pid
sleep 5
- name: Health Check
run: |
curl -f http://localhost:8080/health || exit 1
- name: Stop Backend Server
if: always()
working-directory: ./backend
run: |
if [ -f server.pid ]; then
kill $(cat server.pid) || true
fi
# Job pour l'audit de sécurité
security-audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.25.4'
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '22'
- name: Run Go Security Scan (gosec)
working-directory: ./backend
run: |
go install github.com/securego/gosec/v2/cmd/gosec@latest
gosec -fmt=json -out=gosec-report.json ./... || true
- name: Run npm audit
working-directory: ./frontend
run: |
npm audit --audit-level=moderate || echo "npm audit found vulnerabilities"
- name: Check for hardcoded secrets
run: |
# Rechercher des mots de passe/secrets en dur (pas les variables nommées "password")
echo "🔍 Checking for hardcoded credentials..."
# Pattern pour trouver des secrets en dur (éviter les faux positifs)
# Chercher: password = "valeur", PASSWORD="valeur", etc. mais pas password = ref(''), type="password", etc.
if grep -rE '(password|secret|api_key|private_key|token)\s*[=:]\s*["\047][a-zA-Z0-9!@#$%^&*()_+\-=\[\]{};:,.<>?/]{8,}["\047]' \
--include="*.go" --include="*.js" --include="*.vue" --include="*.ts" . | \
grep -v "test" | \
grep -v "example" | \
grep -v "_test.go" | \
grep -v ".spec.js" | \
grep -v "type=\"password\"" | \
grep -v "type='password'" | \
grep -v "placeholder=" | \
grep -v "ref('')" | \
grep -v "ref(\"\")" | \
grep -v "binding:" | \
grep -v "json:" | \
grep -v "// " | \
grep -v "github.com" | \
grep -v "sslmode=disable"; then
echo "⚠️ Potential hardcoded credentials found!"
exit 1
fi
echo "✅ No hardcoded credentials detected"
- name: Check for exposed API keys
run: |
echo "🔍 Checking for exposed API keys..."
# Chercher des clés API exposées (longues chaînes alphanumériques)
if grep -rE '(api_key|apikey|access_key|secret_key)\s*[=:]\s*["\047][a-zA-Z0-9]{32,}["\047]' \
--include="*.go" --include="*.js" --include="*.vue" --include="*.ts" . | \
grep -v "test" | \
grep -v "example" | \
grep -v "binding:" | \
grep -v "json:" | \
grep -v "// "; then
echo "⚠️ Potential exposed API keys found!"
exit 1
fi
echo "✅ No exposed API keys detected"
# Job pour vérifier la qualité du code
code-quality:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.25.4'
- name: Install dependencies
working-directory: ./backend
run: go mod download
- name: Run go vet
working-directory: ./backend
run: |
# Vérifier les sous-packages testés uniquement
go vet ./handlers/auth/... ./handlers/folders/... ./middleware/... ./pkg/... ./utils/...
- name: Run staticcheck
working-directory: ./backend
run: |
go install honnef.co/go/tools/cmd/staticcheck@latest
staticcheck ./handlers/auth/... ./handlers/folders/... ./middleware/... ./pkg/... ./utils/... || echo "⚠️ Staticcheck warnings found (non-blocking)"
- name: Check for TODO/FIXME comments
run: |
echo "📝 Checking for TODO/FIXME comments..."
grep -rn "TODO\|FIXME" --include="*.go" --include="*.js" --include="*.vue" . || echo "No TODO/FIXME found"