-
Notifications
You must be signed in to change notification settings - Fork 1
140 lines (118 loc) · 4.64 KB
/
ci.yml
File metadata and controls
140 lines (118 loc) · 4.64 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
name: CI
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
exclude:
# Reduce matrix size while maintaining good coverage
- os: windows-latest
python-version: '3.8'
- os: macos-latest
python-version: '3.8'
- os: windows-latest
python-version: '3.9'
- os: macos-latest
python-version: '3.9'
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 .
pip install -r requirements-dev.txt
- name: Lint with flake8
run: |
flake8 modelctx --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 modelctx --count --exit-zero --max-complexity=10 --max-line-length=88 --statistics
- name: Check code formatting with black
run: |
black --check modelctx
- name: Check import sorting with isort
run: |
isort --check-only modelctx
- name: Type check with mypy
run: |
mypy modelctx --ignore-missing-imports
- name: Test with pytest
run: |
pytest tests/ -v --cov=modelctx --cov-report=xml
- name: Test code generation (filesystem backend)
run: |
python -m modelctx.cli create test_fs_server --backend filesystem --output-dir test_output --no-install
python -c "import ast; ast.parse(open('test_output/test_fs_server/server.py').read()); print('Filesystem backend: PASSED')"
- name: Test code generation (API backend)
run: |
python -m modelctx.cli create test_api_server --backend api --output-dir test_output --no-install
python -c "import ast; ast.parse(open('test_output/test_api_server/server.py').read()); print('API backend: PASSED')"
- name: Test code generation (database backend)
run: |
python -m modelctx.cli create test_db_server --backend database --output-dir test_output --no-install
python -c "import ast; ast.parse(open('test_output/test_db_server/server.py').read()); print('Database backend: PASSED')"
- name: Upload coverage to Codecov
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
integration-test:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .
pip install mcp aiofiles httpx sqlalchemy beautifulsoup4 requests
- name: Test all backend generation and syntax
run: |
# Test each backend type
for backend in filesystem api database webscraper; do
echo "Testing $backend backend..."
python -m modelctx.cli create "test_${backend}" --backend "$backend" --output-dir integration_test --no-install
# Verify syntax
python -c "
import ast
with open('integration_test/test_${backend}/server.py', 'r') as f:
code = f.read()
try:
ast.parse(code)
print('✅ ${backend} backend syntax: PASSED')
except SyntaxError as e:
print('❌ ${backend} backend syntax: FAILED')
print(f'Error: {e}')
exit(1)
"
# Verify required functions exist
python -c "
with open('integration_test/test_${backend}/server.py', 'r') as f:
code = f.read()
required_functions = ['async def list_tools()', 'async def call_tool(', 'async def list_resources()', 'async def read_resource(']
for func in required_functions:
if func not in code:
print(f'❌ ${backend} missing function: {func}')
exit(1)
print('✅ ${backend} backend functions: PASSED')
"
done
- name: Test CLI wizard (non-interactive)
run: |
# Test that wizard command exists and shows help
python -m modelctx.cli wizard --help || echo "Wizard command test completed"