Skip to content

Commit

Permalink
bazel: add bazelw wrapper
Browse files Browse the repository at this point in the history
This wrapper allows developers to quickly get off the ground without
having to install bazel or bazelisk manually.

Signed-off-by: Keith Smiley <keithbsmiley@gmail.com>
  • Loading branch information
keith committed Nov 11, 2021
1 parent aac835d commit 822d936
Show file tree
Hide file tree
Showing 13 changed files with 64 additions and 26 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/android_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
bazelisk build \
./bazelw build \
--config=remote-ci-macos \
--remote_header="Authorization=Bearer $GITHUB_TOKEN" \
--fat_apk_cpu=x86 \
Expand Down Expand Up @@ -70,13 +70,13 @@ jobs:
- name: 'Start simulator'
run: ./ci/mac_start_emulator.sh
# Return to using:
# bazelisk mobile-install --fat_apk_cpu=x86 --start_app //examples/java/hello_world:hello_envoy
# ./bazelw mobile-install --fat_apk_cpu=x86 --start_app //examples/java/hello_world:hello_envoy
# When https://github.com/lyft/envoy-mobile/issues/853 is fixed.
- name: 'Start java app'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
bazelisk build \
./bazelw build \
--config=remote-ci-macos \
--remote_header="Authorization=Bearer $GITHUB_TOKEN" \
--fat_apk_cpu=x86 \
Expand Down Expand Up @@ -113,13 +113,13 @@ jobs:
- name: 'Start simulator'
run: ./ci/mac_start_emulator.sh
# Return to using:
# bazelisk mobile-install --fat_apk_cpu=x86 --start_app //examples/kotlin/hello_world:hello_envoy_kt
# ./bazelw mobile-install --fat_apk_cpu=x86 --start_app //examples/kotlin/hello_world:hello_envoy_kt
# When https://github.com/lyft/envoy-mobile/issues/853 is fixed.
- name: 'Start kotlin app'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
bazelisk build \
./bazelw build \
--config=remote-ci-macos \
--remote_header="Authorization=Bearer $GITHUB_TOKEN" \
--fat_apk_cpu=x86 \
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/android_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
bazel test \
./bazelw test \
--test_output=all \
--build_tests_only \
--config=remote-ci-macos \
Expand Down Expand Up @@ -81,7 +81,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
bazel test \
./bazelw test \
--test_output=all \
--build_tests_only \
--config=remote-ci-macos \
Expand Down Expand Up @@ -125,7 +125,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
bazel test \
./bazelw test \
--test_output=all \
--build_tests_only \
--config=remote-ci-linux-clang \
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
current_release_version=$(git describe --tag --abbrev=0)
bazelisk build \
./bazelw build \
--config=release-android \
--fat_apk_cpu=x86 \
--define=pom_version=$current_release_version \
Expand Down Expand Up @@ -114,7 +114,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
bazelisk build \
./bazelw build \
--config=release-ios \
--ios_multi_cpus=i386,x86_64,armv7,arm64 \
--config=remote-ci-macos \
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/asan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: steps.check_context.outputs.run_tests == 'true'
run: |
bazel test --test_output=all \
./bazelw test --test_output=all \
--test_env=ENVOY_IP_TEST_VERSIONS=v4only \
--remote_header="Authorization=Bearer $GITHUB_TOKEN" \
--config=remote-ci-linux-asan \
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cc_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ jobs:
- env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
name: 'Run tests'
run: bazel test --action_env=LD_LIBRARY_PATH --test_output=all --config=remote-ci-linux --remote_header="Authorization=Bearer $GITHUB_TOKEN" //test/cc/...
run: ./bazelw test --action_env=LD_LIBRARY_PATH --test_output=all --config=remote-ci-linux --remote_header="Authorization=Bearer $GITHUB_TOKEN" //test/cc/...
2 changes: 1 addition & 1 deletion .github/workflows/core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ jobs:
- name: 'Run tests'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: bazelisk test --test_output=all --config=remote-ci-macos --remote_header="Authorization=Bearer $GITHUB_TOKEN" //test/common/...
run: ./bazelw test --test_output=all --config=remote-ci-macos --remote_header="Authorization=Bearer $GITHUB_TOKEN" //test/common/...
4 changes: 2 additions & 2 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
bazel build \
./bazelw build \
--config=remote-ci-macos --remote_header="Authorization=Bearer $GITHUB_TOKEN" \
//library/kotlin/io/envoyproxy/envoymobile:envoy_lib_lint \
//examples/kotlin/hello_world:hello_envoy_kt_lint
- name: 'Run Kotlin Formatter (ktlint)'
run: |
bazel build kotlin_format
./bazelw build kotlin_format
12 changes: 6 additions & 6 deletions .github/workflows/ios_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ jobs:
- env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
bazelisk shutdown
bazelisk build --config=ios --config=remote-ci-macos --remote_header="Authorization=Bearer $GITHUB_TOKEN" //:ios_dist
./bazelw shutdown
./bazelw build --config=ios --config=remote-ci-macos --remote_header="Authorization=Bearer $GITHUB_TOKEN" //:ios_dist
if: steps.check-cache.outputs.cache-hit != 'true'
name: 'Build Envoy.framework distributable'
swifthelloworld:
Expand All @@ -56,12 +56,12 @@ jobs:
name: 'Short-circuit'
- env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: bazelisk build --config=ios --config=remote-ci-macos --remote_header="Authorization=Bearer $GITHUB_TOKEN" //examples/swift/hello_world:app
run: ./bazelw build --config=ios --config=remote-ci-macos --remote_header="Authorization=Bearer $GITHUB_TOKEN" //examples/swift/hello_world:app
name: 'Build swift app'
# Run the app in the background and redirect logs.
- env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: bazelisk run --config=ios --config=remote-ci-macos --remote_header="Authorization=Bearer $GITHUB_TOKEN" //examples/swift/hello_world:app &> /tmp/envoy.log &
run: ./bazelw run --config=ios --config=remote-ci-macos --remote_header="Authorization=Bearer $GITHUB_TOKEN" //examples/swift/hello_world:app &> /tmp/envoy.log &
name: 'Run swift app'
- run: sed '/received headers with status 200/q' <(touch /tmp/envoy.log && tail -F /tmp/envoy.log)
name: 'Check connectivity'
Expand Down Expand Up @@ -90,12 +90,12 @@ jobs:
name: 'Short-circuit'
- env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: bazelisk build --config=ios --config=remote-ci-macos --remote_header="Authorization=Bearer $GITHUB_TOKEN" //examples/objective-c/hello_world:app
run: ./bazelw build --config=ios --config=remote-ci-macos --remote_header="Authorization=Bearer $GITHUB_TOKEN" //examples/objective-c/hello_world:app
name: 'Build objective-c app'
# Run the app in the background and redirect logs.
- env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: bazelisk run --config=ios --config=remote-ci-macos --remote_header="Authorization=Bearer $GITHUB_TOKEN" //examples/objective-c/hello_world:app &> /tmp/envoy.log &
run: ./bazelw run --config=ios --config=remote-ci-macos --remote_header="Authorization=Bearer $GITHUB_TOKEN" //examples/objective-c/hello_world:app &> /tmp/envoy.log &
name: 'Run objective-c app'
- run: sed '/received headers with status 200/q' <(touch /tmp/envoy.log && tail -F /tmp/envoy.log)
name: 'Check connectivity'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ios_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ jobs:
if: steps.check_context.outputs.run_tests == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: bazelisk test --test_output=all --config=ios --build_tests_only --config=remote-ci-macos --remote_header="Authorization=Bearer $GITHUB_TOKEN" //test/swift/...
run: ./bazelw test --test_output=all --config=ios --build_tests_only --config=remote-ci-macos --remote_header="Authorization=Bearer $GITHUB_TOKEN" //test/swift/...
4 changes: 2 additions & 2 deletions .github/workflows/perf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
bazel build \
./bazelw build \
--config=sizeopt \
--config=remote-ci-linux-clang \
--remote_header="Authorization=Bearer $GITHUB_TOKEN" \
Expand All @@ -51,7 +51,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git checkout main && git pull origin main && git submodule update
bazel build \
./bazelw build \
--config=sizeopt \
--config=remote-ci-linux-clang \
--remote_header="Authorization=Bearer $GITHUB_TOKEN" \
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
bazel test \
./bazelw test \
--action_env=LD_LIBRARY_PATH \
--test_output=all \
--config=remote-ci-linux \
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tsan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: steps.check_context.outputs.run_tests == 'true'
run: |
bazel test --test_output=all \
./bazelw test --test_output=all \
--test_env=ENVOY_IP_TEST_VERSIONS=v4only \
--remote_header="Authorization=Bearer $GITHUB_TOKEN" \
--config=remote-ci-linux-tsan \
Expand Down
38 changes: 38 additions & 0 deletions bazelw
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash

