Skip to content

Commit

Permalink
etcd 3.5: Install shellcheck if not installed.
Browse files Browse the repository at this point in the history
Include conditional logic to install shellcheck with correct architecture.

This is based on commit 4f23883 and pull request #14872.

Signed-off-by: D Tripp <[email protected]>
  • Loading branch information
thedtripp committed Jun 27, 2024
1 parent dcd7f29 commit 31bce64
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
25 changes: 23 additions & 2 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 31bce64

Please sign in to comment.