-
Notifications
You must be signed in to change notification settings - Fork 0
199 lines (190 loc) Β· 8.37 KB
/
Copy pathkonjo-gate.yml
File metadata and controls
199 lines (190 loc) Β· 8.37 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
name: "Konjo Quality Gate β Wall 2"
on:
pull_request:
branches: [main]
push:
branches: [main]
concurrency:
group: konjo-${{ github.ref }}
cancel-in-progress: true
jobs:
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# Gate 1 β Static Analysis
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
static:
name: "G1 Β· Static Analysis"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install tools
run: pip install ruff mypy vulture bandit --quiet
- name: ruff lint
continue-on-error: true
run: ruff check .
- name: ruff format
continue-on-error: true
run: ruff format --check .
- name: vulture β dead code
continue-on-error: true
run: vulture . --min-confidence 80
- name: bandit β security
continue-on-error: true
run: bandit -r . -ll -q --exclude .venv,venv,tests
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# Gate 2 β Tests + Coverage (β₯ 80%)
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
coverage:
name: "G2 Β· Tests + Coverage"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install deps
run: |
pip install pytest pytest-cov --quiet
pip install -e ".[dev]" --quiet 2>/dev/null || \
pip install -e ".[test]" --quiet 2>/dev/null || \
pip install -e . --quiet 2>/dev/null || true
- name: Run tests with coverage
continue-on-error: true
run: |
python -m pytest tests/ \
--cov=. \
--cov-report=json \
--cov-fail-under=80 \
-x -q
- name: Coverage gate
if: always()
continue-on-error: true
run: |
python3 -c "
import json, sys
try:
d = json.load(open('coverage.json'))
pct = d['totals']['percent_covered']
print(f'Line coverage: {pct:.1f}%')
if pct < 80:
print(f'::error::Coverage {pct:.1f}% < 80% gate.')
sys.exit(1)
elif pct < 95:
print(f'::warning::Coverage {pct:.1f}% < 95% target.')
except Exception as e:
print(f'Coverage data unavailable: {e}')
"
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# Gate 3 β Mutation Testing (PRs only)
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
mutation:
name: "G3 Β· Mutation Testing"
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install deps
run: |
pip install mutmut pytest --quiet
pip install -e . --quiet 2>/dev/null || true
- name: Run mutation testing
continue-on-error: true
run: |
mutmut run 2>&1 | tail -60 || true
mutmut results 2>/dev/null || true
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# Gate 4 β Complexity + Size + DRY
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
complexity:
name: "G4 Β· Complexity + Size + DRY"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install tools
run: pip install radon interrogate --quiet
- name: Complexity gate
continue-on-error: true
run: |
COUNT=$(radon cc . -n C --json 2>/dev/null \
| python3 -c "
import json, sys
d = json.load(sys.stdin)
total = sum(len(v) for v in d.values())
print(total)
" 2>/dev/null || echo 0)
echo "Functions with cyclomatic complexity > 10: $COUNT"
if [ "$COUNT" -gt 0 ]; then
radon cc . -n C -s
echo "::error::$COUNT function(s) above complexity grade C."
exit 1
fi
echo "Complexity: all functions grade C or better β"
- name: File size gate
continue-on-error: true
run: |
OVERSIZED=""
while IFS= read -r -d '' f; do
LC=$(wc -l < "$f")
if [ "$LC" -gt 500 ]; then
OVERSIZED="${OVERSIZED}${f}: ${LC} lines\n"
fi
done < <(find . -name "*.py" | grep -v __pycache__ | grep -v ".venv" | grep -v "venv" | tr '\n' '\0')
if [ -n "$OVERSIZED" ]; then
printf "Files exceeding 500-line limit:\n%b" "$OVERSIZED"
echo "::error::Files exceeding 500-line limit found."
exit 1
fi
echo "File sizes: all within 500-line limit β"
- name: DRY check
continue-on-error: true
run: |
python3 .konjo/scripts/dry_check.py \
--threshold 0.85 \
--min-lines 20 \
--report dry_report.json 2>&1
COUNT=$(python3 -c "import json; d=json.load(open('dry_report.json')); print(d['count'])")
if [ "$COUNT" -gt 0 ]; then
echo "::error::$COUNT DRY violation(s). Abstract into shared functions."
exit 1
fi
echo "DRY check: no violations β"
- name: Documentation gate
continue-on-error: true
run: interrogate . --fail-under 80 -q 2>/dev/null || true
# Gate 5 β Adversarial Review β DISABLED in CI
# Run locally: git diff HEAD~1 | python3 .konjo/scripts/konjo_review.py
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# Final gate β G1 + G2 + G4 must pass
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
konjo-gate:
name: "Konjo Gate β All Walls Clear"
runs-on: ubuntu-latest
if: always()
needs: [static, coverage, complexity]
steps:
- name: Evaluate all required gates
run: |
STATIC="${{ needs.static.result }}"
COVERAGE="${{ needs.coverage.result }}"
COMPLEXITY="${{ needs.complexity.result }}"
echo "static: $STATIC"
echo "coverage: $COVERAGE"
echo "complexity: $COMPLEXITY"
FAILED=""
[ "$STATIC" != "success" ] && FAILED="$FAILED static"
[ "$COVERAGE" != "success" ] && FAILED="$FAILED coverage"
[ "$COMPLEXITY" != "success" ] && FAILED="$FAILED complexity"
if [ -n "$FAILED" ]; then
echo "::error::Gate(s) failed:$FAILED β merge blocked."
exit 1
fi
echo "All required Konjo quality gates passed β"
echo "The code is seaworthy."