set -euo pipefail

readonly bazelisk_version="1.10.1"
if [[ $OSTYPE == darwin* ]]; then
# TODO: Support M1 once https://github.com/envoyproxy/envoy/issues/16482
readonly bazel_platform="darwin-amd64"
readonly bazel_version_sha="e485bbf84532d02a60b0eb23c702610b5408df3a199087a4f2b5e0995bbf2d5a"
else
readonly bazel_platform="linux-amd64"
readonly bazel_version_sha="4cb534c52cdd47a6223d4596d530e7c9c785438ab3b0a49ff347e991c210b2cd"
fi

readonly bazel_version_url="https://github.com/bazelbuild/bazelisk/releases/download/v$bazelisk_version/bazelisk-$bazel_platform"
script_root="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
readonly bazelisk="$script_root/tmp/bazel/versions/bazelisk-$bazelisk_version-$bazel_platform"

if [[ ! -x "$bazelisk" ]]; then
echo "Installing bazelisk..." >&2
mkdir -p "$(dirname "$bazelisk")"

download_bazelisk() {
curl --fail -L --retry 5 --retry-connrefused --silent --progress-bar \
--output "$bazelisk" "$bazel_version_url"
}

download_bazelisk || download_bazelisk
if echo "$bazel_version_sha $bazelisk" | shasum --check --status; then
chmod +x "$bazelisk"
else
echo "Bazelisk sha mismatch" >&2
rm -f "$bazelisk"
exit 1
fi
fi

exec "$bazelisk" "$@"

0 comments on commit 822d936

Please sign in to comment.