diff --git a/build/teamcity/cockroach/nightlies/microbenchmark_build_support.sh b/build/teamcity/cockroach/nightlies/microbenchmark_build_support.sh index 78b38f88e3ca..3617bef563db 100755 --- a/build/teamcity/cockroach/nightlies/microbenchmark_build_support.sh +++ b/build/teamcity/cockroach/nightlies/microbenchmark_build_support.sh @@ -63,6 +63,7 @@ EOF current_sha=$(git rev-parse HEAD) shas=("$@") for sha in "${shas[@]}"; do + git fetch origin "$sha" git checkout "$sha" build_and_upload_binaries "$sha" done diff --git a/build/teamcity/cockroach/nightlies/microbenchmark_weekly.sh b/build/teamcity/cockroach/nightlies/microbenchmark_weekly.sh index 037316bc5c08..cf489da05611 100755 --- a/build/teamcity/cockroach/nightlies/microbenchmark_weekly.sh +++ b/build/teamcity/cockroach/nightlies/microbenchmark_weekly.sh @@ -44,46 +44,12 @@ remote_dir="/mnt/data1" benchmarks_commit=$(git rev-parse HEAD) exit_status=0 -# Set up credentials -google_credentials="$GOOGLE_EPHEMERAL_CREDENTIALS" -log_into_gcloud -export GOOGLE_APPLICATION_CREDENTIALS="$PWD/.google-credentials.json" -export ROACHPROD_USER=teamcity -export ROACHPROD_CLUSTER=teamcity-microbench-${TC_BUILD_ID} -generate_ssh_key - -# Sanatize the package name for use in paths -SANITIZED_BENCH_PACKAGE=${BENCH_PACKAGE//\//-} -export SANITIZED_BENCH_PACKAGE=${SANITIZED_BENCH_PACKAGE/.../all} - -# Build rochprod and roachprod-microbench -run_bazel <<'EOF' -bazel build --config crosslinux //pkg/cmd/roachprod //pkg/cmd/roachprod-microbench -BAZEL_BIN=$(bazel info bazel-bin --config crosslinux) -mkdir -p bin -cp $BAZEL_BIN/pkg/cmd/roachprod/roachprod_/roachprod bin -cp $BAZEL_BIN/pkg/cmd/roachprod-microbench/roachprod-microbench_/roachprod-microbench bin -chmod a+w bin/roachprod bin/roachprod-microbench -EOF - # Check if a string is a valid SHA (otherwise it's a branch or tag name). is_sha() { local sha="$1" [[ "$sha" =~ ^[0-9a-f]{40}$ ]] } -# Check if a string is a valid branch -is_branch() { - local branch="$1" - git rev-parse --verify "refs/heads/$branch" >/dev/null 2>&1 -} - -# Check if a string is a valid tag -is_tag() { - local tag="$1" - git rev-parse --verify "refs/tags/$tag" >/dev/null 2>&1 -} - get_latest_patch_tag() { local latest_tag latest_tag=$(git tag -l 'v*' \ @@ -93,37 +59,48 @@ get_latest_patch_tag() { echo "$latest_tag" } -git fetch origin --tags - # Create arrays for the revisions and their corresponding SHAs. revisions=("${BENCH_REVISION}" "${BENCH_COMPARE_REVISION}") declare -a sha_arr declare -a name_arr for rev in "${revisions[@]}"; do if [ "$rev" == "LATEST_PATCH_RELEASE" ]; then + git fetch origin --tags rev=$(get_latest_patch_tag) fi if is_sha "$rev"; then sha="$rev" name="${sha:0:8}" else - # Named revision (branch or tag) - if is_branch "$rev"; then - git fetch origin "$rev" - sha=$(git rev-parse origin/"$rev") - elif is_tag "$rev"; then - sha=$(git rev-parse "$rev") - else - echo "Invalid revision: $rev" - exit 1 - fi + sha=$(git ls-remote origin "$rev" | awk '{print $1}') name="$rev (${sha:0:8})" fi - name_arr+=("$name") sha_arr+=("$sha") done +# Set up credentials +google_credentials="$GOOGLE_EPHEMERAL_CREDENTIALS" +log_into_gcloud +export GOOGLE_APPLICATION_CREDENTIALS="$PWD/.google-credentials.json" +export ROACHPROD_USER=teamcity +export ROACHPROD_CLUSTER=teamcity-microbench-${TC_BUILD_ID} +generate_ssh_key + +# Sanatize the package name for use in paths +SANITIZED_BENCH_PACKAGE=${BENCH_PACKAGE//\//-} +export SANITIZED_BENCH_PACKAGE=${SANITIZED_BENCH_PACKAGE/.../all} + +# Build rochprod and roachprod-microbench +run_bazel <<'EOF' +bazel build --config crosslinux //pkg/cmd/roachprod //pkg/cmd/roachprod-microbench +BAZEL_BIN=$(bazel info bazel-bin --config crosslinux) +mkdir -p bin +cp $BAZEL_BIN/pkg/cmd/roachprod/roachprod_/roachprod bin +cp $BAZEL_BIN/pkg/cmd/roachprod-microbench/roachprod-microbench_/roachprod-microbench bin +chmod a+w bin/roachprod bin/roachprod-microbench +EOF + # Check if the baseline cache exists and copy it to the output directory. baseline_cache_path="gs://$BENCH_BUCKET/cache/$GCE_MACHINE_TYPE/$SANITIZED_BENCH_PACKAGE/${sha_arr[1]}" declare -a build_sha_arr