| #!/bin/bash | |
| # Copyright 2022 The Fuchsia Authors. All rights reserved. | |
| # Use of this source code is governed by a BSD-style license that can be | |
| # found in the LICENSE file. | |
| #### CATEGORY=Build | |
| #### PREBUILTS=${PREBUILT_BAZEL} ${PREBUILT_PYTHON3} ${PREBUILT_RECLIENT_DIR} | |
| ### check remote build configuration | |
| ## usage: | |
| ## fx rbe auth [options...] | |
| ## Verify authentication to RBE services through reclient and bazel. | |
| ## Options: | |
| ## -f,--force: Always request a fresh authentication token. | |
| ## -p,--profile <name>: Force-load specific profile for authentication testing. | |
| ## --no-rs,--no-resultstore: Test Bazel RBE without uploading build events to ResultStore. | |
| ## All other unknown options are forwarded to 'gcloud auth application-default login'. | |
| ## Testing tips: | |
| ## To revoke gcloud credentials: gcloud auth revoke | |
| ## To revoke ADC credentials: rm ~/.config/gcloud/application_default_credentials.json | |
| ## To revoke LOAS credentials: loas_destroy | |
| ## | |
| ## fx rbe check_loas [options...] | |
| ## For Google FTEs only. | |
| ## Reports the type of LOAS certificate as "restricted" or "unrestricted". | |
| ## Options: | |
| ## -f,--force: re-evaluate LOAS certificate type and update the | |
| ## cache file, instead of just taking the cached result. | |
| ## Use `fx-command-run rbe _check_loas_type` inside other fx scripts. | |
| ## | |
| ## fx rbe cleanlogs | |
| ## Clean up reproxy log dirs (from using fuchsia-reproxy-wrap.sh). | |
| ## | |
| ## fx rbe ensure_loas | |
| ## Checks for valid LOAS credentials, and runs gcert if needed. | |
| ## | |
| ## fx rbe ensure_oauth | |
| ## Checks for valid OAuth token, and runs gcloud auth if needed. | |
| ## | |
| ## fx rbe last_logdir | |
| ## Prints the path to the most recent RBE log dir corresponding to the | |
| ## current build output dir. If none exists, print nothing. | |
| ## | |
| ## fx rbe preflight | |
| ## Ensure credentials for using remote build services is valid, | |
| ## and prompt the user to re-auth if deemed necessary. | |
| ## | |
| ## fx rbe diagnose | |
| ## Diagnose connection and latency issues with RBE/BES services. | |
| ## | |
| ## fx rbe version | |
| ## Reports re-client version. | |
| ## | |
| ## fx rbe profile [subcommand] | |
| ## Manage the active RBE configuration profile. | |
| ## If no subcommand is given, prints the currently active profile name. | |
| ## Subcommands: | |
| ## list [-v|--verbose]: Lists all available RBE profiles. | |
| ## select <name>: Activates the profile named `<name>`. | |
| ## active [-v|--verbose]: Prints the active RBE profile name/details. | |
| set -e | |
| set -o pipefail | |
| # shellcheck source=/dev/null | |
| source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/lib/vars.sh || exit $? | |
| declare -a trace_args=() | |
| if [[ -o xtrace ]]; then | |
| trace_args=( --xtrace ) | |
| fi | |
| fx-standard-switches "$@" | |
| set -- "${FX_ARGV[@]}" | |
| if [[ $# -lt 1 ]]; then | |
| fx-error Invalid syntax | |
| fx-command-help | |
| exit 1 | |
| fi | |
| case "$1" in | |
| -h|--help) | |
| fx-command-help | |
| exit 0 | |
| ;; | |
| auth|check_loas|_check_loas_type|cleanlogs|ensure_loas|ensure_oauth|last_logdir|diagnose|preflight|profile|version) | |
| ;; | |
| *) | |
| fx-error Invalid syntax | |
| fx-command-help | |
| exit 1 | |
| ;; | |
| esac | |
| fx-build-dir-if-present || true | |
| export FUCHSIA_DIR | |
| export FUCHSIA_BUILD_DIR | |
| export CONFIG_RESULTSTORE_ENABLED | |
| export PREBUILT_BAZEL | |
| export PREBUILT_RECLIENT_DIR | |
| exec env PYTHONPATH="${FUCHSIA_DIR}" "${PREBUILT_PYTHON3}" -S \ | |
| "${FUCHSIA_DIR}/build/rbe/rbe_cli.py" \ | |
| ${trace_args[@]+"${trace_args[@]}"} "$@" |