-
Notifications
You must be signed in to change notification settings - Fork 6.8k
build: create script for setting up RBE in local dev environment #16375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,3 +42,4 @@ testem.log | |
/.chrome | ||
/.git | ||
/.firebase | ||
/.bazelrc.user |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#!/bin/bash | ||
# A script for automatically configuring a user's local dev | ||
# environment to use Remote Build Execution. | ||
|
||
# Determine the root directory of the Angular github repo. | ||
github_directory_root=$(git rev-parse --show-toplevel 2> /dev/null); | ||
if [[ $? -ne 0 ]]; then | ||
echo "This command must be run from within the cloned \"angular/components\" repository." | ||
exit 1; | ||
fi | ||
|
||
# Confirm gcloud installed and available as a command. | ||
if [ ! -x "$(command -v gcloud)" ]; then | ||
echo "gcloud command is not available. Please install gcloud before continuing." | ||
exit 1; | ||
fi | ||
|
||
# Confirm the parameter provided to the script is a directory | ||
if [[ ! -d $1 ]]; then | ||
echo -e "Invalid command syntax. | ||
|
||
\e[1mUsage:\e[0m $0 <ServiceAccountKeyLocation> | ||
|
||
\e[1mExample:\e[0m ./setup-rbe ~/my_key_storage_directory/ | ||
|
||
The directory provided will be used to store the GCP service account key | ||
for the angular-local-dev service account. This key will then be used to | ||
authenticate for usage of the Remote Build Execution system and Remote Caching. | ||
"; | ||
exit 1; | ||
fi | ||
credentials_directory=$(readlink -f $1) | ||
if [[ ! -d $credentials_directory ]]; then | ||
echo "Can't find the absolute directory path" | ||
exit 1; | ||
fi | ||
|
||
# Create the service account key in the provided directory. | ||
echo "Checking provided directory for a service account key." | ||
json_key_filepath="$credentials_directory/angular-local-dev-key.json"; | ||
if [[ -f $json_key_filepath ]]; then | ||
echo "Angular Local Dev key already exists, reusing this key." | ||
else | ||
# Confirm the user is already logged into gcloud, if they aren't | ||
# attempt to login | ||
echo "Checking gcloud login state." | ||
gcloud auth print-identity-token &> /dev/null; | ||
if [[ $? -ne 0 ]]; then | ||
echo "Not currently logged into gcloud. Starting gcloud login now." | ||
gcloud auth login; | ||
if [[ $? -ne 0 ]]; then | ||
echo "gcloud login failed. Aborting."; | ||
exit 2 | ||
fi | ||
fi | ||
gcloud iam service-accounts keys create $json_key_filepath \ | ||
--iam-account angular-local-dev@internal-200822.iam.gserviceaccount.com \ | ||
--quiet --verbosity none --project internal-200822; | ||
echo $?; | ||
if [[ $? -ne 0 ]]; then | ||
echo "Downloading service account key failed. Aborting." | ||
exit 2; | ||
fi | ||
fi | ||
|
||
# The full path to the .bazelrc.user file | ||
bazelrc_user_filepath="$github_directory_root/.bazelrc.user"; | ||
# Create the bazelrc.user file, echo the config flags into the file. | ||
touch $bazelrc_user_filepath; | ||
echo "build --config=remote" >> $bazelrc_user_filepath; | ||
echo "build --google_credentials=$json_key_filepath" >> $bazelrc_user_filepath; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this script install
gcloud
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't install
gcloud
because dependent on your platform we have to install it differently.