-
Notifications
You must be signed in to change notification settings - Fork 0
207 lines (170 loc) · 5.35 KB
/
Copy pathci.yml
File metadata and controls
207 lines (170 loc) · 5.35 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
name: CI
on:
push:
branches: [main, claude/**]
pull_request:
branches: [main]
jobs:
test:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: "pip"
cache-dependency-path: apps/api/requirements*.txt
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r apps/api/requirements-test.txt
- name: Run unit tests
run: |
cd apps/api
PYTHONPATH=$PYTHONPATH:../../services/runner/app pytest tests/ --tb=short -v
- name: Run tests with coverage
run: |
cd apps/api
PYTHONPATH=$PYTHONPATH:../../services/runner/app pytest tests/ --cov=app --cov-report=xml --cov-report=term-missing
- name: Upload coverage report
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: apps/api/coverage.xml
integration:
name: Integration Tests
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Create .env file
run: |
cat > .env << 'EOF'
M87_API_KEY=m87-ci-test-key
M87_ENABLE_TEST_ENDPOINTS=true
POSTGRES_PASSWORD=ci-test-password
EOF
- name: Start services
run: |
docker compose -f infra/docker-compose.yml up -d --build
sleep 10
- name: Wait for API health
run: |
for i in {1..30}; do
if curl -s http://localhost:8000/health | grep -q '"ok":true'; then
echo "API is healthy"
exit 0
fi
echo "Waiting for API... ($i/30)"
sleep 2
done
echo "API failed to start"
docker compose -f infra/docker-compose.yml logs
exit 1
- name: Run proof-test.sh
run: ./scripts/proof-test.sh
- name: Collect logs on failure
if: failure()
run: |
docker compose -f infra/docker-compose.yml logs > docker-logs.txt
- name: Upload logs on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: docker-logs
path: docker-logs.txt
- name: Stop services
if: always()
run: docker compose -f infra/docker-compose.yml down -v
audit:
name: Audit Rail
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: "pip"
cache-dependency-path: apps/api/requirements*.txt
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
cache-dependency-path: apps/ui/package-lock.json
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -r apps/api/requirements-test.txt
- name: Install Node dependencies
run: |
cd apps/ui
npm ci
- name: Run audit.sh
env:
PYTHONPATH: ${{ github.workspace }}/services/runner/app
run: ./scripts/audit.sh
- name: Upload evidence artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: audit-evidence
path: evidence/
layer0-proof-rail:
name: Layer 0 Proof Rail
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: "pip"
cache-dependency-path: apps/api/requirements*.txt
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r apps/api/requirements-test.txt
- name: Run TOCTOU red-team probes
run: |
cd apps/api
python -m pytest tests/test_layer0_toctou_probes.py -v --tb=short
- name: Run Layer 0 traceable demo
run: |
python scripts/layer0_demo.py --json > layer0_proof.json 2>layer0_demo.log
python -c "
import json, sys
d = json.load(open('layer0_proof.json'))
v = d['verdict']
c = d['provenance']['repo_commit']
assert v == 'LAYER_0_ENFORCED', f'Verdict: {v}'
assert c != 'unknown', 'Missing commit provenance'
print(f'Layer 0 proof: {v} | commit: {c[:12]} | checks: {d[\"passed\"]}/{d[\"total_checks\"]}')
"
- name: Upload proof artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: layer0-proof
path: |
layer0_proof.json
layer0_demo.log
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Check Python syntax
run: |
python -m py_compile apps/api/app/*.py
python -m py_compile apps/api/app/**/*.py 2>/dev/null || true
python -m py_compile apps/api/tests/*.py