From 6b4658cf4892f6aa0d44bf5e2daa45138f0c46f4 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 1 Dec 2026 22:52:01 +0000 Subject: [PATCH 1/3] ci: test on macOS 27 via the xcode-27 runner GitHub has no macos-27 label. The macOS 27 arm64 image is xcode-27, so the test matrix runs Node 22, 24, and 26 there while the darwin prebuild stays on macos-26. Co-authored-by: Jon Ursenbach --- .github/workflows/publish.yml | 4 ++++ .github/workflows/tests.yml | 3 ++- CLAUDE.md | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 99c8ebc91..d88aaa4d9 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -16,6 +16,10 @@ jobs: node: [22, 24, 26] os: # https://github.com/actions/runner-images#available-images + # darwin arm64 prebuild stays on macos-26. Building on xcode-27 + # (macOS 27) would use the macOS 27 SDK and can raise the minimum + # OS the published binary requires. A macos-26 binary still runs + # on macOS 27. tests.yml covers xcode-27. - name: darwin host: macos-26 #arm64 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3ed6f4f0e..40421c34c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -69,7 +69,8 @@ jobs: strategy: matrix: node-version: [22, 24, 26] - runner: ["macos-26", "macos-15-intel"] + # xcode-27 is the macOS 27 arm64 image. There is no macos-27 label. + runner: ["macos-26", "xcode-27", "macos-15-intel"] runs-on: ${{ matrix.runner }} steps: - uses: actions/checkout@v5 diff --git a/CLAUDE.md b/CLAUDE.md index 907ada858..0e6a11f54 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -101,7 +101,7 @@ Tests are located in: ## CI/CD GitHub Actions workflows: -- **tests.yml**: Runs tests on Ubuntu 22.04 and macOS-26 across Node 22, 24, and 26 +- **tests.yml**: Runs tests on Ubuntu 22.04, macOS 26, macOS 27 (`xcode-27`), and the macOS 15 Intel runner across Node 22, 24, and 26 - **publish.yml**: Handles package publishing ## Architecture From 6fa99a99eba9b3300edac283805b1833624a928f Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 1 Dec 2026 23:11:23 +0000 Subject: [PATCH 2/3] fix: keep the macOS 27 Node 24 worker test within its timeout The context-shutdown worker collected garbage until the heap stopped shrinking, which ran past the 30s limit on Node 24 built with Xcode 27. The history walk then posted failure and failed the following tests. Cap those collections, ignore the walk's end after the count is reported, and build Xcode 27 with a macOS 11 deployment target so libc++ is supported. Prebuilds on older SDKs stay at 10.11. Co-authored-by: Jon Ursenbach --- generate/templates/templates/binding.gyp | 4 +- package.json | 2 +- test/tests/worker.js | 38 +++++++++++++++---- test/utils/garbage_collect.js | 12 ++++-- test/utils/worker_context_aware.js | 21 ++++++++--- test/utils/worker_context_aware_checkout.js | 5 ++- utils/macOSDeploymentTarget.js | 41 +++++++++++++++++++++ utils/macOSDeploymentTarget.test.js | 19 ++++++++++ 8 files changed, 122 insertions(+), 20 deletions(-) create mode 100644 utils/macOSDeploymentTarget.js create mode 100644 utils/macOSDeploymentTarget.test.js diff --git a/generate/templates/templates/binding.gyp b/generate/templates/templates/binding.gyp index 88799b0fd..b75bac96c 100644 --- a/generate/templates/templates/binding.gyp +++ b/generate/templates/templates/binding.gyp @@ -9,7 +9,9 @@ "electron_openssl_static%": " { + if (settled) { + return; + } switch (message) { case "numbersMatch": testOk = true; @@ -129,17 +140,17 @@ if (Worker) { worker.terminate(); break; case "failure": - assert.fail(); + finish(new Error("worker reported failure")); break; } }); - worker.on("error", () => assert.fail()); + worker.on("error", () => finish(new Error("worker error"))); worker.on("exit", (code) => { if (code === 1 && testOk === true) { - done(); + finish(); } else { - assert.fail(); + finish(new Error("worker exited with code " + code)); } }); }); @@ -188,6 +199,14 @@ if (Worker) { return; } let testOk; + let settled = false; + function finish(err) { + if (settled) { + return; + } + settled = true; + done(err); + } const workerPath = local("../utils/worker_context_aware_checkout.js"); const worker = new Worker(workerPath, { workerData: { @@ -196,6 +215,9 @@ if (Worker) { } }); worker.on("message", (message) => { + if (settled) { + return; + } switch (message) { case "numbersMatch": testOk = true; @@ -206,17 +228,17 @@ if (Worker) { worker.terminate(); break; case "failure": - assert.fail(); + finish(new Error("worker reported failure")); break; } }); - worker.on("error", () => assert.fail()); + worker.on("error", () => finish(new Error("worker error"))); worker.on("exit", (code) => { if (code === 1 && testOk === true) { - done(); + finish(); } else { - assert.fail(); + finish(new Error("worker exited with code " + code)); } }); }); diff --git a/test/utils/garbage_collect.js b/test/utils/garbage_collect.js index a288b99c8..8b005b34d 100644 --- a/test/utils/garbage_collect.js +++ b/test/utils/garbage_collect.js @@ -1,11 +1,17 @@ -// aggressively collects garbage until we fail to improve terminatingIterations -// times. -function garbageCollect() { +// Aggressively collects garbage until we fail to improve terminatingIterations +// times. maxIterations caps a worker-thread caller: one global.gc() that keeps +// freeing a little memory would otherwise loop until the suite timeout. +function garbageCollect(maxIterations) { var terminatingIterations = 3; var usedBeforeGC = Number.MAX_VALUE; var nondecreasingIterations = 0; + var iterations = 0; for ( ; ; ) { global.gc(); + iterations++; + if (maxIterations && iterations >= maxIterations) { + break; + } var usedAfterGC = process.memoryUsage().heapUsed; if (usedAfterGC >= usedBeforeGC) { nondecreasingIterations++; diff --git a/test/utils/worker_context_aware.js b/test/utils/worker_context_aware.js index b7784fdae..36e0ac951 100644 --- a/test/utils/worker_context_aware.js +++ b/test/utils/worker_context_aware.js @@ -22,6 +22,7 @@ const opts = { }; let repository; +let reported = false; const oid = "fce88902e66c72b5b93e75bdb5ae717038b221f6"; return NodeGit.Clone(url, clonePath, opts) @@ -35,10 +36,16 @@ return NodeGit.Clone(url, clonePath, opts) var history = commit.history(); history.on("commit", function(commit) { + if (reported) { + return; + } // Number of commits is known to be higher than 200 if (++historyCount == 200) { - // Tracked objects must work too when the Garbage Collector is triggered - garbageCollect(); + reported = true; + // Tracked objects must work too when the Garbage Collector is triggered. + // Cap the collections: an unbounded loop blocked this worker for the + // whole test timeout on Node 24 built with Xcode 27. + garbageCollect(5); // Count total of objects left after being created/destroyed const freeingCount = @@ -58,10 +65,14 @@ return NodeGit.Clone(url, clonePath, opts) } } }); - + history.on("end", function(commits) { - // Test should not get this far - parentPort.postMessage("failure"); + // The walk continues past the 200th commit. That end is not a failure + // once the count has already been reported; posting it made the parent + // assert after the test had moved on. + if (!reported) { + parentPort.postMessage("failure"); + } }); history.on("error", function(err) { diff --git a/test/utils/worker_context_aware_checkout.js b/test/utils/worker_context_aware_checkout.js index 6562915a4..b136f6823 100644 --- a/test/utils/worker_context_aware_checkout.js +++ b/test/utils/worker_context_aware_checkout.js @@ -44,8 +44,9 @@ return NodeGit.Clone(url, clonePath, cloneOpts) return loopingCheckoutHead(clonePath, repository, 10); }).then(function() { assert.strictEqual(applyCallbackResult, 0); - // Tracked objects must work too when the Garbage Collector is triggered - garbageCollect(); + // Tracked objects must work too when the Garbage Collector is triggered. + // Cap the collections so a worker cannot loop in gc until the suite timeout. + garbageCollect(5); // Count total of objects left after being created/destroyed const freeingCount = diff --git a/utils/macOSDeploymentTarget.js b/utils/macOSDeploymentTarget.js new file mode 100644 index 000000000..cc8fc553d --- /dev/null +++ b/utils/macOSDeploymentTarget.js @@ -0,0 +1,41 @@ +const { execFileSync } = require("child_process"); + +const DEFAULT_TARGET = "10.11"; +// Xcode 27's libc++ no longer supports a deployment target below macOS 11. +const XCODE_27_TARGET = "11.0"; + +function deploymentTargetForSdk(version) { + if (!version) { + return DEFAULT_TARGET; + } + const major = Number.parseInt(String(version).split(".")[0], 10); + if (Number.isFinite(major) && major >= 27) { + return XCODE_27_TARGET; + } + return DEFAULT_TARGET; +} + +function sdkVersion() { + if (process.platform !== "darwin") { + return null; + } + try { + return execFileSync("xcrun", ["--sdk", "macosx", "--show-sdk-version"], { + encoding: "utf8", + stdio: ["ignore", "pipe", "ignore"] + }).trim(); + } + catch (error) { + return null; + } +} + +if (require.main === module) { + process.stdout.write(deploymentTargetForSdk(sdkVersion())); +} + +module.exports = { + DEFAULT_TARGET, + XCODE_27_TARGET, + deploymentTargetForSdk +}; diff --git a/utils/macOSDeploymentTarget.test.js b/utils/macOSDeploymentTarget.test.js new file mode 100644 index 000000000..51ceb61ab --- /dev/null +++ b/utils/macOSDeploymentTarget.test.js @@ -0,0 +1,19 @@ +const assert = require("assert"); +const test = require("node:test"); +const { + DEFAULT_TARGET, + XCODE_27_TARGET, + deploymentTargetForSdk +} = require("./macOSDeploymentTarget"); + +test("keeps the historical deployment target on older SDKs", function() { + assert.strictEqual(deploymentTargetForSdk(null), DEFAULT_TARGET); + assert.strictEqual(deploymentTargetForSdk("26.6"), DEFAULT_TARGET); + assert.strictEqual(deploymentTargetForSdk("11.0"), DEFAULT_TARGET); +}); + +test("raises the deployment target when the SDK is macOS 27 or newer", function() { + assert.strictEqual(deploymentTargetForSdk("27.0"), XCODE_27_TARGET); + assert.strictEqual(deploymentTargetForSdk("27.1"), XCODE_27_TARGET); + assert.strictEqual(XCODE_27_TARGET, "11.0"); +}); From 9afa50193e12b5d394a0f8b6570ea6516886162c Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 1 Dec 2026 23:14:02 +0000 Subject: [PATCH 3/3] fix: drop gyp comments that node-gyp cannot parse js-beautify joins the Xcode 27 deployment-target notes into the binding.gyp dictionary, so configure fails before the tests start. Co-authored-by: Jon Ursenbach --- generate/templates/templates/binding.gyp | 2 -- 1 file changed, 2 deletions(-) diff --git a/generate/templates/templates/binding.gyp b/generate/templates/templates/binding.gyp index b75bac96c..fe33fda7c 100644 --- a/generate/templates/templates/binding.gyp +++ b/generate/templates/templates/binding.gyp @@ -9,8 +9,6 @@ "electron_openssl_static%": "