-
Notifications
You must be signed in to change notification settings - Fork 22
159 lines (136 loc) · 4.89 KB
/
ci.yml
File metadata and controls
159 lines (136 loc) · 4.89 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
name: CI
on:
push:
branches: [main]
paths:
- '.claude/skills/solidity-guard/scripts/**'
- 'apps/cli/**'
- 'apps/web/**'
- '.github/workflows/ci.yml'
pull_request:
paths:
- '.claude/skills/solidity-guard/scripts/**'
- 'apps/cli/**'
- 'apps/web/**'
- '.github/workflows/ci.yml'
workflow_dispatch:
jobs:
# ── Lint ──────────────────────────────────────────────────────────────
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: Install ruff
run: pip install ruff
- name: Lint Python
run: ruff check .claude/skills/solidity-guard/scripts/ apps/cli/ apps/web/backend/
# ── Scanner Tests & Benchmark ────────────────────────────────────────
tests:
name: Scanner Tests & Benchmark
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: Install dependencies
run: |
pip install pytest
pip install -e apps/cli
- name: Run scanner tests
run: python3 -m pytest .claude/skills/solidity-guard/scripts/test_scanners.py -v
- name: Run CLI tests
run: python3 -m pytest apps/cli/tests/test_cli.py -v
- name: Run DeFiVulnLabs benchmark
run: |
python3 .claude/skills/solidity-guard/scripts/ctf_benchmark.py \
--output benchmark-results.json
- name: Validate 100% detection rate
run: |
python3 -c "
import json, sys
with open('benchmark-results.json') as f:
data = json.load(f)
defi = data.get('DeFiVulnLabs', {})
total = defi.get('total_contracts', 0)
detected = defi.get('detected', 0)
rate = (detected / total * 100) if total else 0
print(f'Detection rate: {detected}/{total} ({rate:.1f}%)')
if rate < 100:
print(f'::error::Detection rate {rate:.1f}% below 100%')
sys.exit(1)
print('Benchmark PASSED')
"
- name: Upload results
uses: actions/upload-artifact@v4
if: always()
with:
name: benchmark-results
path: benchmark-results.json
- name: Summary
if: always()
run: |
if [ -f benchmark-results.json ]; then
python3 -c "
import json
with open('benchmark-results.json') as f:
data = json.load(f)
defi = data.get('DeFiVulnLabs', {})
total = defi.get('total_contracts', 0)
detected = defi.get('detected', 0)
results = defi.get('results', [])
tp = sum(len(r.get('true_positives', [])) for r in results)
expected = sum(len(r.get('expected', [])) for r in results)
print('## SolidityGuard Benchmark Results')
print()
print(f'| Metric | Value |')
print(f'|--------|-------|')
print(f'| Contracts | {total} |')
print(f'| Detected | {detected}/{total} |')
print(f'| Patterns | {tp}/{expected} |')
print(f'| Rate | {detected*100//total if total else 0}% |')
" >> "$GITHUB_STEP_SUMMARY"
fi
# ── Frontend Build ───────────────────────────────────────────────────
frontend:
name: Frontend Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
- name: Install & build
run: |
cd apps/web/frontend
npm ci
npm run build
- name: TypeScript check
run: |
cd apps/web/frontend
npx tsc --noEmit
# ── Backend Check ────────────────────────────────────────────────────
backend:
name: Backend Check
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: Install backend
run: |
pip install -e apps/web/backend
pip install pytest httpx
- name: Test import
run: python3 -c "from solidityguard_api.main import app; print('Backend OK')"
- name: Run API tests
run: python3 -m pytest apps/web/backend/tests/ -v