From 0f21e2a5c608d3b4b0df8e50217397b53de3136b Mon Sep 17 00:00:00 2001 From: Finn Evers Date: Tue, 24 Feb 2026 13:28:12 +0100 Subject: [PATCH] extension_ci: Use fork point for version comparison (#49972) Lost another battle to the GitHub docs. Instead, now let's just do it ourselves here in bash and not guess whatever GitHub is referring to in their documentation.. Release Notes: - N/A --- .github/workflows/extension_bump.yml | 7 +++---- .github/workflows/extension_tests.yml | 7 +++---- tooling/xtask/src/tasks/workflows/extension_bump.rs | 6 +++--- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/.github/workflows/extension_bump.yml b/.github/workflows/extension_bump.yml index 4f9ee444aced59ea84f65a348546fdf4715a5190..ff903eb63d30319b5df5ced9c0ec545bb15cca06 100644 --- a/.github/workflows/extension_bump.yml +++ b/.github/workflows/extension_bump.yml @@ -39,8 +39,9 @@ jobs: run: | CURRENT_VERSION="$(sed -n 's/^version = \"\(.*\)\"/\1/p' < extension.toml | tr -d '[:space:]')" - if [[ -n "$PR_PARENT_REF" ]]; then - git checkout "$PR_PARENT_REF" + if [[ "${{ github.event_name }}" == "pull_request" ]]; then + PR_FORK_POINT="$(git merge-base --fork-point main)" + git checkout "$PR_FORK_POINT" elif BRANCH_PARENT_SHA="$(git merge-base origin/main origin/zed-zippy-autobump)"; then git checkout "$BRANCH_PARENT_SHA" else @@ -54,8 +55,6 @@ jobs: echo "version_changed=true" >> "$GITHUB_OUTPUT" echo "current_version=${CURRENT_VERSION}" >> "$GITHUB_OUTPUT" - env: - PR_PARENT_REF: ${{ github.head_ref }} outputs: version_changed: ${{ steps.compare-versions-check.outputs.version_changed }} current_version: ${{ steps.compare-versions-check.outputs.current_version }} diff --git a/.github/workflows/extension_tests.yml b/.github/workflows/extension_tests.yml index 3bc3d43b0521b2ce946be386b318d9a3784c22d8..ed35a054241c8c7dc5c823bd25b59f8b9593efbd 100644 --- a/.github/workflows/extension_tests.yml +++ b/.github/workflows/extension_tests.yml @@ -114,8 +114,9 @@ jobs: run: | CURRENT_VERSION="$(sed -n 's/^version = \"\(.*\)\"/\1/p' < extension.toml | tr -d '[:space:]')" - if [[ -n "$PR_PARENT_REF" ]]; then - git checkout "$PR_PARENT_REF" + if [[ "${{ github.event_name }}" == "pull_request" ]]; then + PR_FORK_POINT="$(git merge-base --fork-point main)" + git checkout "$PR_FORK_POINT" elif BRANCH_PARENT_SHA="$(git merge-base origin/main origin/zed-zippy-autobump)"; then git checkout "$BRANCH_PARENT_SHA" else @@ -129,8 +130,6 @@ jobs: echo "version_changed=true" >> "$GITHUB_OUTPUT" echo "current_version=${CURRENT_VERSION}" >> "$GITHUB_OUTPUT" - env: - PR_PARENT_REF: ${{ github.head_ref }} - name: extension_tests::verify_version_did_not_change run: | if [[ ${{ steps.compare-versions-check.outputs.version_changed }} == "true" && "${{ github.event_name }}" == "pull_request" && "${{ github.event.pull_request.user.login }}" != "zed-zippy[bot]" ]] ; then diff --git a/tooling/xtask/src/tasks/workflows/extension_bump.rs b/tooling/xtask/src/tasks/workflows/extension_bump.rs index e06e50fa6ea8aefaf071a63010e54dd18ab9d70d..bdc25f766e367042883ab7051676c7aa08873243 100644 --- a/tooling/xtask/src/tasks/workflows/extension_bump.rs +++ b/tooling/xtask/src/tasks/workflows/extension_bump.rs @@ -150,8 +150,9 @@ pub(crate) fn compare_versions() -> (Step, StepOutput, StepOutput) { r#" CURRENT_VERSION="$({VERSION_CHECK})" - if [[ -n "$PR_PARENT_REF" ]]; then - git checkout "$PR_PARENT_REF" + if [[ "${{{{ github.event_name }}}}" == "pull_request" ]]; then + PR_FORK_POINT="$(git merge-base --fork-point main)" + git checkout "$PR_FORK_POINT" elif BRANCH_PARENT_SHA="$(git merge-base origin/main origin/zed-zippy-autobump)"; then git checkout "$BRANCH_PARENT_SHA" else @@ -167,7 +168,6 @@ pub(crate) fn compare_versions() -> (Step, StepOutput, StepOutput) { echo "current_version=${{CURRENT_VERSION}}" >> "$GITHUB_OUTPUT" "# }) - .add_env(("PR_PARENT_REF", Context::github().head_ref())) .id("compare-versions-check"); let version_changed = StepOutput::new(&check_needs_bump, "version_changed");