From d792c5e2f43ae17bf3a62bd01acb9eef240d324b Mon Sep 17 00:00:00 2001 From: Morgan Rockett Date: Tue, 25 Jun 2024 23:27:57 -0400 Subject: [PATCH] style: made shell scripts all have 4 spaces for indentation; fixes #272 Signed-off-by: Morgan Rockett --- scripts/install-build-tools.sh | 47 +++++++++++++++++---------------- scripts/lint.sh | 20 +++++++------- scripts/setup-dependencies.sh | 48 +++++++++++++++++----------------- scripts/test-e2e-minikube.sh | 14 +++++----- 4 files changed, 65 insertions(+), 64 deletions(-) diff --git a/scripts/install-build-tools.sh b/scripts/install-build-tools.sh index 5a96b4286..592e8929b 100755 --- a/scripts/install-build-tools.sh +++ b/scripts/install-build-tools.sh @@ -15,34 +15,35 @@ if (( $EUID != 0 )); then fi if [[ "$OSTYPE" == "darwin"* ]]; then - CPUS=$(sysctl -n hw.ncpu) - # ensure development environment is set correctly for clang - $SUDO xcode-select -switch /Library/Developer/CommandLineTools - brew install llvm@14 googletest google-benchmark lcov make wget cmake curl - CLANG_TIDY=/usr/local/bin/clang-tidy - if [ ! -L "$CLANG_TIDY" ]; then - $SUDO ln -s $(brew --prefix)/opt/llvm@14/bin/clang-tidy /usr/local/bin/clang-tidy - fi - GMAKE=/usr/local/bin/gmake - if [ ! -L "$GMAKE" ]; then - $SUDO ln -s $(xcode-select -p)/usr/bin/gnumake /usr/local/bin/gmake - fi + CPUS=$(sysctl -n hw.ncpu) + # ensure development environment is set correctly for clang + $SUDO xcode-select -switch /Library/Developer/CommandLineTools + brew install llvm@14 googletest google-benchmark lcov make wget cmake curl + CLANG_TIDY=/usr/local/bin/clang-tidy + if [ ! -L "$CLANG_TIDY" ]; then + $SUDO ln -s $(brew --prefix)/opt/llvm@14/bin/clang-tidy /usr/local/bin/clang-tidy + fi + + GMAKE=/usr/local/bin/gmake + if [ ! -L "$GMAKE" ]; then + $SUDO ln -s $(xcode-select -p)/usr/bin/gnumake /usr/local/bin/gmake + fi fi if [[ "$OSTYPE" == "linux-gnu"* ]]; then - $SUDO apt update - $SUDO apt install -y build-essential wget cmake libgtest-dev libbenchmark-dev lcov git software-properties-common rsync unzip - - wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | $SUDO apt-key add - - $SUDO add-apt-repository "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main" - $SUDO apt install -y clang-format-14 clang-tidy-14 - $SUDO ln -s -f $(which clang-format-14) /usr/local/bin/clang-format - $SUDO ln -s -f $(which clang-tidy-14) /usr/local/bin/clang-tidy + $SUDO apt update + $SUDO apt install -y build-essential wget cmake libgtest-dev libbenchmark-dev lcov git software-properties-common rsync unzip + + wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | $SUDO apt-key add - + $SUDO add-apt-repository "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main" + $SUDO apt install -y clang-format-14 clang-tidy-14 + $SUDO ln -s -f $(which clang-format-14) /usr/local/bin/clang-format + $SUDO ln -s -f $(which clang-tidy-14) /usr/local/bin/clang-tidy fi PYTHON_TIDY=/usr/local/bin/run-clang-tidy.py if [ ! -f "${PYTHON_TIDY}" ]; then - echo -e "${green}Copying run-clang-tidy to /usr/local/bin${end}" - wget https://raw.githubusercontent.com/llvm/llvm-project/e837ce2a32369b2e9e8e5d60270c072c7dd63827/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py - $SUDO mv run-clang-tidy.py /usr/local/bin + echo -e "${green}Copying run-clang-tidy to /usr/local/bin${end}" + wget https://raw.githubusercontent.com/llvm/llvm-project/e837ce2a32369b2e9e8e5d60270c072c7dd63827/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py + $SUDO mv run-clang-tidy.py /usr/local/bin fi diff --git a/scripts/lint.sh b/scripts/lint.sh index 515ac57b1..dbabe0ce1 100755 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -21,7 +21,7 @@ if [ -n "$newline_files" ] ; then fi if [ -n "$whitespace_files" ] || [ -n "$newline_files" ] ; then - exit 1 + exit 1 fi check_format_files=$(git ls-files | grep -E "tools|tests|src|cmake-tests" \ @@ -29,18 +29,18 @@ check_format_files=$(git ls-files | grep -E "tools|tests|src|cmake-tests" \ clang-format --style=file --Werror --dry-run ${check_format_files[@]} if ! command -v clang-tidy &>/dev/null; then - echo "clang-tidy does not appear to be installed" - echo "Please run ./scripts/setup-dependencies.sh to install dependencies or install manually." - exit 1 + echo "clang-tidy does not appear to be installed" + echo "Please run ./scripts/setup-dependencies.sh to install dependencies or install manually." + exit 1 fi if [ -z ${BUILD_DIR+x} ]; then - echo "BUILD_DIR environment variable not found. Assuming default: build" - export BUILD_DIR=build - if [ ! -d "${BUILD_DIR}" ]; then - echo "${BUILD_DIR} directory not found. Please set BUILD_DIR or run \`export BUILD_DIR=${BUILD_DIR}; build.sh\` before linting." - exit 1 - fi + echo "BUILD_DIR environment variable not found. Assuming default: build" + export BUILD_DIR=build + if [ ! -d "${BUILD_DIR}" ]; then + echo "${BUILD_DIR} directory not found. Please set BUILD_DIR or run \`export BUILD_DIR=${BUILD_DIR}; build.sh\` before linting." + exit 1 + fi fi python3 /usr/local/bin/run-clang-tidy.py -p ${BUILD_DIR} "tests/.*/.*\.cpp|src/.*/.*\.cpp|tools/.*/.*\.cpp" diff --git a/scripts/setup-dependencies.sh b/scripts/setup-dependencies.sh index 620eae75c..1dfdf50a7 100755 --- a/scripts/setup-dependencies.sh +++ b/scripts/setup-dependencies.sh @@ -17,14 +17,14 @@ mkdir -p $PREFIX $PREFIX/lib $PREFIX/include CMAKE_BUILD_TYPE="Debug" if [[ "$BUILD_RELEASE" == "1" ]]; then - CMAKE_BUILD_TYPE="Release" + CMAKE_BUILD_TYPE="Release" fi CPUS=1 if [[ "$OSTYPE" == "linux-gnu"* ]]; then - CPUS=$(grep -c ^processor /proc/cpuinfo) + CPUS=$(grep -c ^processor /proc/cpuinfo) elif [[ "$OSTYPE" == "darwin"* ]]; then - CPUS=$(sysctl -n hw.ncpu) + CPUS=$(sysctl -n hw.ncpu) fi LEVELDB_VERSION="1.23" @@ -50,12 +50,12 @@ mv NuRaft-${NURAFT_VERSION} "NuRaft-${NURAFT_VERSION}-${CMAKE_BUILD_TYPE}" cd "NuRaft-${NURAFT_VERSION}-${CMAKE_BUILD_TYPE}" ./prepare.sh if [[ "$BUILD_RELEASE" == "1" ]]; then - # If we're doing a release build, remove the examples and tests - rm -rf examples tests - mkdir examples - mkdir tests - touch examples/CMakeLists.txt - touch tests/CMakeLists.txt + # If we're doing a release build, remove the examples and tests + rm -rf examples tests + mkdir examples + mkdir tests + touch examples/CMakeLists.txt + touch tests/CMakeLists.txt fi mkdir -p build cd build @@ -78,18 +78,18 @@ make INSTALL_TOP=$PREFIX install cd .. if [[ "$OSTYPE" != "darwin"* ]]; then - # For Mac Silicon: this curl install creates problems for building tools/bench/parsec/evm/ - CURL_VERSION="7.83.1" - wget https://curl.se/download/curl-${CURL_VERSION}.tar.gz - rm -rf curl-${CURL_VERSION} - tar xzvf curl-${CURL_VERSION}.tar.gz - rm -rf curl-${CURL_VERSION}.tar.gz - mkdir -p curl-${CURL_VERSION}/build - cd curl-${CURL_VERSION}/build - ../configure --prefix="${PREFIX}" --disable-shared --without-ssl --without-libpsl --without-libidn2 --without-brotli --without-zstd --without-zlib - make -j$CPUS - make install - cd ../.. + # For Mac Silicon: this curl install creates problems for building tools/bench/parsec/evm/ + CURL_VERSION="7.83.1" + wget https://curl.se/download/curl-${CURL_VERSION}.tar.gz + rm -rf curl-${CURL_VERSION} + tar xzvf curl-${CURL_VERSION}.tar.gz + rm -rf curl-${CURL_VERSION}.tar.gz + mkdir -p curl-${CURL_VERSION}/build + cd curl-${CURL_VERSION}/build + ../configure --prefix="${PREFIX}" --disable-shared --without-ssl --without-libpsl --without-libidn2 --without-brotli --without-zstd --without-zlib + make -j$CPUS + make install + cd ../.. fi JSONCPP_VERSION="1.9.5" @@ -130,10 +130,10 @@ rm -rf evmc mv ../evmc-${EVMC_VER} ./evmc mkdir ./evmc/.git if [[ "$OSTYPE" == "darwin"* ]]; then - # Mac Silicon: clang 'ar' does not allow empty member list, fails w/ -DBUILD_SHARED_LIBS=OFF - cmake -S . -B build -DCMAKE_INSTALL_PREFIX="${PREFIX}" + # Mac Silicon: clang 'ar' does not allow empty member list, fails w/ -DBUILD_SHARED_LIBS=OFF + cmake -S . -B build -DCMAKE_INSTALL_PREFIX="${PREFIX}" else - cmake -S . -B build -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX="${PREFIX}" + cmake -S . -B build -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX="${PREFIX}" fi cmake --build build --parallel cd build diff --git a/scripts/test-e2e-minikube.sh b/scripts/test-e2e-minikube.sh index e4135bc5b..d25900163 100755 --- a/scripts/test-e2e-minikube.sh +++ b/scripts/test-e2e-minikube.sh @@ -8,19 +8,19 @@ BUILD_DOCKER=${TESTRUN_BUILD_DOCKER:-1} # Make sure we have the necessary tools installed required_executables=(minikube docker go helm kubectl) for e in ${required_executables[@]}; do - if ! command -v $e &> /dev/null; then - echo "'$e' command not be found! This is required to run. Please install it." - exit 1 - fi + if ! command -v $e &> /dev/null; then + echo "'$e' command not be found! This is required to run. Please install it." + exit 1 + fi done # Start minikube cluster with opencbdc profile minikube_status=$(minikube -p $MINIKUBE_PROFILE status | grep apiserver | awk '{ print $2 }') if [ "$minikube_status" != "Running" ]; then - echo "🔄 Starting minkube cluster with profile '$MINIKUBE_PROFILE'..." - minikube -p $MINIKUBE_PROFILE start + echo "🔄 Starting minkube cluster with profile '$MINIKUBE_PROFILE'..." + minikube -p $MINIKUBE_PROFILE start else - echo "✅ minikube cluster with profile '$MINIKUBE_PROFILE' is currently running." + echo "✅ minikube cluster with profile '$MINIKUBE_PROFILE' is currently running." fi # Update Kubernetes context to default to this minikube cluster profile