diff --git a/tools/pre_commit/shellcheck.baseline b/tools/pre_commit/shellcheck.baseline new file mode 100644 index 000000000..7433bb331 --- /dev/null +++ b/tools/pre_commit/shellcheck.baseline @@ -0,0 +1,89 @@ +benchmarks/auto_tune/auto_tune.sh:SC2034 +benchmarks/auto_tune/auto_tune.sh:SC2086 +benchmarks/auto_tune/batch_auto_tune.sh:SC2086 +benchmarks/run_structured_output_benchmark.sh:SC2028 +benchmarks/run_structured_output_benchmark.sh:SC2034 +benchmarks/run_structured_output_benchmark.sh:SC2086 +.buildkite/image_build/image_build_cpu_arm64.sh:SC2086 +.buildkite/image_build/image_build_cpu.sh:SC2086 +.buildkite/image_build/image_build_hpu.sh:SC2086 +.buildkite/lm-eval-harness/run-lm-eval-chartqa-vllm-vlm-baseline.sh:SC2086 +.buildkite/lm-eval-harness/run-lm-eval-mmlupro-vllm-baseline.sh:SC2034 +.buildkite/performance-benchmarks/scripts/run-performance-benchmarks.sh:SC2027 +.buildkite/performance-benchmarks/scripts/run-performance-benchmarks.sh:SC2086 +.buildkite/performance-benchmarks/scripts/run-performance-benchmarks.sh:SC2126 +.buildkite/scripts/annotate-rocm-release.sh:SC2086 +.buildkite/scripts/cache-rocm-base-wheels.sh:SC2012 +.buildkite/scripts/cherry-pick-from-milestone.sh:SC2064 +.buildkite/scripts/hardware_ci/run-cpu-test-ppc64le.sh:SC2086 +.buildkite/scripts/hardware_ci/run-cpu-test.sh:SC2086 +.buildkite/scripts/hardware_ci/run-hpu-test.sh:SC2086 +.buildkite/scripts/hardware_ci/run-npu-test.sh:SC1090 +.buildkite/scripts/hardware_ci/run-npu-test.sh:SC2006 +.buildkite/scripts/hardware_ci/run-npu-test.sh:SC2086 +.buildkite/scripts/hardware_ci/run-npu-test.sh:SC2181 +.buildkite/scripts/hardware_ci/run-xpu-test.sh:SC2086 +.buildkite/scripts/push-nightly-builds.sh:SC2086 +.buildkite/scripts/run-multi-node-test.sh:SC2086 +.buildkite/scripts/run-multi-node-test.sh:SC2089 +.buildkite/scripts/run-multi-node-test.sh:SC2090 +.buildkite/scripts/run-prime-rl-test.sh:SC2086 +.buildkite/scripts/scheduled_integration_test/deepseek_v2_lite_ep_eplb.sh:SC2086 +.buildkite/scripts/scheduled_integration_test/qwen30b_a3b_fp8_block_ep_eplb.sh:SC2086 +.buildkite/scripts/scheduled_integration_test/qwen3_next_mtp_async_eplb.sh:SC2086 +.buildkite/scripts/tpu/docker_run_bm.sh:SC1090 +.buildkite/scripts/tpu/docker_run_bm.sh:SC2086 +.buildkite/scripts/tpu/run_bm.sh:SC2034 +.buildkite/scripts/tpu/run_bm.sh:SC2086 +.buildkite/scripts/upload-nightly-wheels.sh:SC2086 +.buildkite/scripts/upload-nightly-wheels.sh:SC2115 +.buildkite/scripts/upload-nightly-wheels.sh:SC2236 +.buildkite/scripts/upload-release-wheels-pypi.sh:SC2086 +.buildkite/scripts/upload-rocm-wheels.sh:SC2012 +examples/online_serving/disaggregated_encoder/disagg_1e1p1d_example.sh:SC2086 +examples/online_serving/disaggregated_encoder/disagg_1e1pd_example.sh:SC2086 +examples/online_serving/disaggregated_prefill.sh:SC2086 +examples/online_serving/disaggregated_serving/kv_events.sh:SC2086 +examples/online_serving/disaggregated_serving/mooncake_connector/run_mooncake_connector.sh:SC2046 +examples/online_serving/disaggregated_serving/mooncake_connector/run_mooncake_connector.sh:SC2086 +examples/online_serving/disaggregated_serving/mooncake_connector/run_mooncake_connector.sh:SC2317 +examples/online_serving/disaggregated_serving_p2p_nccl_xpyd/disagg_example_p2p_nccl_xpyd.sh:SC2046 +examples/online_serving/disaggregated_serving_p2p_nccl_xpyd/disagg_example_p2p_nccl_xpyd.sh:SC2086 +examples/online_serving/disaggregated_serving_p2p_nccl_xpyd/disagg_example_p2p_nccl_xpyd.sh:SC2317 +examples/online_serving/elastic_ep/bench.sh:SC2086 +examples/online_serving/elastic_ep/serve_deepseek_v2.sh:SC2086 +examples/online_serving/multi-node-serving.sh:SC2006 +examples/online_serving/multi-node-serving.sh:SC2086 +examples/online_serving/multi-node-serving.sh:SC2181 +examples/others/lmcache/disagg_prefill_lmcache_v1/disagg_example_nixl.sh:SC2046 +examples/others/lmcache/disagg_prefill_lmcache_v1/disagg_example_nixl.sh:SC2126 +examples/others/lmcache/disagg_prefill_lmcache_v1/disagg_example_nixl.sh:SC2181 +examples/others/lmcache/disagg_prefill_lmcache_v1/disagg_example_nixl.sh:SC2206 +examples/others/lmcache/disagg_prefill_lmcache_v1/disagg_vllm_launcher.sh:SC2086 +examples/pooling/embed/openai_embedding_long_text/service.sh:SC2086 +tests/standalone_tests/python_only_compile.sh:SC2086 +tests/v1/ec_connector/integration/run_epd_correctness_test.sh:SC2086 +tests/v1/kv_connector/nixl_integration/config_sweep_accuracy_test.sh:SC2086 +tests/v1/kv_connector/nixl_integration/run_accuracy_test.sh:SC2005 +tests/v1/kv_connector/nixl_integration/run_accuracy_test.sh:SC2086 +tests/v1/kv_connector/nixl_integration/run_accuracy_test.sh:SC2124 +tests/v1/kv_connector/nixl_integration/run_accuracy_test.sh:SC2126 +tests/v1/kv_connector/nixl_integration/run_accuracy_test.sh:SC2206 +tests/v1/kv_connector/nixl_integration/run_edge_case_test.sh:SC2086 +tests/v1/kv_connector/nixl_integration/run_edge_case_test.sh:SC2153 +tests/v1/kv_connector/nixl_integration/run_tpu_disagg_accuracy_test.sh:SC2086 +tests/v1/kv_connector/nixl_integration/run_tpu_disagg_accuracy_test.sh:SC2089 +tests/v1/kv_connector/nixl_integration/run_tpu_disagg_accuracy_test.sh:SC2090 +tests/v1/kv_connector/nixl_integration/run_tpu_edge_case_test.sh:SC2086 +tests/v1/kv_connector/nixl_integration/run_tpu_edge_case_test.sh:SC2089 +tests/v1/kv_connector/nixl_integration/run_tpu_edge_case_test.sh:SC2090 +tools/ep_kernels/elastic_ep/install_eep_libraries.sh:SC2086 +tools/ep_kernels/install_python_libraries.sh:SC2086 +tools/ep_kernels/install_python_libraries.sh:SC2196 +tools/flashinfer-build.sh:SC2086 +tools/flashinfer-build.sh:SC2269 +tools/install_deepgemm.sh:SC2035 +tools/install_deepgemm.sh:SC2295 +tools/pre_commit/shellcheck.sh:SC2016 +tools/vllm-rocm/generate-rocm-wheels-root-index.sh:SC2295 +tools/vllm-tpu/build.sh:SC2145 diff --git a/tools/pre_commit/shellcheck.sh b/tools/pre_commit/shellcheck.sh index 59ce40038..4adee5d57 100755 --- a/tools/pre_commit/shellcheck.sh +++ b/tools/pre_commit/shellcheck.sh @@ -1,7 +1,8 @@ #!/bin/bash -set -e +set -euo pipefail scversion="stable" +baseline="tools/pre_commit/shellcheck.baseline" if [ -d "shellcheck-${scversion}" ]; then export PATH="$PATH:$(pwd)/shellcheck-${scversion}" @@ -19,4 +20,38 @@ if ! [ -x "$(command -v shellcheck)" ]; then fi # TODO - fix warnings in .buildkite/scripts/hardware_ci/run-amd-test.sh -find . -name "*.sh" ".git" -prune -not -path "./.buildkite/scripts/hardware_ci/run-amd-test.sh" -print0 | xargs -0 -I {} sh -c 'git check-ignore -q "{}" || shellcheck -s bash "{}"' +# collects warnings as "file:SCcode" pairs for baseline comparison. +collect() { + find . -path ./.git -prune -o -name "*.sh" \ + -not -path "./.buildkite/scripts/hardware_ci/run-amd-test.sh" -print0 | \ + xargs -0 sh -c 'for f in "$@"; do git check-ignore -q "$f" || shellcheck -s bash -f gcc "$f" || true; done' -- | \ + sed -nE 's|^\./||; s|^([^:]+):[0-9]+:[0-9]+:.*\[(SC[0-9]+)\]$|\1:\2|p' | \ + sort -u +} + +if [[ "${1:-}" == "--generate-baseline" ]]; then + collect > "$baseline" + echo "Wrote baseline to $baseline" + exit 0 +fi + +if [[ ! -f "$baseline" ]]; then + echo "Baseline not found: $baseline (run: $0 --generate-baseline)" + exit 1 +fi + +current="$(mktemp)" +trap 'rm -f "$current"' EXIT +collect > "$current" + +# finds new warnings not in baseline +new_errors="$(comm -23 "$current" <(sort -u "$baseline") || true)" +if [ -n "$new_errors" ]; then + echo "$new_errors" | cut -d: -f1 | sort -u | while IFS= read -r file; do + if [[ -f "$file" ]]; then + codes=$(echo "$new_errors" | awk -F: -v f="$file" '$1==f {print $2}' | paste -sd ',' -) + shellcheck -s bash --include="$codes" "$file" 2>&1 || true + fi + done + exit 1 +fi