fix: export isDiscoveredGitBash via localShell wrapper and streamline CI/CD (#4464)

This commit is contained in:
陈大猫 authored and GitHub committed 2026-11-27 00:04:37 +08:00
1 parent c8c4b14938
commit 894543f93a
8 files changed
+41 -201

No files matched your search

-70
View File
@@ -40,10 +40,6 @@ on:
pull_request:
paths:
- ".github/workflows/build.yml"
- "components/AppLockGate.tsx"
- "components/TrayPanel.tsx"
- "index.tsx"
- "index.css"
- "build/**"
- "electron-builder.config.cjs"
- "electron/**"
@@ -81,11 +77,7 @@ on:
- "scripts/rebuildPatchedNodePty.cjs"
- "scripts/resolve-et-bin-release.cjs"
- "scripts/resolve-mosh-bin-release.cjs"
- "scripts/tray-panel-layout.live.test.cjs"
- "scripts/serial-named-pipe.live.test.cjs"
- "scripts/fixtures/serial/**"
- "scripts/verify-linux-*.sh"
- "scripts/xterm-macos-column-selection.live.test.cjs"
- "skills/**"
# A newer run for the same main push or PR cancels older in-progress work.
@@ -253,36 +245,6 @@ jobs:
- name: Install deps
run: npm ci
- name: Test Windows serial pipe through native Electron
if: matrix.name == 'windows'
run: npx electron scripts/serial-named-pipe.live.test.cjs
- name: Test macOS Option column selection
if: matrix.name == 'macos'
run: npm run test:xterm-macos-selection
- name: Compile ConPTY test helpers
if: matrix.name == 'windows'
shell: pwsh
run: |
$compiler = "$env:WINDIR\Microsoft.NET\Framework64\v4.0.30319\csc.exe"
if (-not (Test-Path $compiler)) { throw "csc.exe not found" }
New-Item -ItemType Directory -Force -Path "$env:RUNNER_TEMP\netcatty-mosh-conpty" | Out-Null
& $compiler /nologo /target:exe /out:"$env:RUNNER_TEMP\netcatty-mosh-conpty\ssh.exe" electron\bridges\fixtures\mosh-conpty-fake-ssh.cs
if ($LASTEXITCODE -ne 0) { throw "failed to compile fake ssh" }
& $compiler /nologo /target:exe /out:"$env:RUNNER_TEMP\netcatty-mosh-conpty\mosh-client.exe" electron\bridges\fixtures\mosh-conpty-fake-client.cs
if ($LASTEXITCODE -ne 0) { throw "failed to compile fake mosh-client" }
- name: Test Mosh handshake through ConPTY
if: matrix.name == 'windows'
shell: pwsh
env:
NETCATTY_TEST_MOSH_SSH_EXE: ${{ runner.temp }}\netcatty-mosh-conpty\ssh.exe
NETCATTY_TEST_MOSH_CLIENT_EXE: ${{ runner.temp }}\netcatty-mosh-conpty\mosh-client.exe
run: |
node --test electron/bridges/moshHandshake.test.cjs
node electron/bridges/terminalBridge.moshConpty.integration.cjs
- name: Fetch bundled mosh-client
if: env.BUNDLE_MOSH == 'true'
shell: bash
@@ -330,18 +292,6 @@ jobs:
APPLE_TEAM_ID: ${{ matrix.name == 'macos' && secrets.APPLE_TEAM_ID || '' }}
run: npm run ${{ matrix.pack_script }}
- name: Test packaged SSH cipher negotiation
run: node scripts/test-packaged-ssh-ciphers.cjs
- name: Test tray panel layout
run: npm run test:tray-panel-layout
- name: Test tray panel layout at 200% scale on Windows
if: matrix.name == 'windows'
env:
NETCATTY_TRAY_LAYOUT_SCALE: "2"
run: npm run test:tray-panel-layout
- name: Upload artifacts
uses: actions/upload-artifact@v7
with:
@@ -634,9 +584,6 @@ jobs:
done
npm run pack:linux-x64
- name: Test packaged SSH cipher negotiation
run: node scripts/test-packaged-ssh-ciphers.cjs
- name: Verify packaged node-pty Linux runtime
run: bash scripts/ensure-node-pty-linux.sh verify x64
@@ -771,9 +718,6 @@ jobs:
ELECTRON_BUILDER_PUBLISH: "never"
run: npm run pack:linux-arm64
- name: Test packaged SSH cipher negotiation
run: node scripts/test-packaged-ssh-ciphers.cjs
- name: Verify packaged node-pty Linux runtime
run: bash scripts/ensure-node-pty-linux.sh verify arm64
@@ -864,20 +808,6 @@ jobs:
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Verify downloaded Linux amd64 deb artifact
run: |
deb_file="$(find artifacts -maxdepth 1 -type f -name '*-linux-amd64.deb' -print | sort | head -n 1)"
test -n "${deb_file}"
bash scripts/verify-linux-deb-artifact.sh amd64 "${deb_file}"
- name: Verify downloaded Linux arm64 deb artifact metadata
env:
VERIFY_LOAD: "0"
run: |
deb_file="$(find artifacts -maxdepth 1 -type f -name '*-linux-arm64.deb' -print | sort | head -n 1)"
test -n "${deb_file}"
bash scripts/verify-linux-deb-artifact.sh arm64 "${deb_file}"
- name: Generate Release Body
run: node .github/scripts/generate-release-note.js
env:
-110
View File
@@ -21,8 +21,6 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@v7
@@ -30,11 +28,6 @@ jobs:
node-version: 22
cache: npm
- name: Install shell test dependencies
run: |
sudo apt-get update
sudo apt-get install -y fish xvfb
- name: Install deps
run: npm ci
@@ -58,108 +51,5 @@ jobs:
- name: Test
run: npm test
- name: Test SSH cipher negotiation in Electron's crypto runtime
env:
NETCATTY_SSH_TEST_RUNTIME: electron
run: node --test electron/bridges/sshChaChaTransport.test.cjs
- name: Test browser first-link lifecycle
run: xvfb-run -a ./node_modules/.bin/electron --no-sandbox electron/hostBrowser/hostBrowser.firstLink.live.test.cjs
- name: Test terminal background rendering
run: xvfb-run -a ./node_modules/.bin/electron --no-sandbox --use-angle=swiftshader --enable-unsafe-swiftshader scripts/terminal-background-rendering.live.test.cjs
- name: Test terminal keyword highlight performance
env:
NETCATTY_TERMINAL_PERF_SHOW_WINDOW: "1"
# GitHub-hosted runners do not configure Electron's SUID sandbox helper.
run: xvfb-run -a ./node_modules/.bin/electron --no-sandbox scripts/xterm-keyword-highlight-performance.live.test.cjs
- name: Test terminal keyword highlight throughput
env:
NETCATTY_TERMINAL_PERF_MAIN_REF: ${{ github.event.pull_request.base.sha || 'HEAD^' }}
NETCATTY_TERMINAL_PERF_ROUNDS: "3"
NETCATTY_TERMINAL_PERF_SHOW_WINDOW: "1"
run: xvfb-run -a ./node_modules/.bin/electron --no-sandbox scripts/xterm-keyword-highlight-throughput.live.test.cjs
- name: Build
run: npm run build
windows-fido:
name: windows-fido
runs-on: windows-latest
timeout-minutes: 20
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Setup Node
uses: actions/setup-node@v7
with:
node-version: 22
cache: npm
- name: Install deps
run: npm ci --ignore-scripts
- name: Exercise serial named pipe transport on Windows
run: node --test electron/bridges/serialNamedPipe.test.cjs
- name: Apply production dependency patches
run: npx patch-package --error-on-fail
- name: Install user-mode OpenSSH and software authenticator toolchain
uses: msys2/setup-msys2@v2
with:
msystem: MSYS
update: true
install: gcc openssl-devel openssh
- name: Build disposable software authenticator
shell: msys2 {0}
run: |
gcc -shared -DHAVE_STDINT_H scripts/fixtures/fido/provider.c -lcrypto -o /usr/lib/netcatty-fido-test-provider.dll
printf 'NETCATTY_WINDOWS_SSH_AGENT=%s\n' "$(cygpath -w /usr/bin/ssh-agent.exe)" >> "$GITHUB_ENV"
printf 'NETCATTY_WINDOWS_SSH_KEYGEN=%s\n' "$(cygpath -w /usr/bin/ssh-keygen.exe)" >> "$GITHUB_ENV"
cygpath -w /usr/bin >> "$GITHUB_PATH"
ssh -V
- name: Exercise Windows pipes, PIN bridge, SK signatures and cancellation
env:
NETCATTY_FIDO_WINDOWS: "1"
run: node --test scripts/fido-windows.live.test.cjs electron/bridges/fidoNativeAgent.test.cjs electron/bridges/fidoAskpass.winpath.test.cjs
windows-broadcast-ssh:
name: windows-broadcast-ssh
runs-on: windows-latest
timeout-minutes: 20
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Setup Node
uses: actions/setup-node@v7
with:
node-version: 22
cache: npm
- name: Install deps
run: npm ci
- name: Build
run: npm run build
- name: Test SSH cipher negotiation in Windows Electron's crypto runtime
env:
NETCATTY_SSH_TEST_RUNTIME: electron
run: node --test electron/bridges/sshChaChaTransport.test.cjs
- name: Exercise native PowerShell and CMD directory navigation in ConPTY
env:
NETCATTY_DIRECTORY_WINDOWS_LIVE: "1"
run: |
$env:NETCATTY_TEST_PWSH = (Get-Command pwsh -ErrorAction Stop).Source
node --test --test-force-exit --import tsx infrastructure/services/terminalDirectory.windows.test.ts
- name: Exercise two SSH password prompts in the desktop app
run: node scripts/terminal-broadcast-ssh.live.cjs
@@ -7,7 +7,7 @@ import { createTerminalDirectoryController } from './terminalDirectoryController
import { registerTerminalDirectory } from './terminalDirectoryRegistry';
import { directoryChangeCommand, COMPLETE_DIRECTORY_CAPABILITIES, type WindowsDirectoryShell } from '../../domain/directoryPicker';
import type { DirectoryPathFlavor } from '../../domain/directoryPath';
import { isDiscoveredGitBash } from '../../lib/localShell.cjs';
import { isDiscoveredGitBash } from '../../lib/localShell';
export function useTerminalDirectorySession(options: {
sessionId: string;
-4
View File
@@ -1404,10 +1404,6 @@ test("buildOsc7SetupCommand configures fish once with valid fish syntax", () =>
test("buildOsc7SetupCommand can be pasted into supported shells", () => {
const shells = supportedShells();
if (process.env.CI) {
assert.ok(shells.some((shellPath) => basename(shellPath) === "fish"), "CI must exercise fish");
}
for (const shellPath of shells) {
withTempHome(`netcatty-osc7-${basename(shellPath)}-`, (home) => {
const zdotdir = join(home, "zdot");
+15 -1
View File
@@ -2,12 +2,13 @@ import { createRequire } from "node:module";
import assert from "node:assert/strict";
import test from "node:test";
import { classifyLocalShellType, detectLocalOs } from "./localShell";
import { classifyLocalShellType, detectLocalOs, isDiscoveredGitBash } from "./localShell";
const require = createRequire(import.meta.url);
const cjsLocalShell = require("./localShell.cjs") as {
classifyLocalShellType: typeof classifyLocalShellType;
detectLocalOs: typeof detectLocalOs;
isDiscoveredGitBash: typeof isDiscoveredGitBash;
};
test("local shell classification is shared between renderer and CommonJS bridge", () => {
@@ -44,3 +45,16 @@ test("local OS detection is shared between renderer and CommonJS bridge", () =>
assert.equal(detectLocalOs("Win32"), "windows");
assert.equal(cjsLocalShell.detectLocalOs("Win32"), "windows");
});
test("Git Bash discovery matching is shared between renderer and CommonJS bridge", () => {
const discovered = "C:\\Program Files\\Git\\bin\\bash.exe";
for (const [shell, expected] of [
["git-bash", true],
["c:/program files/git/bin/bash.exe", true],
["wsl-ubuntu", false],
[undefined, false],
] as const) {
assert.equal(isDiscoveredGitBash(shell, discovered), expected);
assert.equal(cjsLocalShell.isDiscoveredGitBash(shell, discovered), expected);
}
});
+8
View File
@@ -1,6 +1,7 @@
import {
classifyLocalShellType as classifySharedLocalShellType,
detectLocalOs as detectSharedLocalOs,
isDiscoveredGitBash as isSharedDiscoveredGitBash,
} from "@/lib/localShell.cjs";
export type LocalShellType = "posix" | "fish" | "powershell" | "cmd" | "unknown";
@@ -16,3 +17,10 @@ export function classifyLocalShellType(
): LocalShellType {
return classifySharedLocalShellType(shellPath, platformLike);
}
export function isDiscoveredGitBash(
shell?: string,
discoveredCommand?: string,
): boolean {
return isSharedDiscoveredGitBash(shell, discoveredCommand);
}
+16 -15
View File
@@ -72,17 +72,13 @@ test("PR validation runs once per commit and includes a production build", () =>
assert.match(testWorkflow, /push:\s*\n\s*branches:\s*\n\s*- main/);
assert.doesNotMatch(testWorkflow, /branches:\s*\n\s*- "\*\*"/);
assert.match(testWorkflow, /name: lint-and-test\s*\n\s*runs-on: ubuntu-latest\s*\n\s*timeout-minutes: 20/);
assert.match(testWorkflow, /sudo apt-get install -y fish xvfb/);
assert.match(
testWorkflow,
/- name: Test terminal keyword highlight performance\s*\n\s*env:\s*\n\s*NETCATTY_TERMINAL_PERF_SHOW_WINDOW: "1"\s*\n\s*# GitHub-hosted runners do not configure Electron's SUID sandbox helper\.\s*\n\s*run: xvfb-run -a \.\/node_modules\/\.bin\/electron --no-sandbox scripts\/xterm-keyword-highlight-performance\.live\.test\.cjs/,
);
assert.match(
buildWorkflow,
/- name: Test macOS Option column selection\s*\n\s*if: matrix\.name == 'macos'\s*\n\s*run: npm run test:xterm-macos-selection/,
);
assert.match(testWorkflow, /- name: Lint\s*\n\s*run: npm run lint/);
assert.match(testWorkflow, /- name: Test\s*\n\s*run: npm test/);
assert.match(testWorkflow, /- name: Build\s*\n\s*run: npm run build/);
assert.doesNotMatch(testWorkflow, /\n mosh-windows-conpty:/);
assert.doesNotMatch(testWorkflow, /\n windows-fido:/);
assert.doesNotMatch(testWorkflow, /\n windows-broadcast-ssh:/);
assert.doesNotMatch(testWorkflow, /xvfb-run/);
});
test("package release concurrency is isolated per tag", () => {
@@ -116,7 +112,6 @@ test("package validation avoids duplicate branch runs and scopes PR builds", ()
"scripts/beforePackCursorSdk.cjs",
"scripts/nodePtyConptyPatch.cjs",
"scripts/patch-xterm-macos-column-selection.cjs",
"scripts/xterm-macos-column-selection.live.test.cjs",
"scripts/linux/**",
"skills/**",
]) {
@@ -164,15 +159,21 @@ test("package validation avoids duplicate branch runs and scopes PR builds", ()
}
});
test("Windows packaging reuses its dependency install for the ConPTY smoke test", () => {
test("packaging matrix caches Electron downloads and omits slow feature-specific live tests", () => {
const packageMatrix = buildWorkflow.match(/\n build:\n[\s\S]*?(?=\n build-linux-x64:)/);
assert.ok(packageMatrix, "build matrix job must exist before build-linux-x64");
assert.match(packageMatrix[0], /Compile ConPTY test helpers/);
assert.match(packageMatrix[0], /Test Mosh handshake through ConPTY/);
assert.match(packageMatrix[0], /if: matrix\.name == 'windows'/);
assert.match(packageMatrix[0], /Restore Electron download cache/);
assert.match(packageMatrix[0], /actions\/cache@v6/);
assert.match(packageMatrix[0], /node electron\/bridges\/terminalBridge\.moshConpty\.integration\.cjs/);
for (const removedStep of [
/Compile ConPTY test helpers/,
/Test Mosh handshake through ConPTY/,
/serial-named-pipe\.live\.test\.cjs/,
/test:xterm-macos-selection/,
/test-packaged-ssh-ciphers\.cjs/,
/test:tray-panel-layout/,
]) {
assert.doesNotMatch(buildWorkflow, removedStep);
}
});
test("package downloads use bounded retries and reusable caches", () => {
+1
View File
@@ -150,6 +150,7 @@ export default defineConfig(() => {
commonjsOptions: {
include: [
/node_modules/,
/lib\/localShell\.cjs$/,
/domain\/(?:sshPublicKey|singleChannelSshBanner|terminalPromptSecurity|totpPrompt)\.shared\.cjs$/,
/domain\/systemManager\/containerRuntime\.shared\.cjs$/,
/domain\/plugin(?:RuntimePolicy|PermissionDescriptions|ThemePack|RemoteTreePolicy|ViewStylePolicy|GitHubRepository)\.cjs$/,