|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# Copyright 2025 The Cockroach Authors. |
| 4 | +# |
| 5 | +# Use of this software is governed by the CockroachDB Software License |
| 6 | +# included in the /LICENSE file. |
| 7 | + |
| 8 | + |
| 9 | +set -exuo pipefail |
| 10 | + |
| 11 | +export ROACHPROD_DISABLED_PROVIDERS=aws,azure,ibm |
| 12 | +export ROACHPROD_DISABLE_UPDATE_CHECK=true |
| 13 | +export ROACHPROD_GCE_DEFAULT_SERVICE_ACCOUNT=$GOOGLE_SERVICE_ACCOUNT |
| 14 | +export ROACHPROD_GCE_DEFAULT_PROJECT=cockroach-ephemeral |
| 15 | + |
| 16 | +# build the binaries - roachprod, roachtest and drtprod |
| 17 | +build() { |
| 18 | + config="crosslinux" |
| 19 | + # Prepare the bin/ and lib/ directories. |
| 20 | + mkdir -p bin |
| 21 | + chmod o+rwx bin |
| 22 | + |
| 23 | + # Array of arguments to be passed to bazel for the component. |
| 24 | + bazel_args=() |
| 25 | + |
| 26 | + # Array of build artifacts. Each item has format "src:dest"; src is relative to |
| 27 | + # the bazel-bin directory, dst is relative to cwd. |
| 28 | + artifacts=() |
| 29 | + |
| 30 | + bazel_args+=(//pkg/cmd/roachtest) |
| 31 | + artifacts+=("pkg/cmd/roachtest/roachtest_/roachtest:bin/roachtest") |
| 32 | + |
| 33 | + bazel_args+=(//pkg/cmd/roachprod) |
| 34 | + artifacts+=("pkg/cmd/roachprod/roachprod_/roachprod:bin/roachprod") |
| 35 | + |
| 36 | + bazel_args+=(//pkg/cmd/drtprod) |
| 37 | + artifacts+=("pkg/cmd/drtprod/drtprod_/drtprod:bin/drtprod") |
| 38 | + |
| 39 | + bazel build --config $config -c opt "${bazel_args[@]}" |
| 40 | + BAZEL_BIN=$(bazel info bazel-bin --config $config -c opt) |
| 41 | + for artifact in "${artifacts[@]}"; do |
| 42 | + src=${artifact%%:*} |
| 43 | + dst=${artifact#*:} |
| 44 | + cp "$BAZEL_BIN/$src" "$dst" |
| 45 | + # Make files writable to simplify cleanup and copying (e.g., scp retry). |
| 46 | + chmod a+w "$dst" |
| 47 | + done |
| 48 | + |
| 49 | + # add bin to path |
| 50 | + export PATH=$PATH:$(pwd)/bin |
| 51 | +} |
| 52 | + |
| 53 | +# Set up Google credentials. Note that we need this for all clouds since we upload |
| 54 | +# perf artifacts to Google Storage at the end. |
| 55 | +if [[ "$GOOGLE_APPLICATION_CREDENTIALS_CONTENT" ]]; then |
| 56 | + echo "$GOOGLE_APPLICATION_CREDENTIALS_CONTENT" > creds.json |
| 57 | + gcloud auth activate-service-account --key-file=creds.json |
| 58 | + |
| 59 | + # Set GOOGLE_APPLICATION_CREDENTIALS so that gcp go libraries can find it. |
| 60 | + export GOOGLE_APPLICATION_CREDENTIALS="$(pwd)/creds.json" |
| 61 | +else |
| 62 | + echo 'warning: GOOGLE_EPHEMERAL_CREDENTIALS not set' >&2 |
| 63 | + exit 1 |
| 64 | +fi |
| 65 | + |
| 66 | +# Run the build function |
| 67 | +build |
| 68 | +# |
| 69 | +roachprod list |
| 70 | +#drtprod list |
0 commit comments