Merge pull request #18229 from thedtripp/feature/installShellcheckBackport3.5

etcd 3.5: Install shellcheck if not exists.
This commit is contained in:
James Blair 2024-06-28 21:28:02 +12:00 committed by GitHub
commit 8fde09b634
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 24 additions and 2 deletions

View File

@ -37,6 +37,7 @@ 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-*" | $(XARGS)
docker-clean:

25
test.sh
View File

@ -50,6 +50,7 @@ source ./build.sh
PASSES=${PASSES:-"fmt bom dep build unit"}
PKG=${PKG:-}
SHELLCHECK_VERSION=${SHELLCHECK_VERSION:-"v0.10.0"}
if [ -z "${GOARCH:-}" ]; then
GOARCH=$(go env GOARCH);
@ -393,9 +394,29 @@ function fmt_pass {
}
function shellcheck_pass {
if tool_exists "shellcheck" "https://github.com/koalaman/shellcheck#installing"; then
generic_checker run shellcheck -fgcc build test scripts/*.sh ./*.sh
SHELLCHECK=shellcheck
if ! tool_exists "shellcheck" "https://github.com/koalaman/shellcheck#installing"; then
log_callout "Installing shellcheck $SHELLCHECK_VERSION"
if [ "$GOARCH" == "amd64" ]; then
URL="https://github.com/koalaman/shellcheck/releases/download/${SHELLCHECK_VERSION}/shellcheck-${SHELLCHECK_VERSION}.linux.x86_64.tar.xz"
elif [[ "$GOARCH" == "arm" || "$GOARCH" == "arm64" ]]; then
URL="https://github.com/koalaman/shellcheck/releases/download/${SHELLCHECK_VERSION}/shellcheck-${SHELLCHECK_VERSION}.linux.aarch64.tar.xz"
else
echo "Unsupported architecture: $GOARCH"
exit 1
fi
wget -qO- "$URL" | tar -xJv -C /tmp/ --strip-components=1
mkdir -p ./bin
mv /tmp/shellcheck ./bin/
SHELLCHECK=./bin/shellcheck
fi
echo "Running shellcheck with $SHELLCHECK"
generic_checker run ${SHELLCHECK} -fgcc build test scripts/*.sh ./*.sh
}
function shellws_pass {