Skip to content

Commit a44bd5e

Browse files
Copilotdata-douser
andcommitted
Address code review: improve error handling and portability
Co-authored-by: data-douser <70299490+data-douser@users.noreply.github.com>
1 parent c6743c6 commit a44bd5e

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

.github/workflows/ql-unit-tests-windows.yml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ jobs:
7676
shell: bash
7777
run: |
7878
# Read CodeQL CLI version from qlt.conf.json
79-
CLI_VERSION=$(grep -oP '"CodeQLCLI"\s*:\s*"\K[^"]+' qlt.conf.json)
79+
CLI_VERSION=$(sed -n 's/.*"CodeQLCLI"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' qlt.conf.json)
8080
8181
# Ensure version has 'v' prefix for GitHub releases
8282
if [[ ! "$CLI_VERSION" =~ ^v ]]; then
@@ -97,10 +97,16 @@ jobs:
9797
# Download and extract CodeQL CLI
9898
ZIP_PATH="$RUNNER_TEMP/codeql.zip"
9999
echo "Downloading from: $DOWNLOAD_URL"
100-
curl -L -o "$ZIP_PATH" "$DOWNLOAD_URL"
100+
if ! curl -fL -o "$ZIP_PATH" "$DOWNLOAD_URL"; then
101+
echo "Error: Failed to download CodeQL CLI"
102+
exit 1
103+
fi
101104
102105
echo "Extracting CodeQL CLI to: $INSTALL_DIR"
103-
unzip -q "$ZIP_PATH" -d "$INSTALL_DIR"
106+
if ! unzip -q "$ZIP_PATH" -d "$INSTALL_DIR"; then
107+
echo "Error: Failed to extract CodeQL CLI"
108+
exit 1
109+
fi
104110
105111
# Set up environment
106112
CODEQL_PATH="$INSTALL_DIR/codeql"
@@ -137,15 +143,18 @@ jobs:
137143
echo "Installing QL packs from qlpack.yml files..."
138144
139145
# Find all qlpack.yml files and install dependencies
140-
find javascript -name "qlpack.yml" | while read qlpack; do
146+
while IFS= read -r qlpack; do
141147
dir=$(dirname "$qlpack")
142148
echo "Installing packs for: $dir"
143-
pushd "$dir" > /dev/null
149+
if ! pushd "$dir" > /dev/null; then
150+
echo "Error: Failed to change directory to $dir"
151+
continue
152+
fi
144153
if ! codeql pack install; then
145154
echo "Warning: Failed to install packs in $dir"
146155
fi
147156
popd > /dev/null
148-
done
157+
done < <(find javascript -name "qlpack.yml")
149158
150159
echo "QL pack installation complete"
151160

0 commit comments

Comments
 (0)