-
Notifications
You must be signed in to change notification settings - Fork 0
213 lines (177 loc) · 6.89 KB
/
rebuild-all-versions.yml
File metadata and controls
213 lines (177 loc) · 6.89 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
name: Rebuild All Windmill Versions
on:
workflow_dispatch:
inputs:
versions:
description: 'Comma-separated list of Windmill versions (e.g., "1.520.1,1.521.0") or "all" for all existing releases'
required: true
default: "all"
type: string
permissions:
contents: write
jobs:
get-versions:
runs-on: ubuntu-latest
outputs:
versions: ${{ steps.set-versions.outputs.versions }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Get versions to rebuild
id: set-versions
run: |
INPUT_VERSIONS="${{ github.event.inputs.versions }}"
if [ "$INPUT_VERSIONS" = "all" ]; then
echo "📋 Fetching all existing release versions..."
# Fetch all release tags
VERSIONS=$(gh api repos/${{ github.repository }}/releases --paginate | \
jq -r '.[].tag_name' | \
grep '^windmill-v' | \
sed 's/windmill-v\(.*\)-mcp-.*/\1/' | \
sort -u | \
jq -R -s -c 'split("\n") | map(select(length > 0))')
echo "Found versions: $VERSIONS"
else
echo "📋 Using provided versions: $INPUT_VERSIONS"
VERSIONS=$(echo "$INPUT_VERSIONS" | jq -R -c 'split(",")')
fi
echo "versions=$VERSIONS" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ github.token }}
rebuild:
needs: get-versions
runs-on: ubuntu-latest
strategy:
matrix:
version: ${{ fromJSON(needs.get-versions.outputs.versions) }}
fail-fast: false # Continue even if one version fails
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: Start Windmill instance
run: |
echo "🚀 Starting Windmill instance..."
npm run docker:up
- name: Wait for Windmill to be ready
run: |
echo "⏳ Waiting for Windmill to be ready..."
npm run docker:wait
timeout-minutes: 5
- name: Fetch OpenAPI spec
id: fetch-spec
run: |
echo "📥 Fetching OpenAPI spec for Windmill ${{ matrix.version }}..."
# Ensure cache directory exists
mkdir -p cache
# Fetch from local Windmill instance
# Note: In reality, we'd need a way to fetch specific version specs
# For now, we use the running instance
curl -f http://localhost:8000/api/openapi.json -o cache/openapi-spec.json
SPEC_VERSION=$(node -p "JSON.parse(require('fs').readFileSync('cache/openapi-spec.json', 'utf8')).info.version")
echo "spec_version=$SPEC_VERSION" >> $GITHUB_OUTPUT
echo "✅ Fetched OpenAPI spec version: $SPEC_VERSION"
- name: Generate and build MCP server
run: |
echo "🔧 Generating and building MCP server from OpenAPI spec..."
npm run generate
# Verify generation succeeded
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"
- name: Run unit tests
id: unit-test
run: |
echo "🧪 Running unit tests..."
npm run test:unit
continue-on-error: true
- name: Run E2E tests
id: e2e-test
env:
E2E_WINDMILL_URL: http://localhost:8000
E2E_WINDMILL_TOKEN: test-super-secret
E2E_WORKSPACE: admins
WINDMILL_BASE_URL: http://localhost:8000
run: |
echo "🧪 Running E2E tests..."
npm run test:e2e
continue-on-error: true
- name: Stop Windmill
if: always()
run: |
echo "🛑 Stopping Windmill instance..."
npm run docker:down
- name: Check test results
run: |
# STRICT: Both unit AND E2E tests must pass
if [ "${{ steps.unit-test.outcome }}" != "success" ] || [ "${{ steps.e2e-test.outcome }}" != "success" ]; then
echo "❌ Tests failed for version ${{ matrix.version }} - no release will be created"
if [ "${{ steps.unit-test.outcome }}" != "success" ]; then
echo " - Unit tests: FAILED"
fi
if [ "${{ steps.e2e-test.outcome }}" != "success" ]; then
echo " - E2E tests: FAILED"
fi
exit 1
fi
echo "✅ All tests passed - ready for release"
- name: Get package version
id: package-version
run: |
PKG_VERSION=$(node -p "require('./package.json').version")
echo "version=$PKG_VERSION" >> $GITHUB_OUTPUT
echo "📦 Package version: $PKG_VERSION"
- name: Create tarball of generated code
run: |
echo "📦 Creating tarball of generated code..."
cd build
tar --exclude='./runtime' -czf ../generated-mcp-server.tar.gz .
cd ..
echo "✅ Tarball created"
- name: Create release
uses: softprops/action-gh-release@v1
with:
tag_name: windmill-v${{ steps.fetch-spec.outputs.spec_version }}-mcp-${{ steps.package-version.outputs.version }}
name: Windmill ${{ steps.fetch-spec.outputs.spec_version }} MCP Server (rebuilt)
body: |
## Windmill MCP Server (Rebuilt)
**Windmill API Version**: ${{ steps.fetch-spec.outputs.spec_version }}
**MCP Package Version**: ${{ steps.package-version.outputs.version }}
**Rebuilt**: ${{ github.event.repository.updated_at }}
This version was rebuilt with the latest MCP package version.
### Installation
```bash
WINDMILL_VERSION=${{ steps.fetch-spec.outputs.spec_version }} npx windmill-mcp
```
---
Generated by workflow: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
files: |
generated-mcp-server.tar.gz
cache/openapi-spec.json
draft: false
prerelease: false
summary:
needs: rebuild
runs-on: ubuntu-latest
if: always()
steps:
- name: Summary
run: |
echo "## Rebuild Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Rebuild workflow completed for all requested versions." >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Check individual job results above for details." >> $GITHUB_STEP_SUMMARY