Skip to content

Commit 2424b3d

Browse files
Copilotdata-douser
andcommitted
Fix CODEQL_PATH Tests (windows-latest): robust binary search and skip MSYS2 FIFOs
Co-authored-by: data-douser <70299490+data-douser@users.noreply.github.com>
1 parent 2ce2b5d commit 2424b3d

File tree

2 files changed

+39
-13
lines changed

2 files changed

+39
-13
lines changed

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

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,24 @@ jobs:
186186
shell: bash
187187
run: |
188188
if [[ "$RUNNER_OS" == "Windows" ]]; then
189-
SEARCH_DIR="${LOCALAPPDATA:-$HOME/AppData/Local}"
190-
CODEQL_BINARY=$(find "$SEARCH_DIR" -path "*gh-codeql*release*" -name "codeql.exe" 2>/dev/null | head -1)
189+
# The gh-codeql extension stores CodeQL distributions under
190+
# %LOCALAPPDATA%\GitHub\gh-codeql on Windows (its own data dir),
191+
# separate from the GitHub CLI extensions directory. Search there
192+
# first, then fall back to the extensions dir and all LOCALAPPDATA.
193+
LOCALAPPDATA_DIR="${LOCALAPPDATA:-$HOME/AppData/Local}"
194+
CODEQL_BINARY=""
195+
for search_dir in \
196+
"${LOCALAPPDATA_DIR}/GitHub/gh-codeql" \
197+
"${LOCALAPPDATA_DIR}/GitHub CLI/extensions/gh-codeql" \
198+
"${LOCALAPPDATA_DIR}"; do
199+
if [[ -d "$search_dir" ]]; then
200+
CODEQL_BINARY=$(find "$search_dir" -maxdepth 10 \
201+
-name "codeql.exe" -type f 2>/dev/null | head -1)
202+
if [[ -n "$CODEQL_BINARY" ]]; then
203+
break
204+
fi
205+
fi
206+
done
191207
# Convert MSYS path to Windows mixed-mode path for Node.js
192208
if [[ -n "$CODEQL_BINARY" ]]; then
193209
CODEQL_BINARY=$(cygpath -m "$CODEQL_BINARY")

server/scripts/test-codeql-path-valid.sh

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,21 @@ trap cleanup EXIT
8585
# Use a long-running stdin feeder as a SEPARATE backgrounded process, then
8686
# connect it to the server via a named pipe (FIFO) to avoid bash subshell
8787
# PID issues with `A | B &`.
88-
FIFO="$(mktemp -u)"
89-
mkfifo "${FIFO}" 2>/dev/null || {
90-
# mkfifo may not exist on Windows Git Bash — fall back to /dev/null stdin.
91-
# The server will exit immediately on EOF but we can still check if startup
92-
# succeeds before the transport closes.
93-
FIFO=""
94-
}
88+
#
89+
# On Windows (MSYS2/Git Bash), mkfifo creates MSYS2-specific named pipes
90+
# that native Windows processes (node.exe) cannot read from reliably.
91+
# Force the process-substitution fallback on Windows, which creates a
92+
# Windows-compatible pipe handle that node.exe can read from correctly.
93+
FIFO=""
94+
case "$(uname -s)" in
95+
MINGW*|MSYS*|CYGWIN*)
96+
# Windows: skip mkfifo — native node.exe cannot read from MSYS2 FIFOs.
97+
;;
98+
*)
99+
FIFO="$(mktemp -u)"
100+
mkfifo "${FIFO}" 2>/dev/null || { FIFO=""; }
101+
;;
102+
esac
95103

96104
if [[ -n "${FIFO}" ]]; then
97105
# Feed the FIFO in the background so the server's stdin stays open
@@ -101,7 +109,9 @@ if [[ -n "${FIFO}" ]]; then
101109
node "${SERVER_BUNDLE}" < "${FIFO}" > /dev/null 2> "${STDERR_FILE}" &
102110
SERVER_PID=$!
103111
else
104-
# Fallback: use process substitution to keep stdin open
112+
# Fallback: use process substitution to keep stdin open.
113+
# On Windows, Git Bash converts process substitution into a Windows
114+
# pipe handle that node.exe (native process) can read correctly.
105115
node "${SERVER_BUNDLE}" < <(sleep 30) > /dev/null 2> "${STDERR_FILE}" &
106116
SERVER_PID=$!
107117
fi
@@ -140,9 +150,9 @@ if kill -0 "${SERVER_PID}" 2>/dev/null; then
140150
else
141151
wait "${SERVER_PID}" 2>/dev/null && EXIT_CODE=0 || EXIT_CODE=$?
142152

143-
# On Windows, mkfifo is unavailable and the process-substitution fallback
144-
# may not keep stdin open reliably. When the STDIO transport receives EOF
145-
# the server shuts down cleanly (exit 0) even though startup succeeded.
153+
# On Windows, process substitution may not keep stdin open reliably.
154+
# When the STDIO transport receives EOF the server shuts down cleanly
155+
# (exit 0) even though startup succeeded.
146156
# Accept that as a pass when the logs prove the server started correctly.
147157
if [[ "${EXIT_CODE}" -eq 0 ]] && check_startup_logs; then
148158
echo ""

0 commit comments

Comments
 (0)