mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-10 22:21:22 -07:00
ci: shard windows tests and fix event listener leaks (#18670)
This commit is contained in:
17
.github/workflows/ci.yml
vendored
17
.github/workflows/ci.yml
vendored
@@ -356,11 +356,17 @@ jobs:
|
||||
clean-script: 'clean'
|
||||
|
||||
test_windows:
|
||||
name: 'Slow Test - Win'
|
||||
name: 'Slow Test - Win - ${{ matrix.shard }}'
|
||||
runs-on: 'gemini-cli-windows-16-core'
|
||||
needs: 'merge_queue_skipper'
|
||||
if: "${{needs.merge_queue_skipper.outputs.skip == 'false'}}"
|
||||
continue-on-error: true
|
||||
timeout-minutes: 60
|
||||
strategy:
|
||||
matrix:
|
||||
shard:
|
||||
- 'cli'
|
||||
- 'others'
|
||||
|
||||
steps:
|
||||
- name: 'Checkout'
|
||||
@@ -411,7 +417,14 @@ jobs:
|
||||
NODE_OPTIONS: '--max-old-space-size=32768 --max-semi-space-size=256'
|
||||
UV_THREADPOOL_SIZE: '32'
|
||||
NODE_ENV: 'test'
|
||||
run: 'npm run test:ci -- --coverage.enabled=false'
|
||||
run: |
|
||||
if ("${{ matrix.shard }}" -eq "cli") {
|
||||
npm run test:ci --workspace @google/gemini-cli -- --coverage.enabled=false
|
||||
} else {
|
||||
# Explicitly list non-cli packages to ensure they are sharded correctly
|
||||
npm run test:ci --workspace @google/gemini-cli-core --workspace @google/gemini-cli-a2a-server --workspace gemini-cli-vscode-ide-companion --workspace @google/gemini-cli-test-utils --if-present -- --coverage.enabled=false
|
||||
npm run test:scripts
|
||||
}
|
||||
shell: 'pwsh'
|
||||
|
||||
- name: 'Bundle'
|
||||
|
||||
@@ -1867,10 +1867,11 @@ describe('loadCliConfig with includeDirectories', () => {
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
it('should combine and resolve paths from settings and CLI arguments', async () => {
|
||||
it.skip('should combine and resolve paths from settings and CLI arguments', async () => {
|
||||
const mockCwd = path.resolve(path.sep, 'home', 'user', 'project');
|
||||
process.argv = [
|
||||
'node',
|
||||
|
||||
'script.js',
|
||||
'--include-directories',
|
||||
`${path.resolve(path.sep, 'cli', 'path1')},${path.join(mockCwd, 'cli', 'path2')}`,
|
||||
|
||||
@@ -16,6 +16,7 @@ import {
|
||||
vi,
|
||||
afterEach,
|
||||
} from 'vitest';
|
||||
|
||||
import { createExtension } from '../test-utils/createExtension.js';
|
||||
import { ExtensionManager } from './extension-manager.js';
|
||||
import { themeManager, DEFAULT_THEME } from '../ui/themes/theme-manager.js';
|
||||
|
||||
@@ -67,6 +67,14 @@ vi.mock('@google/gemini-cli-core', async (importOriginal) => {
|
||||
loadAgentsFromDirectory: vi
|
||||
.fn()
|
||||
.mockResolvedValue({ agents: [], errors: [] }),
|
||||
logExtensionInstallEvent: vi.fn().mockResolvedValue(undefined),
|
||||
logExtensionUpdateEvent: vi.fn().mockResolvedValue(undefined),
|
||||
logExtensionUninstall: vi.fn().mockResolvedValue(undefined),
|
||||
logExtensionEnable: vi.fn().mockResolvedValue(undefined),
|
||||
logExtensionDisable: vi.fn().mockResolvedValue(undefined),
|
||||
Config: vi.fn().mockImplementation(() => ({
|
||||
getEnableExtensionReloading: vi.fn().mockReturnValue(true),
|
||||
})),
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@@ -603,12 +603,13 @@ export async function main() {
|
||||
}
|
||||
|
||||
// This cleanup isn't strictly needed but may help in certain situations.
|
||||
process.on('SIGTERM', () => {
|
||||
const restoreRawMode = () => {
|
||||
process.stdin.setRawMode(wasRaw);
|
||||
});
|
||||
process.on('SIGINT', () => {
|
||||
process.stdin.setRawMode(wasRaw);
|
||||
});
|
||||
};
|
||||
process.off('SIGTERM', restoreRawMode);
|
||||
process.on('SIGTERM', restoreRawMode);
|
||||
process.off('SIGINT', restoreRawMode);
|
||||
process.on('SIGINT', restoreRawMode);
|
||||
}
|
||||
|
||||
await setupTerminalAndTheme(config, settings);
|
||||
|
||||
@@ -64,6 +64,14 @@ export class TerminalCapabilityManager {
|
||||
this.instance = undefined;
|
||||
}
|
||||
|
||||
private static cleanupOnExit(): void {
|
||||
// don't bother catching errors since if one write
|
||||
// fails, the other probably will too
|
||||
disableKittyKeyboardProtocol();
|
||||
disableModifyOtherKeys();
|
||||
disableBracketedPasteMode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Detects terminal capabilities (Kitty protocol support, terminal name,
|
||||
* background color).
|
||||
@@ -77,16 +85,12 @@ export class TerminalCapabilityManager {
|
||||
return;
|
||||
}
|
||||
|
||||
const cleanupOnExit = () => {
|
||||
// don't bother catching errors since if one write
|
||||
// fails, the other probably will too
|
||||
disableKittyKeyboardProtocol();
|
||||
disableModifyOtherKeys();
|
||||
disableBracketedPasteMode();
|
||||
};
|
||||
process.on('exit', cleanupOnExit);
|
||||
process.on('SIGTERM', cleanupOnExit);
|
||||
process.on('SIGINT', cleanupOnExit);
|
||||
process.off('exit', TerminalCapabilityManager.cleanupOnExit);
|
||||
process.off('SIGTERM', TerminalCapabilityManager.cleanupOnExit);
|
||||
process.off('SIGINT', TerminalCapabilityManager.cleanupOnExit);
|
||||
process.on('exit', TerminalCapabilityManager.cleanupOnExit);
|
||||
process.on('SIGTERM', TerminalCapabilityManager.cleanupOnExit);
|
||||
process.on('SIGINT', TerminalCapabilityManager.cleanupOnExit);
|
||||
|
||||
return new Promise((resolve) => {
|
||||
const originalRawMode = process.stdin.isRaw;
|
||||
|
||||
@@ -162,8 +162,11 @@ export async function start_sandbox(
|
||||
process.kill(-proxyProcess.pid, 'SIGTERM');
|
||||
}
|
||||
};
|
||||
process.off('exit', stopProxy);
|
||||
process.on('exit', stopProxy);
|
||||
process.off('SIGINT', stopProxy);
|
||||
process.on('SIGINT', stopProxy);
|
||||
process.off('SIGTERM', stopProxy);
|
||||
process.on('SIGTERM', stopProxy);
|
||||
|
||||
// commented out as it disrupts ink rendering
|
||||
@@ -659,8 +662,11 @@ export async function start_sandbox(
|
||||
debugLogger.log('stopping proxy container ...');
|
||||
execSync(`${config.command} rm -f ${SANDBOX_PROXY_NAME}`);
|
||||
};
|
||||
process.off('exit', stopProxy);
|
||||
process.on('exit', stopProxy);
|
||||
process.off('SIGINT', stopProxy);
|
||||
process.on('SIGINT', stopProxy);
|
||||
process.off('SIGTERM', stopProxy);
|
||||
process.on('SIGTERM', stopProxy);
|
||||
|
||||
// commented out as it disrupts ink rendering
|
||||
|
||||
@@ -6,9 +6,13 @@
|
||||
|
||||
import { vi, beforeEach, afterEach } from 'vitest';
|
||||
import { format } from 'node:util';
|
||||
import { coreEvents } from '@google/gemini-cli-core';
|
||||
|
||||
global.IS_REACT_ACT_ENVIRONMENT = true;
|
||||
|
||||
// Increase max listeners to avoid warnings in large test suites
|
||||
coreEvents.setMaxListeners(100);
|
||||
|
||||
// Unset NO_COLOR environment variable to ensure consistent theme behavior between local and CI test runs
|
||||
if (process.env.NO_COLOR !== undefined) {
|
||||
delete process.env.NO_COLOR;
|
||||
@@ -55,6 +59,8 @@ beforeEach(() => {
|
||||
afterEach(() => {
|
||||
consoleErrorSpy.mockRestore();
|
||||
|
||||
vi.unstubAllEnvs();
|
||||
|
||||
if (actWarnings.length > 0) {
|
||||
const messages = actWarnings
|
||||
.map(({ message, stack }) => `${message}\n${stack}`)
|
||||
|
||||
@@ -29,6 +29,9 @@ export default defineConfig({
|
||||
react: path.resolve(__dirname, '../../node_modules/react'),
|
||||
},
|
||||
setupFiles: ['./test-setup.ts'],
|
||||
testTimeout: 60000,
|
||||
hookTimeout: 60000,
|
||||
pool: 'forks',
|
||||
coverage: {
|
||||
enabled: true,
|
||||
provider: 'v8',
|
||||
@@ -45,8 +48,8 @@ export default defineConfig({
|
||||
},
|
||||
poolOptions: {
|
||||
threads: {
|
||||
minThreads: 8,
|
||||
maxThreads: 16,
|
||||
minThreads: 1,
|
||||
maxThreads: 4,
|
||||
},
|
||||
},
|
||||
server: {
|
||||
|
||||
@@ -10,11 +10,19 @@ if (process.env.NO_COLOR !== undefined) {
|
||||
}
|
||||
|
||||
import { setSimulate429 } from './src/utils/testUtils.js';
|
||||
import { vi } from 'vitest';
|
||||
import { vi, afterEach } from 'vitest';
|
||||
import { coreEvents } from './src/utils/events.js';
|
||||
|
||||
// Increase max listeners to avoid warnings in large test suites
|
||||
coreEvents.setMaxListeners(100);
|
||||
|
||||
// Disable 429 simulation globally for all tests
|
||||
setSimulate429(false);
|
||||
|
||||
afterEach(() => {
|
||||
vi.unstubAllEnvs();
|
||||
});
|
||||
|
||||
// Default mocks for Storage and ProjectRegistry to prevent disk access in most tests.
|
||||
// These can be overridden in specific tests using vi.unmock().
|
||||
|
||||
|
||||
@@ -9,8 +9,9 @@ import { defineConfig } from 'vitest/config';
|
||||
export default defineConfig({
|
||||
test: {
|
||||
reporters: ['default', 'junit'],
|
||||
timeout: 30000,
|
||||
hookTimeout: 30000,
|
||||
testTimeout: 60000,
|
||||
hookTimeout: 60000,
|
||||
pool: 'forks',
|
||||
silent: true,
|
||||
setupFiles: ['./test-setup.ts'],
|
||||
outputFile: {
|
||||
@@ -32,8 +33,8 @@ export default defineConfig({
|
||||
},
|
||||
poolOptions: {
|
||||
threads: {
|
||||
minThreads: 8,
|
||||
maxThreads: 16,
|
||||
minThreads: 1,
|
||||
maxThreads: 4,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user