-
Notifications
You must be signed in to change notification settings - Fork 0
124 lines (100 loc) · 3.51 KB
/
ci.yml
File metadata and controls
124 lines (100 loc) · 3.51 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
name: CI Tests
on:
pull_request:
branches: [main]
push:
branches: [main]
workflow_dispatch: # Allow manual trigger
permissions:
contents: read
pull-requests: read
jobs:
unit-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "18"
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Check directory structure
run: npm run lint:structure
- name: Run unit tests
run: npm run test:unit
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: unit-test-results
path: |
coverage/
retention-days: 7
generator-validation:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "18"
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Validate generator scripts
run: |
echo "Validating generator scripts..."
node --check src/generator/fetch-spec.js
node --check src/generator/generate.js
echo "✅ Generator scripts are valid"
- name: Test OpenAPI spec fetch
run: |
npm run fetch-spec
if [ ! -f "cache/openapi-spec.json" ]; then
echo "❌ Failed to fetch OpenAPI spec"
exit 1
fi
echo "✅ OpenAPI spec fetched successfully"
- name: Test MCP server generation and build
run: |
echo "Testing MCP server generation and build..."
npm run generate
# Verify generation succeeded
if [ ! -d "build" ]; then
echo "❌ Generation failed - build/ directory not created"
exit 1
fi
if [ ! -f "build/src/index.ts" ]; then
echo "❌ Generation failed - index.ts not found"
exit 1
fi
# Verify build succeeded (postgenerate hook builds automatically)
if [ ! -f "build/dist/index.js" ]; then
echo "❌ Build failed - build/dist/index.js not found"
exit 1
fi
echo "✅ MCP server generated and built successfully"
test-summary:
runs-on: ubuntu-latest
needs: [unit-tests, generator-validation]
if: always()
steps:
- name: Check test results
run: |
echo "## Test Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **Unit Tests**: ${{ needs.unit-tests.result == 'success' && '✅ Passed' || '❌ Failed' }}" >> $GITHUB_STEP_SUMMARY
echo "- **Generator Validation**: ${{ needs.generator-validation.result == 'success' && '✅ Passed' || '❌ Failed' }}" >> $GITHUB_STEP_SUMMARY
if [ "${{ needs.unit-tests.result }}" != "success" ] || [ "${{ needs.generator-validation.result }}" != "success" ]; then
echo "" >> $GITHUB_STEP_SUMMARY
echo "❌ **Required checks failed - PR cannot be merged**" >> $GITHUB_STEP_SUMMARY
exit 1
fi
echo "" >> $GITHUB_STEP_SUMMARY
echo "✅ **All required checks passed**" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Note: Generated MCP server will be tested in version branches" >> $GITHUB_STEP_SUMMARY