Repository navigation
fix(release): bundle remote workspace support #120
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
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,19 @@ | ||
| #!/usr/bin/env bash | ||
| # Build the package's app, and Voltage's provider beside it when requested. | ||
| set -euo pipefail | ||
| here="$(cd "$(dirname "$0")/.." && pwd)" | ||
| repo="$(cd "$here/../.." && pwd)" | ||
| cd "$here" | ||
| target="${CARGO_TARGET_DIR:-$here/target}" | ||
| features=() | ||
| if [ "${BUZZ_GPUI_VOLTAGE:-0}" = 1 ]; then | ||
| features=(--features voltage-sandbox) | ||
| cargo build --manifest-path "$repo/Cargo.toml" --locked --release \ | ||
| -p buzz-backend-relay --target-dir "$target/voltage-provider" | ||
| fi | ||
| cargo build --locked --release -p buzz-gpui "${features[@]}" "$@" | ||
| if [ "${BUZZ_GPUI_VOLTAGE:-0}" = 1 ]; then | ||
| suffix="" | ||
| if [ "${OS:-}" = Windows_NT ]; then suffix=.exe; fi | ||
| cp "$target/voltage-provider/release/buzz-backend-relay$suffix" "$target/release/" | ||
| fi |
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,23 @@ | ||
| // Exercise the packaged provider without credentials or a relay connection. | ||
| import { spawnSync } from "node:child_process"; | ||
|
|
||
| const binary = process.argv[2]; | ||
| if (!binary) throw new Error("Expected the packaged buzz-backend-relay path"); | ||
| const result = spawnSync(binary, { | ||
| input: '{"op":"info"}\n', | ||
| encoding: "utf8", | ||
| timeout: 10_000, | ||
| maxBuffer: 64 * 1024, | ||
| }); | ||
| if (result.error || result.status !== 0) { | ||
| throw new Error("The packaged relay provider could not start"); | ||
| } | ||
| const info = JSON.parse(result.stdout); | ||
| const nonemptyText = (field) => typeof info?.[field] === "string" && info[field].length > 0; | ||
| if (info?.ok !== true || info.name !== "relay" || info.protocol_version !== 1 || | ||
| !nonemptyText("version") || !nonemptyText("description") || | ||
| !info.config_schema || typeof info.config_schema !== "object" || Array.isArray(info.config_schema) || | ||
| !Array.isArray(info.ops) || !["deploy", "stop", "recover"].every((op) => info.ops.includes(op))) { | ||
| throw new Error("The packaged relay provider has an incompatible protocol"); | ||
| } | ||
| console.log("Packaged relay provider supports deploy, stop, and recovery"); | ||
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,50 @@ | ||
| import assert from "node:assert/strict"; | ||
| import { spawnSync } from "node:child_process"; | ||
| import { mkdtempSync, rmSync, writeFileSync } from "node:fs"; | ||
| import { tmpdir } from "node:os"; | ||
| import { join } from "node:path"; | ||
| import test from "node:test"; | ||
| import { fileURLToPath } from "node:url"; | ||
|
|
||
| const check = fileURLToPath(new URL("check-remote-provider.mjs", import.meta.url)); | ||
| const valid = { | ||
| ok: true, name: "relay", version: "0.1.0", description: "Relay provider", | ||
| protocol_version: 1, config_schema: {}, ops: ["info", "deploy", "stop", "recover"], | ||
| }; | ||
|
|
||
| function run(info) { | ||
| const directory = mkdtempSync(join(tmpdir(), "provider-package-check-")); | ||
| try { | ||
| const binary = join(directory, "provider"); | ||
| writeFileSync(binary, `#!${process.execPath}\nprocess.stdout.write(${JSON.stringify(JSON.stringify(info))});\n`, { mode: 0o755 }); | ||
| return spawnSync(process.execPath, [check, binary], { | ||
| encoding: "utf8", timeout: 5_000, maxBuffer: 64 * 1024, | ||
| }); | ||
| } finally { | ||
| rmSync(directory, { recursive: true, force: true }); | ||
| } | ||
| } | ||
|
|
||
| test("accepts the complete desktop provider response", () => { | ||
| const result = run(valid); | ||
| assert.equal(result.status, 0, result.stderr); | ||
| }); | ||
|
|
||
| test("rejects missing, empty, and wrongly typed desktop metadata", () => { | ||
| for (const field of ["version", "description", "config_schema"]) { | ||
| const values = field === "config_schema" | ||
| ? [undefined, null, [], "schema", 1, false] | ||
| : [undefined, null, "", 1, false, {}, []]; | ||
| for (const value of values) { | ||
| const result = run({ ...valid, [field]: value }); | ||
| assert.equal(result.error, undefined); | ||
| assert.notEqual(result.status, 0, `${field}=${JSON.stringify(value)} must fail`); | ||
| } | ||
| } | ||
| }); | ||
|
|
||
| test("still requires the supported protocol and lifecycle operations", () => { | ||
| for (const patch of [{ protocol_version: 2 }, { ops: ["info", "deploy"] }, { ops: "deploy stop recover" }]) { | ||
| assert.notEqual(run({ ...valid, ...patch }).status, 0); | ||
| } | ||
| }); |
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,77 @@ | ||
| """Exercise the real package builder with a deterministic Cargo subprocess.""" | ||
| import json | ||
| import os | ||
| from pathlib import Path | ||
| import shutil | ||
| import subprocess | ||
| import tempfile | ||
| import unittest | ||
|
|
||
|
|
||
| class PackageBuild(unittest.TestCase): | ||
| def run_build(self, voltage, windows=False, fail=False): | ||
| temporary = tempfile.TemporaryDirectory() | ||
| self.addCleanup(temporary.cleanup) | ||
| root = Path(temporary.name) | ||
| app = root / "apps" / "buzz-gpui" | ||
| scripts = app / "scripts" | ||
| scripts.mkdir(parents=True) | ||
| shutil.copy2(Path(__file__).with_name("build-package.sh"), scripts) | ||
| binaries = root / "bin" | ||
| binaries.mkdir() | ||
| cargo = binaries / "cargo" | ||
| cargo.write_text('''#!/usr/bin/env python3 | ||
| import json, os, pathlib, sys | ||
| args = sys.argv[1:] | ||
| with open(os.environ["CALLS"], "a") as log: | ||
| log.write(json.dumps(args) + "\\n") | ||
| provider = "buzz-backend-relay" in args | ||
| if provider and os.environ.get("FAIL_PROVIDER") == "1": | ||
| sys.exit(9) | ||
| target = pathlib.Path(args[args.index("--target-dir")+1] if provider else os.environ["CARGO_TARGET_DIR"]) | ||
| release = target / "release" | ||
| release.mkdir(parents=True, exist_ok=True) | ||
| name = "buzz-backend-relay" if provider else "buzz-gpui" | ||
| if os.environ.get("OS") == "Windows_NT": | ||
| name += ".exe" | ||
| (release / name).write_text("fresh " + name) | ||
| ''') | ||
| cargo.chmod(0o755) | ||
| env = dict(os.environ, PATH=str(binaries)+os.pathsep+os.environ["PATH"], | ||
| CALLS=str(root/"calls.jsonl"), CARGO_TARGET_DIR=str(root/"build"), | ||
| BUZZ_GPUI_VOLTAGE="1" if voltage else "0", | ||
| OS="Windows_NT" if windows else "Linux", FAIL_PROVIDER="1" if fail else "0") | ||
| result = subprocess.run(["bash", str(scripts/"build-package.sh")], | ||
| env=env, capture_output=True, text=True, timeout=10) | ||
| calls = [json.loads(line) for line in (root/"calls.jsonl").read_text().splitlines()] | ||
| return root, result, calls | ||
|
|
||
| def test_voltage_build_enables_remote_ui_and_stages_the_same_builds_provider(self): | ||
| for windows in [False, True]: | ||
| with self.subTest(windows=windows): | ||
| root, result, calls = self.run_build(True, windows) | ||
| self.assertEqual(result.returncode, 0, result.stderr) | ||
| self.assertEqual(len(calls), 2) | ||
| self.assertIn(str(root/"Cargo.toml"), calls[0]) | ||
| self.assertIn("buzz-backend-relay", calls[0]) | ||
| self.assertIn("--features", calls[1]) | ||
| self.assertIn("voltage-sandbox", calls[1]) | ||
| name = "buzz-backend-relay" + (".exe" if windows else "") | ||
| self.assertEqual((root/"build"/"release"/name).read_text(), "fresh "+name) | ||
|
|
||
| def test_generic_packages_keep_their_existing_feature_set(self): | ||
| root, result, calls = self.run_build(False) | ||
| self.assertEqual(result.returncode, 0, result.stderr) | ||
| self.assertEqual(len(calls), 1) | ||
| self.assertNotIn("--features", calls[0]) | ||
| self.assertFalse((root/"build"/"release"/"buzz-backend-relay").exists()) | ||
|
|
||
| def test_provider_failure_stops_packaging_before_building_the_app(self): | ||
| root, result, calls = self.run_build(True, fail=True) | ||
| self.assertNotEqual(result.returncode, 0) | ||
| self.assertEqual(len(calls), 1) | ||
| self.assertFalse((root/"build"/"release"/"buzz-gpui").exists()) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| unittest.main() |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Match the desktop’s complete
infovalidation.If a packaged provider adds an unknown top-level field or advertises more than 32 operations, this check passes but the desktop rejects the provider. The desktop also rejects non-string operation entries. Apply those constraints here so the release check cannot certify that response. (github.com)