etcd 3.4: Install revive linter on CI if not installed.

This is based on commit 4f238837aa and pull request https://github.com/etcd-io/etcd/pull/14872.

Signed-off-by: D Tripp <38776199+thedtripp@users.noreply.github.com>
This commit is contained in:
D Tripp 2024-06-30 03:47:27 +00:00
parent f4e506aa24
commit 640e54552a
2 changed files with 23 additions and 2 deletions

View File

@ -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

24
test
View File

@ -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
@ -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