Skip to content

Commit

Permalink
etcd 3.4: Install revive linter on CI if not installed.
Browse files Browse the repository at this point in the history
This is based on commit thedtripp@4f23883 and pull request #14872.

Signed-off-by: D Tripp <[email protected]>
  • Loading branch information
thedtripp committed Jul 3, 2024
1 parent e3c0ac0 commit 7e9deee
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ clean:
rm -f ./clientv3/integration/127.0.0.1:* ./clientv3/integration/localhost:*
rm -f ./clientv3/ordering/127.0.0.1:* ./clientv3/ordering/localhost:*
rm -rf ./bin/shellcheck*
rm -rf ./bin/revive*

docker-clean:
docker images
Expand Down
24 changes: 22 additions & 2 deletions test
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ source ./build

PASSES=${PASSES:-}
SHELLCHECK_VERSION=${SHELLCHECK_VERSION:-"v0.10.0"}
REVIVE_VERSION=${REVIVE_VERSION:-"v1.3.7"}

# build before setting up test GOPATH
if [[ "${PASSES}" == *"functional"* ]]; then
Expand Down Expand Up @@ -543,8 +544,27 @@ function staticcheck_pass {
}

function revive_pass {
if command -v revive >/dev/null; then
reviveResult=$(revive -config ./tests/revive.toml -exclude "vendor/..." ./... 2>&1 || true)
REVIVE=revive

if ! command -v $REVIVE >/dev/null; then
echo "Installing revive $REVIVE_VERSION"
if [ "$GOARCH" == "amd64" ]; then
URL="https://github.com/mgechev/revive/releases/download/${REVIVE_VERSION}/revive_linux_amd64.tar.gz"
elif [[ "$GOARCH" == "arm" || "$GOARCH" == "arm64" ]]; then
URL="https://github.com/mgechev/revive/releases/download/${REVIVE_VERSION}/revive_linux_arm64.tar.gz"
else
echo "Unsupported architecture: $GOARCH"
exit 255
fi

wget -qO- "$URL" | tar -xzv -C /tmp/ > /dev/null
mkdir -p ./bin
mv /tmp/revive ./bin/
REVIVE=./bin/revive
fi

if command -v $REVIVE >/dev/null; then
reviveResult=$($REVIVE -config ./tests/revive.toml -exclude "vendor/..." ./... 2>&1 || true)
if [ -n "${reviveResult}" ]; then
echo -e "revive checking failed:\\n${reviveResult}"
exit 255
Expand Down

0 comments on commit 7e9deee

Please sign in to comment.