From 37dd47ff0a8f13671a56f9240359d8320298c4d0 Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Tue, 1 Nov 2022 11:22:07 +0000 Subject: [PATCH] repo: Shellcheck cleanups Signed-off-by: Ryan Northey --- bazelw | 3 ++- ci/linux_ci_setup.sh | 8 +++++--- ci/mac_ci_setup.sh | 4 ++-- ci/mac_start_emulator.sh | 12 ++++++++---- ci/test_size_regression.sh | 6 +++--- docs/build.sh | 1 + docs/publish.sh | 2 +- tools/bump_lyft_support_rotation.sh | 4 ++-- tools/check_format.sh | 2 +- 9 files changed, 25 insertions(+), 17 deletions(-) diff --git a/bazelw b/bazelw index 9347022cc9..6a67bcef3f 100755 --- a/bazelw +++ b/bazelw @@ -10,7 +10,8 @@ else readonly bazel_os="linux" fi -readonly raw_arch="$(uname -m)" +raw_arch="$(uname -m)" +readonly raw_arch if [[ "$raw_arch" == "aarch64" || "$raw_arch" == "arm64" ]]; then readonly bazel_arch="arm64" else diff --git a/ci/linux_ci_setup.sh b/ci/linux_ci_setup.sh index 8712662569..cb93cac12a 100755 --- a/ci/linux_ci_setup.sh +++ b/ci/linux_ci_setup.sh @@ -24,6 +24,8 @@ echo "y" | $SDKMANAGER --install "ndk;21.4.7075529" $SDKMANAGER --install "platforms;android-30" $SDKMANAGER --install "build-tools;30.0.2" -echo "ANDROID_HOME=$ANDROID_HOME" >> $GITHUB_ENV -echo "ANDROID_SDK_ROOT=$ANDROID_HOME" >> $GITHUB_ENV -echo "ANDROID_NDK_HOME=$ANDROID_HOME/ndk/21.4.7075529" >> $GITHUB_ENV +{ + echo "ANDROID_HOME=${ANDROID_HOME}" + echo "ANDROID_SDK_ROOT=${ANDROID_HOME}" + echo "ANDROID_NDK_HOME=${ANDROID_HOME}/ndk/21.4.7075529" +} >> "$GITHUB_ENV" diff --git a/ci/mac_ci_setup.sh b/ci/mac_ci_setup.sh index a0d908fc21..953a08d24d 100755 --- a/ci/mac_ci_setup.sh +++ b/ci/mac_ci_setup.sh @@ -54,9 +54,9 @@ if [[ "${1:-}" == "--android" ]]; then SDKMANAGER="${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager" $SDKMANAGER --uninstall "ndk-bundle" echo "y" | $SDKMANAGER "ndk;21.4.7075529" - ln -sfn $ANDROID_SDK_ROOT/ndk/21.4.7075529 "${ANDROID_SDK_ROOT}/ndk-bundle" + ln -sfn "${ANDROID_SDK_ROOT}/ndk/21.4.7075529" "${ANDROID_SDK_ROOT}/ndk-bundle" # Download and set up build-tools 30.0.3, 31.0.0 is missing dx.jar. $SDKMANAGER --install "build-tools;30.0.3" - echo "ANDROID_NDK_HOME=$ANDROID_HOME/ndk/21.4.7075529" >> $GITHUB_ENV + echo "ANDROID_NDK_HOME=${ANDROID_HOME}/ndk/21.4.7075529" >> "$GITHUB_ENV" fi diff --git a/ci/mac_start_emulator.sh b/ci/mac_start_emulator.sh index c4d85a4a0c..ea9f633e13 100755 --- a/ci/mac_start_emulator.sh +++ b/ci/mac_start_emulator.sh @@ -2,7 +2,11 @@ set -e -echo "y" | $ANDROID_HOME/tools/bin/sdkmanager --install 'system-images;android-29;google_apis;x86_64' --channel=3 -echo "no" | $ANDROID_HOME/tools/bin/avdmanager create avd -n test_android_emulator -k 'system-images;android-29;google_apis;x86_64' --force -ls $ANDROID_HOME/tools/bin/ -nohup $ANDROID_HOME/emulator/emulator -partition-size 1024 -avd test_android_emulator -no-snapshot > /dev/null 2>&1 & $ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed | tr -d '\r') ]]; do sleep 1; done; input keyevent 82' +echo "y" | "${ANDROID_HOME}/tools/bin/sdkmanager" --install 'system-images;android-29;google_apis;x86_64' --channel=3 +echo "no" | "${ANDROID_HOME}/tools/bin/avdmanager" create avd -n test_android_emulator -k 'system-images;android-29;google_apis;x86_64' --force +ls "${ANDROID_HOME}/tools/bin/" + +nohup "${ANDROID_HOME}/emulator/emulator" -partition-size 1024 -avd test_android_emulator -no-snapshot > /dev/null 2>&1 & { + # shellcheck disable=SC2016 + "${ANDROID_HOME}/platform-tools/adb" wait-for-device shell 'while [[ -z $(getprop sys.boot_completed | tr -d '\''\r'\'') ]]; do sleep 1; done; input keyevent 82' +} diff --git a/ci/test_size_regression.sh b/ci/test_size_regression.sh index 43ea094aae..d5b03618a8 100755 --- a/ci/test_size_regression.sh +++ b/ci/test_size_regression.sh @@ -5,7 +5,7 @@ MAX_SIZE=7300000 # 7.3MB MAX_PERC=2.0 -if [ `uname` == "Darwin" ] +if [ "$(uname)" == "Darwin" ] then SIZE1=$(stat -f "%z" "$1") SIZE2=$(stat -f "%z" "$2") @@ -18,13 +18,13 @@ PERC=$(bc <<< "scale=2; ($SIZE2 - $SIZE1)/$SIZE1 * 100") echo "The new binary is $PERC % different in size compared to main." echo "The new binary is $SIZE2 bytes." -if [ $SIZE2 -gt $MAX_SIZE ] +if [ "$SIZE2" -gt $MAX_SIZE ] then echo "The current size ($SIZE2) is larger than the maximum size ($MAX_SIZE)." exit 1 fi -if [ $(bc <<< "scale=2; $PERC >= $MAX_PERC") -eq 1 ] +if [ "$(bc <<< "scale=2; $PERC >= $MAX_PERC")" -eq 1 ] then echo "The percentage increase ($PERC) is larger then the maximum percentage increase ($MAX_PERC)." exit 1 diff --git a/docs/build.sh b/docs/build.sh index c2e02e8cce..bb3ded52b0 100755 --- a/docs/build.sh +++ b/docs/build.sh @@ -2,6 +2,7 @@ set -e +# shellcheck disable=SC1091 . envoy/tools/shell_utils.sh # We need to set ENVOY_DOCS_VERSION_STRING and ENVOY_DOCS_RELEASE_LEVEL for Sphinx. diff --git a/docs/publish.sh b/docs/publish.sh index 7eb52fb66f..5212617416 100755 --- a/docs/publish.sh +++ b/docs/publish.sh @@ -11,7 +11,7 @@ set -e DOCS_DIR=generated/docs CHECKOUT_DIR=../envoy-mobile-docs -BUILD_SHA=`git rev-parse HEAD` +BUILD_SHA="$(git rev-parse HEAD)" if [ -n "$CIRCLE_TAG" ] then diff --git a/tools/bump_lyft_support_rotation.sh b/tools/bump_lyft_support_rotation.sh index 1b79902750..2b8775f1e2 100755 --- a/tools/bump_lyft_support_rotation.sh +++ b/tools/bump_lyft_support_rotation.sh @@ -48,7 +48,7 @@ previous=${first_line#"current: "} next="$(next_maintainer "$previous" "$maintainers_file")" set_maintainer "$next" "$maintainers_file" -echo "PREVIOUS_MAINTAINER=$previous" >> $GITHUB_OUTPUT -echo "NEXT_MAINTAINER=$next" >> $GITHUB_OUTPUT +echo "PREVIOUS_MAINTAINER=$previous" >> "$GITHUB_OUTPUT" +echo "NEXT_MAINTAINER=$next" >> "$GITHUB_OUTPUT" echo "Lyft support maintainer changing from $previous to $next" diff --git a/tools/check_format.sh b/tools/check_format.sh index ed4f1bad26..b22f81754c 100755 --- a/tools/check_format.sh +++ b/tools/check_format.sh @@ -25,6 +25,6 @@ TARGET_PATH="$2" ENVOY_BAZEL_PREFIX=@envoy envoy/tools/code_format/check_format.py \ --config_path envoy/tools/code_format/config.yaml \ --add-excluded-prefixes ./envoy/ ./envoy_build_config/extensions_build_config.bzl ./WORKSPACE ./Envoy.xcodeproj/ ./dist/ ./library/common/config_template.cc ./bazel/envoy_mobile_swift_bazel_support.bzl ./bazel/envoy_mobile_repositories.bzl ./examples/swift/swiftpm/Packages/Envoy.xcframework \ - --skip_envoy_build_rule_check "$ENVOY_FORMAT_ACTION" $TARGET_PATH \ + --skip_envoy_build_rule_check "$ENVOY_FORMAT_ACTION" "$TARGET_PATH" \ --namespace_check_excluded_paths ./envoy ./examples/ ./library/java/ ./library/kotlin ./library/objective-c ./test/java ./test/java ./test/objective-c ./test/swift ./experimental/swift \ --build_fixer_check_excluded_paths ./envoy ./BUILD ./dist ./examples ./library/java ./library/kotlin ./library/objective-c ./library/swift ./library/common/extensions ./test/java ./test/kotlin ./test/objective-c ./test/swift ./experimental/swift