-
Notifications
You must be signed in to change notification settings - Fork 3
209 lines (172 loc) · 6.02 KB
/
code-quality.yml
File metadata and controls
209 lines (172 loc) · 6.02 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
name: Code Quality
on:
push:
branches: [ main, develop, feature/* ]
pull_request:
branches: [ main, develop ]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
pre-commit:
name: Pre-commit hooks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pre-commit
- name: Run pre-commit
run: pre-commit run --all-files
lint-and-format:
name: Linting and Formatting
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e . || echo "Package install failed, installing dev deps directly"
pip install black ruff isort
- name: Check code formatting with Black
run: black --check --diff .
- name: Lint with Ruff
run: ruff check .
- name: Check import sorting with isort
run: isort --check-only --diff .
type-check:
name: Type Checking
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e . || echo "Package install failed, installing deps directly"
pip install mypy types-requests
- name: Type check with MyPy
run: mypy src/
security:
name: Security Analysis
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install bandit[toml] safety
- name: Run Bandit security linter
run: bandit -r src/ -f json -o bandit-report.json || true
- name: Upload Bandit report
uses: actions/upload-artifact@v4
if: always()
with:
name: bandit-report
path: bandit-report.json
- name: Check dependencies for security vulnerabilities
run: safety check --json --output safety-report.json || true
- name: Upload Safety report
uses: actions/upload-artifact@v4
if: always()
with:
name: safety-report
path: safety-report.json
complexity:
name: Code Complexity Analysis
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install radon xenon
- name: Run complexity analysis
run: |
echo "## Cyclomatic Complexity" >> complexity-report.md
radon cc src/ -s >> complexity-report.md
echo "" >> complexity-report.md
echo "## Maintainability Index" >> complexity-report.md
radon mi src/ -s >> complexity-report.md
echo "" >> complexity-report.md
echo "## Raw Metrics" >> complexity-report.md
radon raw src/ -s >> complexity-report.md
- name: Check complexity thresholds
run: xenon --max-absolute B --max-modules B --max-average A src/
- name: Upload complexity report
uses: actions/upload-artifact@v4
if: always()
with:
name: complexity-report
path: complexity-report.md
test-coverage:
name: Test Coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e . || echo "Package install failed, installing deps directly"
pip install pytest pytest-cov pytest-asyncio pytest-mock coverage
- name: Run tests with coverage
run: |
pytest --cov=src/mujoco_mcp --cov-report=xml --cov-report=html --cov-report=term-missing
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
- name: Upload coverage report
uses: actions/upload-artifact@v4
if: always()
with:
name: coverage-report
path: htmlcov/
quality-gate:
name: Quality Gate
runs-on: ubuntu-latest
needs: [pre-commit, lint-and-format, type-check, security, complexity, test-coverage]
if: always()
steps:
- name: Check all jobs status
run: |
if [[ "${{ needs.pre-commit.result }}" == "failure" || \
"${{ needs.lint-and-format.result }}" == "failure" || \
"${{ needs.type-check.result }}" == "failure" || \
"${{ needs.security.result }}" == "failure" || \
"${{ needs.complexity.result }}" == "failure" || \
"${{ needs.test-coverage.result }}" == "failure" ]]; then
echo "❌ Quality gate failed - some checks did not pass"
exit 1
else
echo "✅ Quality gate passed - all checks successful"
fi