Skip to content

Ensure cross-platform support via client integration tests run on ubuntu-latest and windows-latest#22

Merged
data-douser merged 12 commits intomainfrom
dd/fix-client-integration-tests-for-windows
Feb 7, 2026
Merged

Ensure cross-platform support via client integration tests run on ubuntu-latest and windows-latest#22
data-douser merged 12 commits intomainfrom
dd/fix-client-integration-tests-for-windows

Conversation

@data-douser
Copy link
Collaborator

Resolves #19

Summary of Changes

This pull request introduces significant improvements to how temporary files are handled in integration tests, ensuring that all test-related temporary files are stored in a project-local .tmp/ directory instead of OS-level temp directories. This change addresses security concerns (CWE-377/CWE-378) around world-readable temp files and standardizes temp file handling across platforms. Additionally, the PR enhances Windows support in CI workflows, updates documentation and fixtures to use the new temp directory convention, and improves the reliability and consistency of integration tests across both Linux and Windows environments.

Outline of Changes

Key changes:

Security and Temp Directory Handling

  • All test fixtures, test code, and documentation now use a {{tmpdir}} placeholder that resolves to the project-local .tmp/ directory, replacing any direct use of /tmp or OS temp directories. This affects test JSON files, test runner logic, and developer instructions. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]
  • The integration test runner (client/src/lib/integration-test-runner.js) is refactored to create and use temp directories under .tmp/, and a new resolvePathPlaceholders utility is added to substitute {{tmpdir}} in test parameters. [1] [2] [3] [4]

GitHub Actions and CI Improvements

  • The client-integration-tests workflow is updated to run on both Ubuntu and Windows runners, with a matrix strategy and OS-specific dependency installation (using choco for Windows and apt-get for Ubuntu). [1] [2]
  • The workflow now explicitly verifies that the CodeQL CLI is spawnable from Node.js (not just bash), which is crucial for Windows compatibility.
  • The setup action for CodeQL is improved to cache dependencies separately for Unix and Windows, and includes a workaround to ensure the CodeQL CLI binary is on PATH for Windows runners. [1] [2] [3]

Documentation and Developer Guidance

  • All relevant documentation and instructions are updated to instruct developers to use the {{tmpdir}} placeholder and avoid OS temp directories in tests and fixtures, explaining the security rationale. [1] [2] [3]

Miscellaneous

  • Minor workflow path matching and import improvements to support the above changes and maintain cross-platform compatibility. [1] [2] [3]

These changes collectively ensure secure, cross-platform temporary file handling for integration tests and robust CI support for both Linux and Windows environments.

Copilot AI and others added 10 commits February 6, 2026 20:35
- Use pathToFileURL() instead of file:// string concatenation in:
  - server/src/ql-mcp-server.ts (entrypoint check)
  - server/src/tools/codeql/language-server-eval.ts (workspace URI)
  - client/src/ql-mcp-client.js (entrypoint check)
- Fix path.includes() to normalize separators in cli-tool-registry.ts
- Replace .split('/').pop() with path.basename() for cross-platform path handling
- Update client-integration-tests.yml to run on matrix of ubuntu-latest and windows-latest
- Add platform-specific CI steps for process cleanup and OS dependencies
- Update setup-codeql-environment action with Windows cache paths

Co-authored-by: data-douser <70299490+data-douser@users.noreply.github.com>
…ead of split/join

Co-authored-by: data-douser <70299490+data-douser@users.noreply.github.com>
Co-authored-by: data-douser <70299490+data-douser@users.noreply.github.com>
On Windows, gh codeql install-stub creates a bash script (codeql) which
is not discoverable by Node.js child_process.spawn(). This causes
'spawn codeql ENOENT' errors in integration tests.

Add a step that creates a codeql.cmd wrapper delegating to 'gh codeql'
so that spawn('codeql', ...) resolves correctly on Windows.

Aligns with github/gh-codeql#21 which adds native Windows support to
install-stub. This workaround can be removed once that PR is merged.
@data-douser data-douser self-assigned this Feb 7, 2026
@data-douser data-douser requested review from a team and enyil as code owners February 7, 2026 02:15
Copilot AI review requested due to automatic review settings February 7, 2026 02:15
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens cross-platform behavior (Linux/Windows) by removing POSIX-specific path handling and OS temp directory usage, and by expanding CI coverage to run client integration tests on both ubuntu-latest and windows-latest.

Changes:

  • Replace fragile path/URI string manipulation with cross-platform Node APIs (pathToFileURL, path.basename, separator normalization).
  • Move integration test temporary-file usage to a repo-local .tmp/ directory via {{tmpdir}} placeholders resolved at runtime.
  • Update GitHub Actions workflows/actions to run client integration tests on a Windows + Ubuntu matrix and improve CodeQL CLI availability on Windows.

Reviewed changes

Copilot reviewed 16 out of 18 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
server/src/tools/codeql/language-server-eval.ts Uses pathToFileURL(...).href to construct a valid workspace URI on Windows.
server/src/ql-mcp-server.ts Updates “run directly” check to use pathToFileURL(...).
server/src/prompts/workflow-prompts.ts Replaces POSIX-only split('/') filename extraction with path.basename.
server/src/lib/cli-tool-registry.ts Normalizes separators for bundle/source detection; uses path.basename for query name extraction.
server/dist/ql-mcp-server.js Regenerated bundle reflecting the cross-platform path changes.
client/src/ql-mcp-client.js Improves Windows CLI handling and updates “run directly” check to use pathToFileURL(...).
client/src/lib/integration-test-runner.js Moves temp execution dirs under <repoRoot>/.tmp and introduces {{tmpdir}} placeholder resolution.
client/integration-tests/** Updates fixtures to use {{tmpdir}} instead of /tmp.
client/integration-tests/README.md Documents {{tmpdir}} usage and rationale.
.github/workflows/client-integration-tests.yml Runs integration tests on Windows + Ubuntu; adds CodeQL spawnability check and bash shell usage.
.github/actions/setup-codeql-environment/action.yml Adds Windows-specific caching and PATH workaround for codeql.exe.
.github/instructions/server_test_ts.instructions.md Adds explicit guidance to avoid OS temp dirs in tests/fixtures.
.github/agents/ql-mcp-tool-tester.md Updates agent constraints to avoid OS temp dirs and prefer {{tmpdir}}.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 16 out of 18 changed files in this pull request and generated 3 comments.

@data-douser data-douser added this pull request to the merge queue Feb 7, 2026
Merged via the queue into main with commit 2c48986 Feb 7, 2026
22 of 23 checks passed
@data-douser data-douser deleted the dd/fix-client-integration-tests-for-windows branch February 7, 2026 04:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Verify and ensure cross-platform support (Windows vs macOS/Linux)

3 participants