chore(ci_visibility): use merge-base for github actions PR base commit sha#17657
Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 3 commits intoApr 22, 2026
Merged
Conversation
On GitHub Actions, pull_request.base.sha points to the HEAD of the base branch rather than the common ancestor commit. Store it as git.pull_request.base_branch_head_sha and compute the true base commit SHA via `git merge-base` for use as git.pull_request.base_branch_sha. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Codeowners resolved as |
Member
Author
E2E Test Report: SUCCESS ✅Tested by: Shepherd Agent (autonomous QA for Datadog Test Optimization) Test Environment
Results
Test MethodologyTest 1 — Regression check (local, no GHA env) Ran the Test 2 — Simulated GitHub Actions environment Re-ran with the following injected env vars to simulate a Verified in the raw citestcycle payload:
"git.pull_request.base_branch_head_sha": "a411a2434b09d9cbaa4074232b2c247d591bb655",
"git.pull_request.base_branch_sha": "a411a2434b09d9cbaa4074232b2c247d591bb655",
"git.pull_request.base_branch": "main",
"git.branch": "feature-branch"
This E2E test was performed by Shepherd — autonomous QA agent for Datadog Test Optimization |
juan-fernandez
approved these changes
Apr 21, 2026
gh-worker-dd-mergequeue-cf854d
Bot
deleted the
gnufede/SDTEST-2356-base-branch-sha-gha
branch
April 22, 2026 09:29
brettlangdon
pushed a commit
that referenced
this pull request
Apr 23, 2026
…t sha (#17657) ## Description On GitHub Actions, `pull_request.base.sha` in the event payload points to the **HEAD of the base branch**, not to the common ancestor (merge base) commit. This PR fixes two related issues: 1. **Tag rename**: `pull_request.base.sha` is now stored as `git.pull_request.base_branch_head_sha` (was incorrectly absent; the value is semantically the base branch head, not the base commit SHA). 2. **Merge base computation**: `git.pull_request.base_branch_sha` (the true diff base) is now computed via `git merge-base <base.sha> <head.sha>` when it hasn't already been provided by the CI system (e.g. GitLab provides it directly via `CI_MERGE_REQUEST_DIFF_BASE_SHA`). Reference implementation (Go): DataDog/dd-trace-go#3816 ## Changes - `ddtrace/ext/ci/github_actions.py`: read `pull_request.base.sha` from event file → set as `git.PULL_REQUEST_BASE_BRANCH_HEAD_SHA` - `ddtrace/testing/internal/git.py`: add `Git.get_merge_base()` method and `get_pr_base_commit_sha()` module-level helper - `ddtrace/testing/internal/env_tags.py`: after assembling tags, compute `PULL_REQUEST_BASE_BRANCH_SHA` via merge-base when not already set ## Test plan - [x] `test_github_actions_base_branch_head_sha_extracted_from_event` — verifies `pull_request.base.sha` → `base_branch_head_sha` - [x] `test_github_actions_base_branch_sha_computed_as_merge_base` — verifies merge-base is called with correct SHAs - [x] `test_github_actions_base_branch_sha_not_overwritten_when_already_set` — verifies pre-existing value (e.g. from `DD_GIT_PULL_REQUEST_BASE_BRANCH_SHA`) is respected 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: federico.mon <[email protected]>
emmettbutler
pushed a commit
that referenced
this pull request
May 6, 2026
…t sha (#17657) ## Description On GitHub Actions, `pull_request.base.sha` in the event payload points to the **HEAD of the base branch**, not to the common ancestor (merge base) commit. This PR fixes two related issues: 1. **Tag rename**: `pull_request.base.sha` is now stored as `git.pull_request.base_branch_head_sha` (was incorrectly absent; the value is semantically the base branch head, not the base commit SHA). 2. **Merge base computation**: `git.pull_request.base_branch_sha` (the true diff base) is now computed via `git merge-base <base.sha> <head.sha>` when it hasn't already been provided by the CI system (e.g. GitLab provides it directly via `CI_MERGE_REQUEST_DIFF_BASE_SHA`). Reference implementation (Go): DataDog/dd-trace-go#3816 ## Changes - `ddtrace/ext/ci/github_actions.py`: read `pull_request.base.sha` from event file → set as `git.PULL_REQUEST_BASE_BRANCH_HEAD_SHA` - `ddtrace/testing/internal/git.py`: add `Git.get_merge_base()` method and `get_pr_base_commit_sha()` module-level helper - `ddtrace/testing/internal/env_tags.py`: after assembling tags, compute `PULL_REQUEST_BASE_BRANCH_SHA` via merge-base when not already set ## Test plan - [x] `test_github_actions_base_branch_head_sha_extracted_from_event` — verifies `pull_request.base.sha` → `base_branch_head_sha` - [x] `test_github_actions_base_branch_sha_computed_as_merge_base` — verifies merge-base is called with correct SHAs - [x] `test_github_actions_base_branch_sha_not_overwritten_when_already_set` — verifies pre-existing value (e.g. from `DD_GIT_PULL_REQUEST_BASE_BRANCH_SHA`) is respected 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: federico.mon <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
On GitHub Actions,
pull_request.base.shain the event payload points to the HEAD of the base branch, not to the common ancestor (merge base) commit. This PR fixes two related issues:pull_request.base.shais now stored asgit.pull_request.base_branch_head_sha(was incorrectly absent; the value is semantically the base branch head, not the base commit SHA).git.pull_request.base_branch_sha(the true diff base) is now computed viagit merge-base <base.sha> <head.sha>when it hasn't already been provided by the CI system (e.g. GitLab provides it directly viaCI_MERGE_REQUEST_DIFF_BASE_SHA).Reference implementation (Go): DataDog/dd-trace-go#3816
Changes
ddtrace/ext/ci/github_actions.py: readpull_request.base.shafrom event file → set asgit.PULL_REQUEST_BASE_BRANCH_HEAD_SHAddtrace/testing/internal/git.py: addGit.get_merge_base()method andget_pr_base_commit_sha()module-level helperddtrace/testing/internal/env_tags.py: after assembling tags, computePULL_REQUEST_BASE_BRANCH_SHAvia merge-base when not already setTest plan
test_github_actions_base_branch_head_sha_extracted_from_event— verifiespull_request.base.sha→base_branch_head_shatest_github_actions_base_branch_sha_computed_as_merge_base— verifies merge-base is called with correct SHAstest_github_actions_base_branch_sha_not_overwritten_when_already_set— verifies pre-existing value (e.g. fromDD_GIT_PULL_REQUEST_BASE_BRANCH_SHA) is respected🤖 Generated with Claude Code