k8s.io/test-infra@v0.0.0-20240520184403-27c6b4c223d8/rbe/configure.sh (about) 1 #!/usr/bin/env bash 2 # Copyright 2019 The Kubernetes Authors. 3 # 4 # Licensed under the Apache License, Version 2.0 (the "License"); 5 # you may not use this file except in compliance with the License. 6 # You may obtain a copy of the License at 7 # 8 # http://www.apache.org/licenses/LICENSE-2.0 9 # 10 # Unless required by applicable law or agreed to in writing, software 11 # distributed under the License is distributed on an "AS IS" BASIS, 12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 # See the License for the specific language governing permissions and 14 # limitations under the License. 15 16 set -o errexit 17 set -o nounset 18 set -o pipefail 19 20 if [[ $# -lt 1 ]]; then 21 echo "Usage: $(basename "$0") <gcp-project-id>" >&2 22 exit 1 23 fi 24 proj=$1 25 26 # TODO(fejta): always enable 27 goal="build:remote-$proj --config=remote --remote_instance_name=projects/$proj/instances/default_instance" 28 29 if [[ -n "${GOOGLE_APPLICATION_CREDENTIALS:-}" ]]; then 30 echo "Application default: $GOOGLE_APPLICATION_CREDENTIALS" 31 elif [[ ! -f ~/.config/gcloud/application_default_credentials.json ]]; then 32 echo "Remote execution requires application-default credentials..." 33 ( 34 set -o xtrace 35 gcloud auth application-default login 36 ) 37 fi 38 39 echo "Add the following line to ~/.bazelrc:" 40 echo " $goal" 41 if ! grep "$goal" ~/.bazelrc &>/dev/null; then 42 read -p "Update ~/.bazelrc file [y/N]: " conf 43 case "$conf" in 44 y*|Y*) 45 ;; 46 *) 47 exit 1 48 ;; 49 esac 50 51 touch ~/.bazelrc 52 echo "$goal" >> ~/.bazelrc 53 fi 54 55 echo "Use by adding --config=remote-$proj to your bazel commands:" 56 echo " bazel test --config=remote-$proj //... # etc"