From 3b3dda7dc8f6c8c8b248c89eb0eee36336efd9a8 Mon Sep 17 00:00:00 2001 From: Noel Kwan <47273164+kwannoel@users.noreply.github.com> Date: Wed, 18 Sep 2024 02:01:08 +0800 Subject: [PATCH] fix(test): fix `current_branch` for backwards compat test (#18565) --- ci/workflows/main-cron.yml | 2 ++ ci/workflows/pull-request.yml | 2 ++ e2e_test/backwards-compat-tests/scripts/utils.sh | 7 +++++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ci/workflows/main-cron.yml b/ci/workflows/main-cron.yml index 1c2083e1a0d4d..d35803e02d758 100644 --- a/ci/workflows/main-cron.yml +++ b/ci/workflows/main-cron.yml @@ -712,6 +712,8 @@ steps: run: source-test-env config: ci/docker-compose.yml mount-buildkite-agent: true + environment: + - BUILDKITE_BRANCH - ./ci/plugins/upload-failure-logs matrix: setup: diff --git a/ci/workflows/pull-request.yml b/ci/workflows/pull-request.yml index c76589e95afd0..151d5ce6ec057 100644 --- a/ci/workflows/pull-request.yml +++ b/ci/workflows/pull-request.yml @@ -711,6 +711,8 @@ steps: run: source-test-env config: ci/docker-compose.yml mount-buildkite-agent: true + environment: + - BUILDKITE_BRANCH - ./ci/plugins/upload-failure-logs matrix: setup: diff --git a/e2e_test/backwards-compat-tests/scripts/utils.sh b/e2e_test/backwards-compat-tests/scripts/utils.sh index f66e7518df2ef..3f99565b9870e 100644 --- a/e2e_test/backwards-compat-tests/scripts/utils.sh +++ b/e2e_test/backwards-compat-tests/scripts/utils.sh @@ -138,7 +138,10 @@ get_old_version() { # We handle the edge case where the current branch is the one being released. # If so, we need to prune it from the list. - local current_branch=$(git branch --show-current | tr -d 'v') + # We cannot simply use 'git branch --show-current', because buildkite checks out with the commit, + # rather than branch. So the current state is detached. + # Instead we rely on BUILDKITE_BRANCH, provided by buildkite. + local current_branch=$(echo "$BUILDKITE_BRANCH" | tr -d 'v') echo "--- CURRENT BRANCH: $current_branch" echo "--- PRUNED VERSIONS" @@ -147,7 +150,7 @@ get_old_version() { # Then we take the Nth latest version. # We set $OLD_VERSION to this. - OLD_VERSION=$(echo -e "$sorted_versions" | tail -n $VERSION_OFFSET | head -1) + OLD_VERSION=$(echo -e "$pruned_versions" | tail -n $VERSION_OFFSET | head -1) } get_new_version() {