Skip to content

Commit 2128505

Browse files
committed
Fix extract-test-databases.sh minimal default scope
1 parent 0bd5348 commit 2128505

File tree

3 files changed

+50
-5
lines changed

3 files changed

+50
-5
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ jobs:
9393
run: ./server/scripts/install-packs.sh
9494

9595
## Extract test databases used in the integration tests.
96+
## Defaults to integration scope (javascript/examples only).
97+
## Query unit tests auto-extract their own databases via `codeql test run`.
9698
- name: MCP Integration Tests - Extract test databases
9799
shell: bash
98100
run: ./server/scripts/extract-test-databases.sh

client/src/lib/integration-test-runner.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,16 @@ export class IntegrationTestRunner {
785785
// Call the tool with appropriate parameters (timeout is handled by this.callTool)
786786
this.logger.log(`Calling tool ${toolName}`);
787787

788+
// Clean up stale interpretedOutput from prior test runs so that
789+
// directory comparisons only see output from this invocation.
790+
if (toolName === "codeql_query_run" && params.interpretedOutput) {
791+
try {
792+
fs.rmSync(params.interpretedOutput, { recursive: true, force: true });
793+
} catch {
794+
// Ignore — path may not exist yet
795+
}
796+
}
797+
788798
const result = await this.callTool(toolName, params);
789799

790800
// For monitoring tests, we primarily check if the tool executed successfully

server/scripts/extract-test-databases.sh

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,26 @@ set -euo pipefail
33

44
## Parse command line arguments
55
LANGUAGE=""
6+
SCOPE=""
67

78
usage() {
89
cat << EOF
910
Usage: $0 [OPTIONS]
1011
1112
Extract test databases for CodeQL queries associated with the MCP server.
1213
14+
By default, only databases needed by client integration tests are extracted
15+
(currently: javascript/examples only). Query unit tests (codeql test run)
16+
auto-extract their own databases, so full extraction is rarely needed.
17+
1318
OPTIONS:
14-
--language <lang> Extract databases only for the specified language
19+
--scope <scope> Extract databases for a specific use case
20+
Valid values:
21+
integration - Only databases needed by client integration tests (default)
22+
all - All test databases for all languages
23+
--language <lang> Extract databases only for the specified language (implies --scope all)
1524
Valid values: actions, cpp, csharp, go, java, javascript, python, ruby, rust, swift
1625
-h, --help Show this help message
17-
18-
By default, the script extracts databases for all supported languages.
1926
EOF
2027
}
2128

@@ -25,6 +32,10 @@ while [[ $# -gt 0 ]]; do
2532
LANGUAGE="$2"
2633
shift 2
2734
;;
35+
--scope)
36+
SCOPE="$2"
37+
shift 2
38+
;;
2839
-h|--help)
2940
usage
3041
exit 0
@@ -37,6 +48,18 @@ while [[ $# -gt 0 ]]; do
3748
esac
3849
done
3950

51+
## Validate scope if provided
52+
if [ -n "${SCOPE}" ]; then
53+
case "${SCOPE}" in
54+
integration|all) ;;
55+
*)
56+
echo "Error: Invalid scope '${SCOPE}'" >&2
57+
echo "Valid scopes: integration, all" >&2
58+
exit 1
59+
;;
60+
esac
61+
fi
62+
4063
## Validate language if provided
4164
VALID_LANGUAGES=("actions" "cpp" "csharp" "go" "java" "javascript" "python" "ruby" "rust" "swift")
4265
if [ -n "${LANGUAGE}" ]; then
@@ -91,7 +114,14 @@ extract_test_databases() {
91114
done < <(find "${_base_dir}/test" -mindepth 1 -maxdepth 1 -type d -print0)
92115
}
93116

94-
## Extract test databases for integration tests.
117+
## Extract test databases based on scope and language filters.
118+
##
119+
## Default (no flags): only databases needed by client integration tests
120+
## (currently just server/ql/javascript/examples).
121+
## --scope all: all languages × examples + tools.
122+
## --language: filter to a single language (implies --scope all).
123+
124+
# --language implies --scope all for that language
95125
if [ -n "${LANGUAGE}" ]; then
96126
echo "Extracting test databases for language: ${LANGUAGE}"
97127
# Special handling for JavaScript which has both examples and tools
@@ -101,7 +131,7 @@ if [ -n "${LANGUAGE}" ]; then
101131
if [ -d "server/ql/${LANGUAGE}/tools" ]; then
102132
extract_test_databases "server/ql/${LANGUAGE}/tools"
103133
fi
104-
else
134+
elif [ "${SCOPE}" = "all" ]; then
105135
echo "Extracting test databases for all languages..."
106136
for lang in "${VALID_LANGUAGES[@]}"; do
107137
# Special handling for JavaScript which has both examples and tools
@@ -112,6 +142,9 @@ else
112142
extract_test_databases "server/ql/${lang}/tools"
113143
fi
114144
done
145+
else
146+
echo "Extracting test databases for integration tests only..."
147+
extract_test_databases "server/ql/javascript/examples"
115148
fi
116149

117150
echo "INFO: Test database extraction complete!"

0 commit comments

Comments
 (0)