This is an automated email from the ASF dual-hosted git repository.
gian pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/druid.git
The following commit(s) were added to refs/heads/master by this push:
new a5dad129e95 Web console: Add test-unit script. (#19184)
a5dad129e95 is described below
commit a5dad129e95cdea9d661b1700f26f7b6d0cc0632
Author: Gian Merlino <[email protected]>
AuthorDate: Fri Mar 20 08:29:53 2026 -0700
Web console: Add test-unit script. (#19184)
The "test" script runs the full script/build, which takes a while
and isn't necessary. It also runs e2e tests, which require a running
Druid service, which is not always going to be available.
This patch adds a "test-unit" script that builds SQL docs only, not
the full webpack bundle, and runs unit tests only.
---
AGENTS.md | 7 ++++-
web-console/package.json | 1 +
web-console/script/build | 43 +++-------------------------
web-console/script/{build => build-sql-docs} | 37 ------------------------
4 files changed, 11 insertions(+), 77 deletions(-)
diff --git a/AGENTS.md b/AGENTS.md
index 355a07d797c..bf1bfd379da 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -76,7 +76,12 @@ present, such as `-Dquidem.filter=qaWin/**`.
### Web Console Development
-- Refer to `web-console/README.md` for instructions on developing, linting,
and testing web console features.
+Refer to `web-console/README.md` for general instructions on developing the
web console.
+
+Run `npm run test-unit` from the `web-console/` directory to verify your work.
Before doing this for the first time
+in a fresh checkout, you will also need to run `npm install`.
+
+Run `npm run autofix` from the `web-console/` directory to fix formatting
issues.
### Documentation
diff --git a/web-console/package.json b/web-console/package.json
index 67aa9b09227..0ffde8c3c3b 100644
--- a/web-console/package.json
+++ b/web-console/package.json
@@ -17,6 +17,7 @@
"test": "npm run test-base -- --silent 2>&1",
"test-ci": "npm run test-base -- --coverage",
"test-e2e": "jest --runInBand --config jest.e2e.config.js e2e-tests",
+ "test-unit": "./script/build-sql-docs && npm run eslint && npm run
sasslint && npm run prettify-check && jest --config jest.config.js
--testPathIgnorePatterns='e2e-tests'",
"codecov": "codecov --disable=gcov -p ..",
"coverage": "jest --coverage src",
"update-snapshots": "jest -u --config jest.config.js",
diff --git a/web-console/script/build b/web-console/script/build
index 0bb00fb2aec..8b3c4976480 100755
--- a/web-console/script/build
+++ b/web-console/script/build
@@ -36,46 +36,11 @@ is_newer_than() {
[ "$1" -nt "$2" ]
}
-# Check if SQL docs need to be built
-SQL_DOCS_OUTPUT="lib/sql-docs.ts"
-SQL_DOCS_SCRIPT="script/create-sql-docs.mjs"
-SQL_DOCS_FILELIST="script/sql-doc-files.txt"
-
-BUILD_SQL_DOCS=false
-
-if [ "$FORCE_BUILD" = true ] || [ ! -f "$SQL_DOCS_OUTPUT" ]; then
- BUILD_SQL_DOCS=true
-else
- # Check if create-sql-docs.mjs is newer than output
- if is_newer_than "$SQL_DOCS_SCRIPT" "$SQL_DOCS_OUTPUT"; then
- BUILD_SQL_DOCS=true
- fi
-
- # Check if sql-doc-files.txt is newer than output
- if is_newer_than "$SQL_DOCS_FILELIST" "$SQL_DOCS_OUTPUT"; then
- BUILD_SQL_DOCS=true
- fi
-
- # Check if any file listed in sql-doc-files.txt is newer than output
- if [ -f "$SQL_DOCS_FILELIST" ] && [ "$BUILD_SQL_DOCS" = false ]; then
- while read -r file; do
- # Skip empty lines and comments
- if [[ -z "$file" ]] || [[ "$file" =~ ^[[:space:]]*# ]]; then
- continue
- fi
- if [ -n "$file" ] && is_newer_than "$file" "$SQL_DOCS_OUTPUT"; then
- BUILD_SQL_DOCS=true
- break
- fi
- done < "$SQL_DOCS_FILELIST"
- fi
-fi
-
-if [ "$BUILD_SQL_DOCS" = true ]; then
- echo "Compiling SQL function docs for the web console..."
- ./script/create-sql-docs.mjs
+# Build SQL docs
+if [ "$FORCE_BUILD" = true ]; then
+ ./script/build-sql-docs --force
else
- echo "SQL docs are up to date, skipping..."
+ ./script/build-sql-docs
fi
# Get version from package.json
diff --git a/web-console/script/build b/web-console/script/build-sql-docs
similarity index 66%
copy from web-console/script/build
copy to web-console/script/build-sql-docs
index 0bb00fb2aec..0a6f49bdf7a 100755
--- a/web-console/script/build
+++ b/web-console/script/build-sql-docs
@@ -36,7 +36,6 @@ is_newer_than() {
[ "$1" -nt "$2" ]
}
-# Check if SQL docs need to be built
SQL_DOCS_OUTPUT="lib/sql-docs.ts"
SQL_DOCS_SCRIPT="script/create-sql-docs.mjs"
SQL_DOCS_FILELIST="script/sql-doc-files.txt"
@@ -77,39 +76,3 @@ if [ "$BUILD_SQL_DOCS" = true ]; then
else
echo "SQL docs are up to date, skipping..."
fi
-
-# Get version from package.json
-VERSION=$(node -e "console.log(require('./package.json').version)")
-CONSOLE_OUTPUT="public/web-console-$VERSION.js"
-
-BUILD_CONSOLE=false
-
-if [ "$FORCE_BUILD" = true ] || [ ! -f "$CONSOLE_OUTPUT" ]; then
- BUILD_CONSOLE=true
-else
- # Check if any config file is newer than output
- CONFIG_FILES=("package.json" "package-lock.json" "webpack.config.mjs"
"tsconfig.json")
- for config_file in "${CONFIG_FILES[@]}"; do
- if is_newer_than "$config_file" "$CONSOLE_OUTPUT"; then
- BUILD_CONSOLE=true
- break
- fi
- done
-
- # Check if any source file is newer than output
- if [ "$BUILD_CONSOLE" = false ]; then
- # Find the newest source file
- NEWEST_SOURCE=$(find src lib -name "*.ts" -o -name "*.tsx" | xargs ls -t
2>/dev/null | head -1)
- if [ -n "$NEWEST_SOURCE" ] && is_newer_than "$NEWEST_SOURCE"
"$CONSOLE_OUTPUT"; then
- BUILD_CONSOLE=true
- fi
- fi
-fi
-
-if [ "$BUILD_CONSOLE" = true ]; then
- echo "Webpacking everything..."
- NODE_ENV=production ./node_modules/.bin/webpack -c webpack.config.mjs
--mode=production
- echo "Web console build finished."
-else
- echo "Web console is up to date, skipping webpack..."
-fi
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]