-
Notifications
You must be signed in to change notification settings - Fork 1
256 lines (211 loc) · 6.93 KB
/
Copy pathci.yml
File metadata and controls
256 lines (211 loc) · 6.93 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
name: CI
on:
pull_request:
branches: [main]
push:
branches: [main]
jobs:
python-checks:
name: Python Checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install dependencies
run: |
pip install -r backend/requirements.txt \
-r agent/requirements.txt \
-r requirements-dev.txt
- name: Check formatting (black)
run: ./scripts/format-python.sh
- name: Lint (flake8 + pylint)
run: ./scripts/lint-python.sh
- name: Security scan (bandit)
run: ./scripts/security-python.sh
- name: Backend unit tests with coverage
run: ./scripts/test-backend.sh
env:
BYPASS_AUTH: "true"
- name: Upload backend coverage
uses: actions/upload-artifact@v5
if: always()
with:
name: backend-coverage
path: coverage/backend/
- name: Host Daemon unit tests with coverage
run: ./scripts/test-daemon.sh
- name: Upload daemon coverage
uses: actions/upload-artifact@v5
if: always()
with:
name: daemon-coverage
path: coverage/daemon/
frontend-checks:
name: Frontend Checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Set up Node 22
uses: actions/setup-node@v5
with:
node-version: "22"
- name: Install dependencies
run: cd frontend && npm ci
- name: Check formatting (prettier)
run: ./scripts/format-frontend.sh
- name: Lint (eslint)
run: ./scripts/lint-frontend.sh
- name: Type check (tsc)
run: ./scripts/typecheck-frontend.sh
- name: Build
run: ./scripts/build-frontend.sh
- name: Unit tests with coverage
run: ./scripts/test-frontend.sh
- name: Upload frontend coverage
uses: actions/upload-artifact@v5
if: always()
with:
name: frontend-coverage
path: coverage/frontend/
- name: Security audit (npm audit)
run: ./scripts/security-frontend.sh
continue-on-error: true
secret-detection:
name: Secret Detection
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Run gitleaks
uses: gitleaks/gitleaks-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
e2e-tests:
name: E2E Tests
runs-on: ubuntu-latest
needs: python-checks
steps:
- uses: actions/checkout@v5
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install dependencies
run: |
pip install -r backend/requirements.txt \
-r agent/requirements.txt \
-r requirements-dev.txt
- name: Run E2E tests
run: ./scripts/test-e2e.sh
env:
BYPASS_AUTH: "true"
coverage-summary:
name: Coverage Summary
runs-on: ubuntu-latest
needs: [python-checks, frontend-checks]
if: always()
steps:
- uses: actions/checkout@v5
- name: Download all coverage artifacts
uses: actions/download-artifact@v5
with:
path: coverage/
- name: Generate coverage summary table
run: |
python3 << 'PYEOF'
import json, os
def read_cov(path):
"""Read a coverage JSON and return (covered, total)."""
if not os.path.isfile(path):
return None, None
with open(path) as f:
data = json.load(f)
t = data.get("totals", {})
stmts = t.get("num_statements", 0)
covered = t.get("covered_lines", 0)
return covered, stmts
def read_frontend_cov(path):
"""Read vitest v8 coverage-summary.json."""
if not os.path.isfile(path):
return None, None
with open(path) as f:
data = json.load(f)
t = data.get("total", {}).get("lines", {})
total = int(t.get("total", 0))
covered = int(t.get("covered", 0))
if total == 0:
return None, None
return covered, total
def pct(covered, total):
return (covered / total * 100) if total else 0
rows = []
grand_covered = grand_total = 0
# Backend
c, t = read_cov("coverage/backend-coverage/coverage.json")
if c is not None:
rows.append(("Backend (backend/app)", c, t))
grand_covered += c
grand_total += t
# Daemon
c, t = read_cov("coverage/daemon-coverage/coverage.json")
if c is not None:
rows.append(("Host Daemon (agent)", c, t))
grand_covered += c
grand_total += t
# Frontend (json-summary reporter output)
c, t = read_frontend_cov(
"coverage/frontend-coverage/coverage-summary.json"
)
if c is not None:
rows.append(("Frontend (src)", c, t))
grand_covered += c
grand_total += t
lines = [
"## Test Coverage Summary",
"",
"| Component | Covered / Total | Percent |",
"|-----------|-----------------|---------|",
]
for name, covered, total in rows:
lines.append(
f"| {name} | {covered}/{total}"
f" | {pct(covered, total):.1f}% |"
)
lines.append(
f"| **Total** | **{grand_covered}/{grand_total}**"
f" | **{pct(grand_covered, grand_total):.1f}%** |"
)
summary_path = os.environ.get(
"GITHUB_STEP_SUMMARY", "/dev/null"
)
with open(summary_path, "a") as f:
f.write("\n".join(lines) + "\n")
# Also print to stdout
print("\n".join(lines))
PYEOF
container-builds:
name: Container Builds
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Build backend container
run: |
podman build --no-cache -t agent-dashboard-backend \
-f backend/Containerfile .
- name: Build frontend container
run: |
podman build --no-cache -t agent-dashboard-frontend \
-f frontend/Containerfile .
- name: Generate agent daemon Containerfile
run: |
pip install -q pyyaml jinja2
python3 agent/generate_containerfile.py
- name: Build agent daemon container
run: |
podman build --no-cache -t agent-dashboard-daemon \
-f agent/Containerfile agent/
timeout-minutes: 15