1+ name : MTA CI
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+ - release-*
8+ - ' feature/**'
9+ tags :
10+ - ' v*'
11+ pull_request :
12+ branches :
13+ - main
14+ - release-*
15+ paths-ignore :
16+ - ' docs/**'
17+ - ' *.md'
18+ workflow_dispatch :
19+ inputs :
20+ upstream_ref :
21+ description : ' Override upstream ref (branch, tag, or SHA)'
22+ required : false
23+ type : string
24+ workflow_call :
25+
26+ env :
27+ HUSKY : 0
28+
29+ concurrency :
30+ group : mta-ci-${{ github.event_name }}-${{ github.ref }}
31+ cancel-in-progress : true
32+
33+ jobs :
34+ lint :
35+ name : Lint
36+ runs-on : ubuntu-latest
37+ steps :
38+ - name : Checkout MTA build repository
39+ uses : actions/checkout@v4
40+
41+ - name : Setup Node.js
42+ uses : actions/setup-node@v4
43+ with :
44+ node-version-file : ' .nvmrc'
45+ cache : ' npm'
46+
47+ - name : Install MTA build dependencies
48+ run : npm ci
49+
50+ - name : Run lint
51+ run : npm run lint --if-present
52+
53+ build :
54+ name : Build Extension
55+ needs : lint
56+ runs-on : ubuntu-latest
57+
58+ outputs :
59+ upstream_sha : ${{ steps.build_info.outputs.upstream_sha }}
60+ upstream_sha_short : ${{ steps.build_info.outputs.upstream_sha_short }}
61+ mta_version : ${{ steps.build_info.outputs.mta_version }}
62+
63+ steps :
64+ - name : Checkout MTA build repository
65+ uses : actions/checkout@v4
66+
67+ - name : Setup Node.js
68+ uses : actions/setup-node@v4
69+ with :
70+ node-version-file : ' .nvmrc'
71+ cache : ' npm'
72+
73+ - name : Install MTA build dependencies
74+ run : npm ci
75+
76+ - name : Pull upstream and apply MTA branding
77+ run : |
78+ if [[ -n "${{ inputs.upstream_ref }}" ]]; then
79+ echo "Using override upstream ref: ${{ inputs.upstream_ref }}"
80+ npm run pull-upstream -- --ref=${{ inputs.upstream_ref }}
81+ else
82+ echo "Using configured upstream ref from mta-build.yaml"
83+ npm run pull-upstream
84+ fi
85+
86+ - name : Extract build info
87+ id : build_info
88+ run : |
89+ cd .upstream-workspace
90+ UPSTREAM_SHA=$(git rev-parse HEAD)
91+ UPSTREAM_SHA_SHORT=$(git rev-parse --short HEAD)
92+ echo "upstream_sha=${UPSTREAM_SHA}" >> $GITHUB_OUTPUT
93+ echo "upstream_sha_short=${UPSTREAM_SHA_SHORT}" >> $GITHUB_OUTPUT
94+
95+ # Get MTA version from transformed package.json
96+ MTA_VERSION=$(node -p "require('./vscode/package.json').version")
97+ echo "mta_version=${MTA_VERSION}" >> $GITHUB_OUTPUT
98+
99+ - name : Display build configuration
100+ run : |
101+ echo "## MTA Build Configuration" >> $GITHUB_STEP_SUMMARY
102+ echo "- **Upstream SHA**: \`${{ steps.build_info.outputs.upstream_sha }}\`" >> $GITHUB_STEP_SUMMARY
103+ echo "- **MTA Version**: \`${{ steps.build_info.outputs.mta_version }}\`" >> $GITHUB_STEP_SUMMARY
104+
105+ - name : Install upstream dependencies
106+ run : |
107+ cd .upstream-workspace
108+ npm ci
109+
110+ - name : Build extension
111+ run : |
112+ cd .upstream-workspace
113+ npm run build
114+
115+ test :
116+ name : Test
117+ needs : build
118+ runs-on : ubuntu-latest
119+
120+ steps :
121+ - name : Checkout MTA build repository
122+ uses : actions/checkout@v4
123+
124+ - name : Setup Node.js
125+ uses : actions/setup-node@v4
126+ with :
127+ node-version-file : ' .nvmrc'
128+ cache : ' npm'
129+
130+ - name : Install MTA build dependencies
131+ run : npm ci
132+
133+ - name : Pull upstream and apply MTA branding
134+ run : |
135+ if [[ -n "${{ inputs.upstream_ref }}" ]]; then
136+ echo "Using override upstream ref: ${{ inputs.upstream_ref }}"
137+ npm run pull-upstream -- --ref=${{ inputs.upstream_ref }}
138+ else
139+ echo "Using configured upstream ref from mta-build.yaml"
140+ npm run pull-upstream
141+ fi
142+
143+ - name : Install upstream dependencies
144+ run : |
145+ cd .upstream-workspace
146+ npm ci
147+
148+ - name : Run tests
149+ run : |
150+ cd .upstream-workspace
151+ xvfb-run -a npm test
152+
153+ package :
154+ name : Package Extension
155+ needs : test
156+ runs-on : ubuntu-latest
157+ steps :
158+ - name : Checkout MTA build repository
159+ uses : actions/checkout@v4
160+
161+ - name : Setup Node.js
162+ uses : actions/setup-node@v4
163+ with :
164+ node-version-file : ' .nvmrc'
165+ cache : ' npm'
166+
167+ - name : Install MTA build dependencies
168+ run : npm ci
169+
170+ - name : Pull upstream and apply MTA branding
171+ run : |
172+ if [[ -n "${{ inputs.upstream_ref }}" ]]; then
173+ echo "Using override upstream ref: ${{ inputs.upstream_ref }}"
174+ npm run pull-upstream -- --ref=${{ inputs.upstream_ref }}
175+ else
176+ echo "Using configured upstream ref from mta-build.yaml"
177+ npm run pull-upstream
178+ fi
179+
180+ - name : Extract build info
181+ id : build_info
182+ run : |
183+ cd .upstream-workspace
184+ UPSTREAM_SHA=$(git rev-parse HEAD)
185+ UPSTREAM_SHA_SHORT=$(git rev-parse --short HEAD)
186+ echo "upstream_sha=${UPSTREAM_SHA}" >> $GITHUB_OUTPUT
187+ echo "upstream_sha_short=${UPSTREAM_SHA_SHORT}" >> $GITHUB_OUTPUT
188+
189+ # Get MTA version from transformed package.json
190+ MTA_VERSION=$(node -p "require('./vscode/package.json').version")
191+ echo "mta_version=${MTA_VERSION}" >> $GITHUB_OUTPUT
192+
193+ - name : Version management for development builds
194+ if : ${{ !startsWith(github.ref, 'refs/tags/') }}
195+ run : |
196+ cd .upstream-workspace
197+ # Update version for development build
198+ CURRENT_VERSION=$(node -p "require('./vscode/package.json').version")
199+ DEV_VERSION="${CURRENT_VERSION}-dev.${{ github.run_number }}"
200+ npm version $DEV_VERSION --no-git-tag-version --workspace=vscode
201+ echo "Set development version: $DEV_VERSION"
202+
203+ - name : Install upstream dependencies
204+ run : |
205+ cd .upstream-workspace
206+ npm ci
207+
208+ - name : Build extension
209+ run : |
210+ cd .upstream-workspace
211+ npm run build
212+
213+ - name : Create distribution and package
214+ run : |
215+ cd .upstream-workspace
216+ npm run dist
217+ npm run package
218+
219+ - name : Upload VSIX artifact
220+ uses : actions/upload-artifact@v4
221+ with :
222+ name : mta-vsix-artifact-${{ github.run_number }}
223+ path : .upstream-workspace/dist/*.vsix
224+ retention-days : 30
225+
226+ e2e-test :
227+ name : E2E Tests
228+ needs : package
229+ runs-on : ubuntu-latest
230+ steps :
231+ - name : Checkout MTA build repository
232+ uses : actions/checkout@v4
233+
234+ - name : Setup Node.js
235+ uses : actions/setup-node@v4
236+ with :
237+ node-version-file : ' .nvmrc'
238+ cache : ' npm'
239+
240+ - name : Install dependencies
241+ run : npm ci
242+
243+ - name : Install VS Code
244+ run : |
245+ wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
246+ sudo install -o root -g root -m 644 packages.microsoft.gpg /etc/apt/trusted.gpg.d/
247+ sudo sh -c 'echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/trusted.gpg.d/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" > /etc/apt/sources.list.d/vscode.list'
248+ sudo apt update
249+ sudo apt install code
250+
251+ - name : Setup virtual display
252+ run : |
253+ sudo apt-get update
254+ sudo apt-get install -y xvfb
255+
256+ - name : Download VSIX artifact
257+ uses : actions/download-artifact@v4
258+ with :
259+ name : mta-vsix-artifact-${{ github.run_number }}
260+ path : ./artifacts
261+
262+ - name : Run E2E tests
263+ run : |
264+ # Install the extension
265+ VSIX_FILE=$(find ./artifacts -name "*.vsix" | head -1)
266+ if [[ -n "$VSIX_FILE" ]]; then
267+ code --install-extension "$VSIX_FILE"
268+ fi
269+
270+ # Run E2E tests if they exist
271+ if [[ -f "package.json" ]] && npm run | grep -q "test:e2e"; then
272+ xvfb-run -a npm run test:e2e
273+ else
274+ echo "No E2E tests found, skipping..."
275+ fi
276+
277+ publish-development :
278+ name : Publish Development Build
279+ needs : [package, e2e-test]
280+ runs-on : ubuntu-latest
281+ if : >
282+ ${{
283+ !failure() &&
284+ !(github.event_name == 'pull_request' && !github.event.pull_request.merged) &&
285+ !startsWith(github.ref, 'refs/tags/')
286+ }}
287+
288+ steps :
289+ - name : Download VSIX artifact
290+ uses : actions/download-artifact@v4
291+ with :
292+ name : mta-vsix-artifact-${{ github.run_number }}
293+ path : ./artifacts
294+
295+ - name : Publish to development builds release
296+ run : |
297+ # Find VSIX file
298+ VSIX_FILE=$(find ./artifacts -name "*.vsix" | head -1)
299+ if [[ -z "$VSIX_FILE" ]]; then
300+ echo "Error: No VSIX file found"
301+ exit 1
302+ fi
303+
304+ # Upload to development-builds release
305+ gh release upload development-builds "$VSIX_FILE" --clobber
306+ echo "Published development build: $(basename "$VSIX_FILE")"
307+ env :
308+ GITHUB_TOKEN : ${{ github.token }}
309+
310+ release :
311+ name : Create Release
312+ needs : [package, e2e-test]
313+ runs-on : ubuntu-latest
314+ if : ${{ startsWith(github.ref, 'refs/tags/') }}
315+
316+ steps :
317+ - name : Download VSIX artifact
318+ uses : actions/download-artifact@v4
319+ with :
320+ name : mta-vsix-artifact-${{ github.run_number }}
321+ path : ./artifacts
322+
323+ - name : Create GitHub release
324+ run : |
325+ VSIX_FILE=$(find ./artifacts -name "*.vsix" | head -1)
326+ RELEASE_NAME="${{ github.ref_name }}"
327+
328+ gh release create "${{ github.ref_name }}" \
329+ --title "MTA Extension $RELEASE_NAME" \
330+ --notes "Migration Toolkit for Applications extension release $RELEASE_NAME
331+
332+ ## Installation
333+ Download the .vsix file and install using 'Extensions: Install from VSIX...' in VS Code.
334+
335+ ## Changes
336+ See the full changelog in the repository." \
337+ "$VSIX_FILE"
338+ env :
339+ GITHUB_TOKEN : ${{ github.token }}
340+
341+ # TODO: Add marketplace publishing when ready
342+ # - name: Publish to VS Code Marketplace
343+ # run: npx vsce publish --packagePath "$VSIX_FILE"
344+ # env:
345+ # VSCE_PAT: ${{ secrets.VSCE_PAT }}
346+
347+ # - name: Publish to Open VSX
348+ # run: npx ovsx publish "$VSIX_FILE"
349+ # env:
350+ # OVSX_PAT: ${{ secrets.OVSX_PAT }}
0 commit comments