|
| 1 | +{ |
| 2 | + nativelink, |
| 3 | + writeShellScriptBin, |
| 4 | + bazelisk, |
| 5 | +}: |
| 6 | +writeShellScriptBin "rbe-toolchain-test" '' |
| 7 | + set -uo pipefail |
| 8 | +
|
| 9 | + cleanup() { |
| 10 | + local pids=$(jobs -pr) |
| 11 | + [ -n "$pids" ] && kill $pids |
| 12 | + } |
| 13 | + trap "cleanup" INT QUIT TERM EXIT |
| 14 | +
|
| 15 | + NO_COLOR=true ${nativelink}/bin/nativelink -- toolchain-examples/nativelink-config.json5 | tee -i toolchain-examples/nativelink.log & |
| 16 | +
|
| 17 | + CORE_BAZEL_ARGS="--check_direct_dependencies=error --remote_cache=grpc://localhost:50051 --remote_executor=grpc://localhost:50051" |
| 18 | +
|
| 19 | + CPU_TYPE=$(uname -m) |
| 20 | +
|
| 21 | + if [[ "$CPU_TYPE" == 'x86_64' ]]; then |
| 22 | + PLATFORM='amd64' |
| 23 | + else |
| 24 | + PLATFORM='arm64' |
| 25 | + fi |
| 26 | +
|
| 27 | + LLVM_PLATFORM="--platforms=@toolchains_llvm//platforms:linux-''${CPU_TYPE}" |
| 28 | + ZIG_PLATFORM="--platforms @zig_sdk//platform:linux_''${PLATFORM}" |
| 29 | +
|
| 30 | + # As per https://nativelink.com/docs/rbe/remote-execution-examples#minimal-example-targets |
| 31 | + COMMANDS=("test //cpp $ZIG_PLATFORM" |
| 32 | + "test //cpp --config=llvm $LLVM_PLATFORM" |
| 33 | + "test //python" |
| 34 | + "test //go $ZIG_PLATFORM" |
| 35 | + # "test //rust $ZIG_PLATFORM" # rules_rust isn't RBE-compatible |
| 36 | + "test //java:HelloWorld --config=java" |
| 37 | + "build @curl//... $ZIG_PLATFORM" |
| 38 | + "build @zstd//... $ZIG_PLATFORM" |
| 39 | + # "test @abseil-cpp//... $ZIG_PLATFORM" # Buggy build due to google_benchmark errors |
| 40 | + "test @abseil-py//..." |
| 41 | + "test @circl//... $ZIG_PLATFORM" |
| 42 | + ) |
| 43 | +
|
| 44 | + echo "" > toolchain-examples/cmd.log |
| 45 | + for cmd in "''${COMMANDS[@]}" |
| 46 | + do |
| 47 | + FULL_CMD="${bazelisk}/bin/bazelisk $cmd $CORE_BAZEL_ARGS" |
| 48 | + echo $FULL_CMD |
| 49 | + echo -e \\n$FULL_CMD\\n >> toolchain-examples/cmd.log |
| 50 | + cmd_output=$(cd toolchain-examples && eval "$FULL_CMD" 2>&1 | tee -ai cmd.log) |
| 51 | + cmd_exit_code=$? |
| 52 | + case $cmd_exit_code in |
| 53 | + 0 ) |
| 54 | + echo "Saw a successful $cmd build" |
| 55 | + ;; |
| 56 | + *) |
| 57 | + echo "Failed $cmd build:" |
| 58 | + echo $cmd_output |
| 59 | + exit 1 |
| 60 | + ;; |
| 61 | + esac |
| 62 | + done |
| 63 | +
|
| 64 | + nativelink_output=$(cat toolchain-examples/nativelink.log) |
| 65 | +
|
| 66 | + case $nativelink_output in |
| 67 | + *"ERROR "* ) |
| 68 | + echo "Error in nativelink build" |
| 69 | + exit 1 |
| 70 | + ;; |
| 71 | + *) |
| 72 | + echo 'Successful nativelink build' |
| 73 | + ;; |
| 74 | + esac |
| 75 | +'' |
0 commit comments