Skip to content

fix(internal/civisibility): fix base branch SHA usage.#3816

Merged
dd-mergequeue[bot] merged 2 commits into
mainfrom
tony/topt-fix-base-branch-sha
Jul 30, 2025
Merged

fix(internal/civisibility): fix base branch SHA usage.#3816
dd-mergequeue[bot] merged 2 commits into
mainfrom
tony/topt-fix-base-branch-sha

Conversation

@tonyredondo

Copy link
Copy Markdown
Member

What does this PR do?

This PR fixes the use of the base branch sha value, we thought this sha was the BASE sha, but we realized it is the HEAD sha of the base branch.

Motivation

JIRA: https://datadoghq.atlassian.net/browse/SDTEST-2353

Reviewer's Checklist

  • Changed code has unit tests for its functionality at or near 100% coverage.
  • System-Tests covering this feature have been added and enabled with the va.b.c-dev version tag.
  • There is a benchmark for any new code, or changes to existing code.
  • If this interacts with the agent in a new way, a system test has been added.
  • New code is free of linting errors. You can check this by running ./scripts/lint.sh locally.
  • Add an appropriate team label so this PR gets put in the right place for the release notes.
  • Non-trivial go.mod changes, e.g. adding new modules, are reviewed by @DataDog/dd-trace-go-guild.

Unsure? Have a question? Request a review!

@tonyredondo
tonyredondo requested a review from a team as a code owner July 30, 2025 08:14
@pr-commenter

pr-commenter Bot commented Jul 30, 2025

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2025-07-30 08:31:12

Comparing candidate commit 11bbfaa in PR branch tony/topt-fix-base-branch-sha with baseline commit 229781c in branch main.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 24 metrics, 0 unstable metrics.

@tonyredondo

Copy link
Copy Markdown
Member Author

/merge

@dd-devflow-routing-codex

dd-devflow-routing-codex Bot commented Jul 30, 2025

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2025-07-30 08:22:09 UTC ℹ️ Start processing command /merge


2025-07-30 08:22:18 UTC ℹ️ MergeQueue: waiting for PR to be ready

This merge request is not mergeable yet, because of pending checks/missing approvals. It will be added to the queue as soon as checks pass and/or get approvals.
Note: if you pushed new commits since the last approval, you may need additional approval.
You can remove it from the waiting list with /remove command.


2025-07-30 08:38:12 UTC ℹ️ MergeQueue: merge request added to the queue

The expected merge time in main is approximately 14m (p90).


2025-07-30 08:48:34 UTCMergeQueue: The checks failed on this merge request

Tests failed on this commit 188e5e0:

What to do next?

  • Investigate the failures and when ready, re-add your pull request to the queue!
  • If your PR checks are green, try to rebase/merge. It might be because the CI run is a bit old.
  • Any question, go check the FAQ.

@tonyredondo

Copy link
Copy Markdown
Member Author

/merge

@dd-devflow-routing-codex

dd-devflow-routing-codex Bot commented Jul 30, 2025

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2025-07-30 08:49:29 UTC ℹ️ Start processing command /merge


2025-07-30 08:49:34 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in main is approximately 14m (p90).


2025-07-30 09:00:02 UTC ℹ️ MergeQueue: This merge request was merged

@dd-mergequeue
dd-mergequeue Bot merged commit db6cb4e into main Jul 30, 2025
222 checks passed
@dd-mergequeue
dd-mergequeue Bot deleted the tony/topt-fix-base-branch-sha branch July 30, 2025 08:59
gh-worker-dd-mergequeue-cf854d Bot pushed a commit to DataDog/dd-trace-py that referenced this pull request Apr 22, 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]>
brettlangdon pushed a commit to DataDog/dd-trace-py 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 to DataDog/dd-trace-py 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants