From 4f238837aa1945919b197f300fe7fe244eac4d8c Mon Sep 17 00:00:00 2001 From: "guiyong.ou" Date: Mon, 5 Dec 2022 10:55:57 +0800 Subject: [PATCH] Make sure shellcheck exist Signed-off-by: guiyong.ou --- Makefile | 1 + scripts/test.sh | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 1f0cfba4c..1044e7769 100644 --- a/Makefile +++ b/Makefile @@ -141,4 +141,5 @@ clean: rm -rf ./release rm -rf ./coverage/*.err ./coverage/*.out rm -rf ./tests/e2e/default.proxy + rm -rf ./bin/shellcheck* find ./ -name "127.0.0.1:*" -o -name "localhost:*" -o -name "*.log" -o -name "agent-*" -o -name "*.coverprofile" -o -name "testname-proxy-*" -delete diff --git a/scripts/test.sh b/scripts/test.sh index f1d4df207..c71560713 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -53,6 +53,7 @@ fi PASSES=${PASSES:-"fmt bom dep build unit"} PKG=${PKG:-} +SHELLCHECK_VERSION=${SHELLCHECK_VERSION:-"v0.8.0"} if [ -z "$GOARCH" ]; then GOARCH=$(go env GOARCH); @@ -388,9 +389,15 @@ function cov_pass { ######### Code formatting checkers ############################################# function shellcheck_pass { - if tool_exists "shellcheck" "https://github.com/koalaman/shellcheck#installing"; then - generic_checker run shellcheck -fgcc scripts/*.sh + SHELLCHECK=shellcheck + if ! tool_exists "shellcheck" "https://github.com/koalaman/shellcheck#installing"; then + log_callout "Installing shellcheck $SHELLCHECK_VERSION" + wget -qO- "https://github.com/koalaman/shellcheck/releases/download/${SHELLCHECK_VERSION}/shellcheck-${SHELLCHECK_VERSION}.linux.x86_64.tar.xz" | tar -xJv -C /tmp/ --strip-components=1 + mkdir -p ./bin + mv /tmp/shellcheck ./bin/ + SHELLCHECK=./bin/shellcheck fi + generic_checker run ${SHELLCHECK} -fgcc scripts/*.sh } function shellws_pass {