-
Notifications
You must be signed in to change notification settings - Fork 0
206 lines (172 loc) · 6.27 KB
/
Copy pathci.yml
File metadata and controls
206 lines (172 loc) · 6.27 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
name: Continuous Integration
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
permissions:
contents: read
pull-requests: write
checks: write
jobs:
# Run tests first
test:
uses: ./.github/workflows/test.yml
# Check for breaking changes in API
api-compatibility:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- name: Checkout PR branch
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
path: pr
- name: Checkout main branch
uses: actions/checkout@v4
with:
ref: main
path: main
- name: Check for MCP tool changes
run: |
echo "Checking for changes in MCP tools..."
# Check if any tool functions were removed or renamed
cd main
MAIN_TOOLS=$(find src/authlete_mcp/tools/ -name "*.py" \
-exec grep -l "async def " {} \; | xargs grep "^async def " | sort)
cd ../pr
PR_TOOLS=$(find src/authlete_mcp/tools/ -name "*.py" \
-exec grep -l "async def " {} \; | xargs grep "^async def " | sort)
echo "Main branch tools:"
echo "$MAIN_TOOLS"
echo ""
echo "PR branch tools:"
echo "$PR_TOOLS"
# Simple check for breaking changes
if [ "$(echo "$MAIN_TOOLS" | wc -l)" -gt "$(echo "$PR_TOOLS" | wc -l)" ]; then
echo "⚠️ WARNING: Some MCP tools may have been removed"
echo "removed-tools=true" >> $GITHUB_OUTPUT
else
echo "✅ No MCP tools were removed"
echo "removed-tools=false" >> $GITHUB_OUTPUT
fi
- name: Check OpenAPI spec changes
run: |
echo "Checking for OpenAPI specification changes..."
if ! cmp -s main/resources/openapi-spec.json pr/resources/openapi-spec.json; then
echo "📋 OpenAPI specification was updated"
echo "spec-updated=true" >> $GITHUB_OUTPUT
# Show basic diff info
echo "Changes detected in OpenAPI spec:"
echo "Main branch version: $(jq -r '.info.version // "unknown"' \
main/resources/openapi-spec.json)"
echo "PR branch version: $(jq -r '.info.version // "unknown"' \
pr/resources/openapi-spec.json)"
else
echo "No changes in OpenAPI specification"
echo "spec-updated=false" >> $GITHUB_OUTPUT
fi
# Performance and load testing
performance-test:
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install uv
uses: astral-sh/setup-uv@v3
- name: Install dependencies
run: uv sync
- name: Run performance tests
env:
ORGANIZATION_ACCESS_TOKEN: "dummy_token_for_ci"
ORGANIZATION_ID: "12345"
run: |
echo "Running performance tests..."
# Test MCP server startup time
START_TIME=$(date +%s%N)
timeout 30s uv run python main.py --help > /dev/null 2>&1 || true
END_TIME=$(date +%s%N)
STARTUP_TIME=$((($END_TIME - $START_TIME) / 1000000))
echo "MCP server startup time: ${STARTUP_TIME}ms"
# Test import time for main modules
echo "Testing module import performance..."
uv run python -c "
import time
start = time.time()
import src.authlete_mcp.server
end = time.time()
print(f'Server module import time: {(end-start)*1000:.2f}ms')
start = time.time()
from src.authlete_mcp.tools import service_tools, client_tools, token_tools, jose_tools
end = time.time()
print(f'Tools import time: {(end-start)*1000:.2f}ms')
"
# Generate test coverage report
coverage:
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install uv
uses: astral-sh/setup-uv@v3
- name: Install dependencies
run: |
uv sync
uv add coverage pytest-cov
- name: Run tests with coverage
env:
ORGANIZATION_ACCESS_TOKEN: "dummy_token_for_ci"
ORGANIZATION_ID: "12345"
run: |
echo "Running tests with coverage..."
uv run pytest --cov=src/authlete_mcp --cov-report=xml --cov-report=html -m unit
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
if: always()
with:
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
- name: Upload coverage HTML report
uses: actions/upload-artifact@v4
if: always()
with:
name: coverage-report
path: htmlcov/
retention-days: 30
# Final status check
ci-success:
runs-on: ubuntu-latest
needs: [test, api-compatibility, performance-test, coverage]
if: always()
steps:
- name: Check all jobs status
run: |
echo "## CI Pipeline Results" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Component | Status |" >> $GITHUB_STEP_SUMMARY
echo "|-----------|--------|" >> $GITHUB_STEP_SUMMARY
echo "| Tests | ${{ needs.test.result }} |" >> $GITHUB_STEP_SUMMARY
echo "| API Compatibility | ${{ needs.api-compatibility.result }} |" >> $GITHUB_STEP_SUMMARY
echo "| Performance | ${{ needs.performance-test.result }} |" >> $GITHUB_STEP_SUMMARY
echo "| Coverage | ${{ needs.coverage.result }} |" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ "${{ needs.test.result }}" = "success" ] && [ "${{ needs.performance-test.result }}" = "success" ]; then
echo "✅ CI pipeline completed successfully!" >> $GITHUB_STEP_SUMMARY
exit 0
else
echo "❌ CI pipeline failed. Check individual job logs for details." >> $GITHUB_STEP_SUMMARY
exit 1
fi