-
Notifications
You must be signed in to change notification settings - Fork 2
233 lines (191 loc) · 6.42 KB
/
ci.yml
File metadata and controls
233 lines (191 loc) · 6.42 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
name: CI
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
workflow_dispatch:
env:
PYTHON_VERSION: '3.10'
UV_SYSTEM_PYTHON: 1
jobs:
lint:
name: Lint Code
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install dependencies
run: |
uv pip install ruff mypy pylint black isort
uv pip install -e .[test]
- name: Run Ruff linter
run: ruff check src/ tests/
continue-on-error: true
- name: Run Black formatter check
run: black --check src/ tests/
continue-on-error: true
- name: Run isort import checker
run: isort --check-only src/ tests/
continue-on-error: true
- name: Run MyPy type checker
run: mypy src/ --ignore-missing-imports
continue-on-error: true
- name: Run Pylint
run: pylint src/mcp_gitlab --exit-zero
test:
name: Test Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
uv pip install -e .[test]
- name: Run tests with pytest
run: |
pytest tests/ -v --cov=src/mcp_gitlab --cov-report=xml --cov-report=html --cov-report=term
env:
GITLAB_PRIVATE_TOKEN: ${{ secrets.GITLAB_PRIVATE_TOKEN }}
GITLAB_URL: https://gitlab.com
- name: Upload coverage reports
uses: actions/upload-artifact@v6
with:
name: coverage-${{ matrix.python-version }}
path: |
coverage.xml
htmlcov/
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
file: ./coverage.xml
flags: unittests
name: codecov-${{ matrix.python-version }}
token: ${{ secrets.CODECOV_TOKEN }}
continue-on-error: true
security:
name: Security Scan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install dependencies
run: |
uv pip install safety bandit pip-audit
uv pip install -e .
- name: Run Safety security check
run: safety check --json
continue-on-error: true
- name: Run Bandit security linter
run: bandit -r src/ -f json -o bandit-report.json
continue-on-error: true
- name: Run pip-audit for dependency vulnerabilities
run: pip-audit
continue-on-error: true
- name: Upload security reports
uses: actions/upload-artifact@v6
if: always()
with:
name: security-reports
path: |
bandit-report.json
build:
name: Build Package
runs-on: ubuntu-latest
needs: [lint, test]
steps:
- uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install build dependencies
run: |
uv pip install build wheel setuptools
- name: Build distribution packages
run: python -m build
- name: Check distribution packages
run: |
uv pip install twine
twine check dist/*
- name: Validate package size
run: |
# Check wheel size (should be reasonable for an MCP server)
wheel_size=$(find dist/ -name "*.whl" -exec ls -la {} \; | awk '{print $5}')
max_size=10485760 # 10MB in bytes
if [ "$wheel_size" -gt "$max_size" ]; then
echo "❌ Package size too large: $(( wheel_size / 1024 / 1024 ))MB (max: 10MB)"
echo "Consider excluding unnecessary files or reducing dependencies"
exit 1
else
echo "✅ Package size acceptable: $(( wheel_size / 1024 / 1024 ))MB"
fi
# List package contents for transparency
echo "📦 Package contents:"
python -c "
import zipfile
import glob
wheel_files = glob.glob('dist/*.whl')
if wheel_files:
with zipfile.ZipFile(wheel_files[0], 'r') as zf:
for info in sorted(zf.infolist(), key=lambda x: x.file_size, reverse=True)[:20]:
print(f'{info.file_size:>8} bytes {info.filename}')
"
- name: Upload build artifacts
uses: actions/upload-artifact@v6
with:
name: dist-packages
path: dist/
integration-test:
name: Integration Tests
runs-on: ubuntu-latest
needs: [build]
if: github.event_name == 'pull_request' || github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install package
run: |
uv pip install -e .[test]
- name: Run integration tests
run: |
pytest tests/test_integration.py -v -m integration
env:
GITLAB_PRIVATE_TOKEN: ${{ secrets.GITLAB_TEST_TOKEN }}
GITLAB_URL: ${{ secrets.GITLAB_TEST_URL }}
continue-on-error: true