Repository: envoyproxy/envoy
File: ci/do_ci.sh (Shell)

Code before:
CI_TARGET=$1

# shellcheck source=ci/build_setup.sh
. "${CURRENT_SCRIPT_DIR}"/build_setup.sh

echo "building for ${ENVOY_BUILD_ARCH}"

cd "${SRCDIR}"

if [[ "${ENVOY_BUILD_ARCH}" == "x86_64" ]]; then
  BUILD_ARCH_DIR="/linux/amd64"
elif [[ "${ENVOY_BUILD_ARCH}" == "aarch64" ]]; then
  BUILD_ARCH_DIR="/linux/arm64"
else
  # Fall back to use the ENVOY_BUILD_ARCH itself.
  BUILD_ARCH_DIR="/linux/${ENVOY_BUILD_ARCH}"
fi

ENVOY_DOCS_PATH="${ENVOY_DOCS_PATH:-./docs}"
# We use a portable realpath alternative here since macOS realpath
# does not support -m.
if [[ -d "$ENVOY_DOCS_PATH" ]]; then
  ENVOY_DOCS_PATH="$(cd "$ENVOY_DOCS_PATH" && pwd)"
elif [[ "$ENVOY_DOCS_PATH" != /* ]]; then
  ENVOY_DOCS_PATH="${PWD}/${ENVOY_DOCS_PATH}"
fi

setup_clang_toolchain() {
    local config
    if [[ -n "${CLANG_TOOLCHAIN_SETUP}" ]]; then
        return
    fi
    config="clang"
    # We only support clang with libc++ now
    BAZEL_QUERY_OPTIONS=("${BAZEL_GLOBAL_OPTIONS[@]}" "--config=${config}")
    BAZEL_QUERY_OPTION_LIST="${BAZEL_QUERY_OPTIONS[*]}"
    BAZEL_BUILD_OPTIONS+=("--config=${config}")
    BAZEL_BUILD_OPTION_LIST="${BAZEL_BUILD_OPTIONS[*]}"
    export BAZEL_BUILD_OPTION_LIST
    export BAZEL_QUERY_OPTION_LIST
    echo "clang toolchain configured: ${config}"
}

function collect_build_profile() {
    local output_base
    declare -g build_profile_count=${build_profile_count:-1}
    output_base="$(bazel info "${BAZEL_BUILD_OPTIONS[@]}" output_base)"
    mv -f \
       "${output_base}/command.profile.gz" \
       "${ENVOY_BUILD_PROFILE}/${build_profile_count}-$1.profile.gz" \
        || :

Review comment (suggestion):
```suggestion
if [[ -d "$ENVOY_DOCS_PATH" ]]; then
  ENVOY_DOCS_PATH="$(cd "$ENVOY_DOCS_PATH" && pwd)"
elif [[ "$ENVOY_DOCS_PATH" != /* ]]; then
  ENVOY_DOCS_PATH="${PWD}/${ENVOY_DOCS_PATH}"
fi
```

Code after:
CI_TARGET=$1

# shellcheck source=ci/build_setup.sh
. "${CURRENT_SCRIPT_DIR}"/build_setup.sh

echo "building for ${ENVOY_BUILD_ARCH}"

cd "${SRCDIR}"

if [[ "${ENVOY_BUILD_ARCH}" == "x86_64" ]]; then
  BUILD_ARCH_DIR="/linux/amd64"
elif [[ "${ENVOY_BUILD_ARCH}" == "aarch64" ]]; then
  BUILD_ARCH_DIR="/linux/arm64"
else
  # Fall back to use the ENVOY_BUILD_ARCH itself.
  BUILD_ARCH_DIR="/linux/${ENVOY_BUILD_ARCH}"
fi

# Portable realpath alternative since macOS realpath does not support -m.
_realpath() {
    local path="$1"
    if [[ -d "$path" ]]; then
        cd "$path" && pwd
    elif [[ "$path" != /* ]]; then
        echo "${PWD}/${path}"
    else
        echo "$path"
    fi
}

ENVOY_DOCS_PATH="${ENVOY_DOCS_PATH:-./docs}"
ENVOY_DOCS_PATH="$(_realpath "$ENVOY_DOCS_PATH")"

setup_clang_toolchain() {
    local config
    if [[ -n "${CLANG_TOOLCHAIN_SETUP}" ]]; then
        return
    fi
    config="clang"
    # We only support clang with libc++ now
    BAZEL_QUERY_OPTIONS=("${BAZEL_GLOBAL_OPTIONS[@]}" "--config=${config}")
    BAZEL_QUERY_OPTION_LIST="${BAZEL_QUERY_OPTIONS[*]}"
    BAZEL_BUILD_OPTIONS+=("--config=${config}")
    BAZEL_BUILD_OPTION_LIST="${BAZEL_BUILD_OPTIONS[*]}"
    export BAZEL_BUILD_OPTION_LIST
    export BAZEL_QUERY_OPTION_LIST
    echo "clang toolchain configured: ${config}"
}

function collect_build_profile() {
    local output_base