Skip to content

Commit

Permalink
workspace status
Browse files Browse the repository at this point in the history
  • Loading branch information
tinder-maxwellelliott committed Oct 23, 2024
1 parent 72d5a1e commit 52849b8
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ build:bb --bes_results_url=https://app.buildbuddy.io/invocation/
build:bb --bes_backend=grpcs://remote.buildbuddy.io
build:bb --remote_cache=grpcs://remote.buildbuddy.io
build:bb --remote_timeout=3600
build:bb --workspace_status_command=$(pwd)/workspace_status.sh

run -c opt --show_loading_progress=false --show_progress=false --ui_event_filters=error
run:verbose -c dbg --show_loading_progress=true --show_progress=true --ui_event_filters=info,error,debug
Expand Down
36 changes: 36 additions & 0 deletions workspace_status.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

# This script will be run bazel when building process starts to
# generate key-value information that represents the status of the
# workspace. The output should be like
#
# KEY1 VALUE1
# KEY2 VALUE2
#
# If the script exits with non-zero code, it's considered as a failure
# and the output will be discarded.

set -eo pipefail # exit immediately if any command fails.

function remove_url_credentials() {
which perl >/dev/null && perl -pe 's#//.*?:.*?@#//#' || cat
}

repo_url=$(git config --get remote.origin.url | remove_url_credentials)
echo "REPO_URL $repo_url"

commit_sha=$(git rev-parse HEAD)
echo "COMMIT_SHA $commit_sha"

git_branch=$(git rev-parse --abbrev-ref HEAD)
echo "GIT_BRANCH $git_branch"

git_tree_status=$(git diff-index --quiet HEAD -- && echo 'Clean' || echo 'Modified')
echo "GIT_TREE_STATUS $git_tree_status"

# Note: the "STABLE_" suffix causes these to be part of the "stable" workspace
# status, which may trigger rebuilds of certain targets if these values change
# and you're building with the "--stamp" flag.
latest_version_tag=$(./tools/latest_version_tag.sh)
echo "STABLE_VERSION_TAG $latest_version_tag"
echo "STABLE_COMMIT_SHA $commit_sha

0 comments on commit 52849b8

Please sign in to comment.