From 3ce4d08afb304974b55a2499e1bc982bd24ecaa4 Mon Sep 17 00:00:00 2001 From: Saul Paredes Date: Thu, 14 Nov 2024 13:05:30 -0800 Subject: [PATCH] ci: rebase before running samples check This removes the need for PR author to rebase feature branch for updated samples in target branch, if any Signed-off-by: Saul Paredes --- .github/workflows/check-samples.yaml | 6 ++++++ tests/git-helper.sh | 2 ++ 2 files changed, 8 insertions(+) diff --git a/.github/workflows/check-samples.yaml b/.github/workflows/check-samples.yaml index 92945a2fa2da..4c7d783b7c14 100644 --- a/.github/workflows/check-samples.yaml +++ b/.github/workflows/check-samples.yaml @@ -14,6 +14,12 @@ jobs: - name: Check out code uses: actions/checkout@v4 + - name: Rebase atop of the latest target branch + env: + TARGET_BRANCH: ${{ github.event.pull_request.base.ref }} + run: | + ./tests/git-helper.sh "rebase-atop-of-the-latest-target-branch" + - name: Install yq env: INSTALL_IN_GOPATH: false diff --git a/tests/git-helper.sh b/tests/git-helper.sh index 32d0384fa79e..a0ac2dba2e19 100755 --- a/tests/git-helper.sh +++ b/tests/git-helper.sh @@ -8,6 +8,7 @@ set -o errexit set -o nounset set -o pipefail +set -x function add_kata_bot_info() { echo "Adding user name and email to the local git repo" @@ -21,6 +22,7 @@ function rebase_atop_of_the_latest_target_branch() { echo "Rebasing atop of the latest ${TARGET_BRANCH}" # Recover from any previous rebase left halfway git rebase --abort 2> /dev/null || true + git fetch origin ${TARGET_BRANCH} git rebase origin/${TARGET_BRANCH} fi }