Skip to content

Commit aa64fa1

Browse files
committed
Another attempted fix for client-integration-tests on Windows
1 parent f5fd393 commit aa64fa1

File tree

2 files changed

+52
-10
lines changed

2 files changed

+52
-10
lines changed

.github/actions/setup-codeql-environment/action.yml

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -150,21 +150,44 @@ runs:
150150
echo "✅ GitHub CLI CodeQL extension installed successfully"
151151
152152
# On Windows, gh codeql install-stub creates a bash script which is not
153-
# discoverable by Node.js child_process.spawn(). Create a .cmd wrapper
154-
# so that tools using spawn('codeql', ...) can find the CodeQL CLI.
155-
- name: Create Windows-compatible CodeQL CLI wrapper
153+
# discoverable by Node.js child_process.spawn() or execFile(), since
154+
# these functions only resolve real executables (.exe), not scripts.
155+
# Find the actual codeql.exe binary from the gh-codeql distribution
156+
# and add its directory to PATH so that spawn('codeql', ...) works.
157+
# This workaround can be removed once github/gh-codeql#21 is merged,
158+
# which adds native Windows support to install-stub.
159+
- name: Add CodeQL binary directory to PATH (Windows)
156160
if: runner.os == 'Windows'
157161
shell: bash
158162
run: |
159-
CODEQL_STUB_DIR="$HOME/.local/bin"
163+
echo "🔧 Locating actual codeql.exe binary for Windows compatibility..."
164+
165+
# Determine the gh-codeql data directory
166+
GH_CODEQL_DIR="${LOCALAPPDATA:-$HOME/AppData/Local}/GitHub/gh-codeql"
167+
168+
if [ ! -d "$GH_CODEQL_DIR" ]; then
169+
echo "❌ Error: gh-codeql data directory not found at $GH_CODEQL_DIR"
170+
exit 1
171+
fi
172+
173+
# Find the codeql.exe binary in the gh-codeql distribution
174+
CODEQL_EXE=$(find "$GH_CODEQL_DIR" -name "codeql.exe" -type f 2>/dev/null | head -1)
175+
176+
if [ -z "$CODEQL_EXE" ]; then
177+
echo "❌ Error: codeql.exe not found in $GH_CODEQL_DIR"
178+
echo "Directory contents:"
179+
find "$GH_CODEQL_DIR" -maxdepth 3 -type f | head -20
180+
exit 1
181+
fi
182+
183+
CODEQL_BIN_DIR=$(dirname "$CODEQL_EXE")
184+
echo "Found codeql.exe at: $CODEQL_EXE"
185+
echo "Adding $CODEQL_BIN_DIR to PATH"
160186
161-
cat > "$CODEQL_STUB_DIR/codeql.cmd" << 'WRAPPER'
162-
@echo off
163-
gh codeql %*
164-
exit /b %errorlevel%
165-
WRAPPER
187+
# Prepend the directory containing codeql.exe to PATH
188+
echo "$CODEQL_BIN_DIR" >> "$GITHUB_PATH"
166189
167-
echo "✅ Created Windows-compatible CodeQL CLI wrapper at $CODEQL_STUB_DIR/codeql.cmd"
190+
echo "✅ Added CodeQL binary directory to PATH for Windows"
168191
169192
- name: Setup CodeQL environment variables
170193
id: setup-codeql-env

.github/workflows/client-integration-tests.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,25 @@ jobs:
6666
with:
6767
install-language-runtimes: false
6868

69+
## Verify that the CodeQL CLI is spawnable from Node.js, not just from
70+
## bash. On Windows, Node.js spawn()/execFile() require a real .exe
71+
## binary on PATH, not a bash stub or .cmd wrapper. Fail fast here
72+
## instead of waiting for integration tests to time out.
73+
- name: MCP Integration Tests - Verify CodeQL CLI is spawnable from Node.js
74+
shell: bash
75+
run: |
76+
node -e "
77+
const { execFile } = require('child_process');
78+
execFile('codeql', ['version', '--format=terse'], (err, stdout) => {
79+
if (err) {
80+
console.error('❌ CodeQL CLI is not spawnable from Node.js:', err.message);
81+
console.error('This typically means codeql.exe is not on PATH (Windows).');
82+
process.exit(1);
83+
}
84+
console.log('✅ CodeQL CLI is spawnable from Node.js, version:', stdout.trim());
85+
});
86+
"
87+
6988
## Install packs used in the integration tests.
7089
- name: MCP Integration Tests - Install CodeQL packs
7190
shell: bash

0 commit comments

Comments
 (0)