Repository navigation
ci: run on Node 24 and smoke-test the bundle on Node 20 #78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
4b8d060
ci: run on Node 24 and smoke-test the bundle on Node 20
satsukies 8ebeef1
ci: run the bundle outside the checkout and require JSON-RPC output i…
satsukies bcaae26
ci: smoke-test a copy of plugin/ on the exact engines minimum, Node 2…
satsukies 9d510d5
Merge branch 'main' into ci/node24-bundle-compat
satsukies File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,140 @@ | ||
| // Smoke test for the bundled MCP server. Spawns the bundle with the current | ||
| // Node, performs the MCP handshake over stdio and checks that tools/list | ||
| // returns tools. Dependency-free so it can run on the minimum supported Node | ||
| // without installing dev dependencies. | ||
| // | ||
| // Usage: node scripts/smoke-bundle.mjs [path/to/bundle.js] | ||
|
|
||
| import { spawn } from "node:child_process"; | ||
| import { mkdtempSync, rmSync } from "node:fs"; | ||
| import { tmpdir } from "node:os"; | ||
| import { join, resolve } from "node:path"; | ||
|
|
||
| const TIMEOUT_MS = 15_000; | ||
|
|
||
| const bundle = resolve(process.argv[2] ?? "plugin/scripts/bundle.js"); | ||
|
|
||
| // Point every config location at an empty directory so a token stored on the | ||
| // machine is never picked up. | ||
| const home = mkdtempSync(join(tmpdir(), "deploygate-smoke-")); | ||
|
|
||
| const child = spawn(process.execPath, [bundle], { | ||
| env: { | ||
| ...process.env, | ||
| HOME: home, | ||
| USERPROFILE: home, | ||
| XDG_CONFIG_HOME: home, | ||
| APPDATA: home, | ||
| }, | ||
| stdio: ["pipe", "pipe", "pipe"], | ||
| }); | ||
|
|
||
| let stderr = ""; | ||
| child.stderr.on("data", (chunk) => (stderr += chunk)); | ||
|
|
||
| const pending = new Map(); | ||
| let buffer = ""; | ||
| child.stdout.on("data", (chunk) => { | ||
| buffer += chunk; | ||
| let newline; | ||
| while ((newline = buffer.indexOf("\n")) >= 0) { | ||
| const line = buffer.slice(0, newline).trim(); | ||
| buffer = buffer.slice(newline + 1); | ||
| if (!line) continue; | ||
| let message; | ||
| try { | ||
| message = JSON.parse(line); | ||
| } catch { | ||
| message = undefined; | ||
| } | ||
| if ( | ||
| typeof message !== "object" || | ||
| message === null || | ||
| Array.isArray(message) || | ||
| message.jsonrpc !== "2.0" | ||
| ) { | ||
| fail(new Error(`bundle wrote a non JSON-RPC line to stdout: ${line}`)); | ||
| return; | ||
| } | ||
|
Copilot marked this conversation as resolved.
|
||
| pending.get(message.id)?.(message); | ||
| pending.delete(message.id); | ||
|
satsukies marked this conversation as resolved.
|
||
| } | ||
| }); | ||
|
|
||
| const exited = new Promise((_, reject) => { | ||
| child.on("exit", (code, signal) => | ||
| reject(new Error(`bundle exited early (code=${code}, signal=${signal})`)), | ||
| ); | ||
| }); | ||
|
|
||
| function send(message) { | ||
| child.stdin.write(JSON.stringify(message) + "\n"); | ||
| } | ||
|
|
||
| function request(id, method, params = {}) { | ||
| const response = new Promise((resolve) => pending.set(id, resolve)); | ||
| send({ jsonrpc: "2.0", id, method, params }); | ||
| return Promise.race([response, exited]).then((message) => { | ||
| if (message.error) | ||
| throw new Error(`${method} failed: ${JSON.stringify(message.error)}`); | ||
| return message.result; | ||
| }); | ||
| } | ||
|
|
||
| function assert(condition, message) { | ||
| if (!condition) throw new Error(message); | ||
| } | ||
|
|
||
| const timer = setTimeout( | ||
| () => fail(new Error(`timed out after ${TIMEOUT_MS}ms`)), | ||
| TIMEOUT_MS, | ||
| ); | ||
|
|
||
| function finish(code) { | ||
| clearTimeout(timer); | ||
| child.removeAllListeners("exit"); | ||
| child.kill(); | ||
| rmSync(home, { recursive: true, force: true }); | ||
| process.exit(code); | ||
| } | ||
|
|
||
| function fail(error) { | ||
| console.error( | ||
| `smoke test failed on Node ${process.version}: ${error.message}`, | ||
| ); | ||
| if (stderr) console.error(`bundle stderr:\n${stderr}`); | ||
| finish(1); | ||
| } | ||
|
|
||
| try { | ||
| const init = await request(1, "initialize", { | ||
| protocolVersion: "2025-06-18", | ||
| capabilities: {}, | ||
| clientInfo: { name: "smoke-bundle", version: "0.0.0" }, | ||
| }); | ||
| assert( | ||
| init.serverInfo?.name === "deploygate", | ||
| `unexpected serverInfo: ${JSON.stringify(init.serverInfo)}`, | ||
| ); | ||
|
|
||
| send({ jsonrpc: "2.0", method: "notifications/initialized" }); | ||
|
|
||
| const { tools } = await request(2, "tools/list"); | ||
| assert( | ||
| Array.isArray(tools) && tools.length > 0, | ||
| "tools/list returned no tools", | ||
| ); | ||
| for (const tool of tools) { | ||
| assert( | ||
| typeof tool.name === "string" && tool.inputSchema, | ||
| `malformed tool: ${JSON.stringify(tool)}`, | ||
| ); | ||
| } | ||
|
|
||
| console.log( | ||
| `smoke test passed on Node ${process.version}: ${init.serverInfo.name} ${init.serverInfo.version}, ${tools.length} tools`, | ||
| ); | ||
| finish(0); | ||
| } catch (error) { | ||
| fail(error); | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.