Skip to content

Commit 3f3d99e

Browse files
Add BuildBuddy Support (#248)
* Add BuildBuddy Support Adds BuildBuddy caching and BES support * more updates * workspace status * more updates * more flags * flags
1 parent 97f4900 commit 3f3d99e

File tree

3 files changed

+54
-3
lines changed

3 files changed

+54
-3
lines changed

.bazelrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1+
build:bb --bes_results_url=https://app.buildbuddy.io/invocation/
2+
build:bb --bes_backend=grpcs://remote.buildbuddy.io
3+
build:bb --remote_cache=grpcs://remote.buildbuddy.io
4+
build:bb --remote_timeout=3600
5+
build:bb --experimental_remote_cache_compression
6+
build:bb --experimental_remote_cache_compression_threshold=100
7+
build:bb --workspace_status_command=$(pwd)/workspace_status.sh
8+
19
run -c opt --show_loading_progress=false --show_progress=false --ui_event_filters=error
210
run:verbose -c dbg --show_loading_progress=true --show_progress=true --ui_event_filters=info,error,debug
311
# https://github.com/mockito/mockito/issues/1879
412
test --sandbox_tmpfs_path=/tmp
13+
14+
try-import /tmp/bb.bazelrc

.github/workflows/ci.yaml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,12 @@ jobs:
2323
- name: Setup Bazelisk
2424
run: go install github.com/bazelbuild/bazelisk@latest && export PATH=$PATH:$(go env GOPATH)/bin
2525
- uses: actions/checkout@v4
26+
- name: Write BuildBuddy config
27+
env:
28+
BUILDBUDDY_API_KEY: ${{ secrets.BUILDBUDDY_API_KEY }}
29+
run: echo "build:bb --remote_header=x-buildbuddy-api-key=$BUILDBUDDY_API_KEY" > /tmp/bb.bazelrc
2630
- name: Run bazel-diff tests
27-
run: ~/go/bin/bazelisk coverage --combined_report=lcov //cli/... --enable_bzlmod=true
31+
run: ~/go/bin/bazelisk coverage --combined_report=lcov //cli/... --enable_bzlmod=true --config=bb
2832
test-jre21:
2933
runs-on: ubuntu-latest
3034
steps:
@@ -41,8 +45,12 @@ jobs:
4145
- name: Setup Bazelisk
4246
run: go install github.com/bazelbuild/bazelisk@latest && export PATH=$PATH:$(go env GOPATH)/bin
4347
- uses: actions/checkout@v4
48+
- name: Write BuildBuddy config
49+
env:
50+
BUILDBUDDY_API_KEY: ${{ secrets.BUILDBUDDY_API_KEY }}
51+
run: echo "build:bb --remote_header=x-buildbuddy-api-key=$BUILDBUDDY_API_KEY" > /tmp/bb.bazelrc
4452
- name: Run bazel-diff tests
45-
run: ~/go/bin/bazelisk coverage --combined_report=lcov //cli/... --enable_bzlmod=false
53+
run: ~/go/bin/bazelisk coverage --combined_report=lcov //cli/... --enable_bzlmod=false --config=bb
4654
test-jre11-run-example:
4755
runs-on: ubuntu-latest
4856
steps:
@@ -85,8 +93,12 @@ jobs:
8593
- name: Setup Bazelisk
8694
run: go install github.com/bazelbuild/bazelisk@latest && export PATH=$PATH:$(go env GOPATH)/bin
8795
- uses: actions/checkout@v4
96+
- name: Write BuildBuddy config
97+
env:
98+
BUILDBUDDY_API_KEY: ${{ secrets.BUILDBUDDY_API_KEY }}
99+
run: echo "build:bb --remote_header=x-buildbuddy-api-key=$BUILDBUDDY_API_KEY" > /tmp/bb.bazelrc
88100
- name: Build deployable JAR
89-
run: ~/go/bin/bazelisk build //cli:bazel-diff_deploy.jar
101+
run: ~/go/bin/bazelisk build //cli:bazel-diff_deploy.jar --config=bb
90102
- uses: actions/upload-artifact@v4
91103
with:
92104
name: bazel-diff_deploy.jar

workspace_status.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
3+
# This script will be run bazel when building process starts to
4+
# generate key-value information that represents the status of the
5+
# workspace. The output should be like
6+
#
7+
# KEY1 VALUE1
8+
# KEY2 VALUE2
9+
#
10+
# If the script exits with non-zero code, it's considered as a failure
11+
# and the output will be discarded.
12+
13+
set -eo pipefail # exit immediately if any command fails.
14+
15+
function remove_url_credentials() {
16+
which perl >/dev/null && perl -pe 's#//.*?:.*?@#//#' || cat
17+
}
18+
19+
repo_url=$(git config --get remote.origin.url | remove_url_credentials)
20+
echo "REPO_URL $repo_url"
21+
22+
commit_sha=$(git rev-parse HEAD)
23+
echo "COMMIT_SHA $commit_sha"
24+
25+
git_branch=$(git rev-parse --abbrev-ref HEAD)
26+
echo "GIT_BRANCH $git_branch"
27+
28+
git_tree_status=$(git diff-index --quiet HEAD -- && echo 'Clean' || echo 'Modified')
29+
echo "GIT_TREE_STATUS $git_tree_status"

0 commit comments

Comments
 (0)