Skip to content

Support multiple lang-branch overrides in PR title#6468

Open
bm1549 wants to merge 2 commits intomainfrom
brian.marks/multi-branch-override
Open

Support multiple lang-branch overrides in PR title#6468
bm1549 wants to merge 2 commits intomainfrom
brian.marks/multi-branch-override

Conversation

@bm1549
Copy link
Contributor

@bm1549 bm1549 commented Mar 11, 2026

Motivation

The system-tests CI supports specifying a tracer branch override in the PR title like [java@my-branch], but it only supported one branch override at a time. This made it impossible to test PRs that need changes from multiple tracer libraries simultaneously (e.g. [java@branch1][dotnet@branch2]).

Changes

  • get_target_branch action: Updated to capture all [lang@branch] pairs from the PR title and output them as a JSON map (e.g. {"java":"branch1","dotnet":"branch2"}). Added a has-target-branch boolean output.
  • compute-workflow-parameters.yml: Added a step to extract the specific library's branch from the JSON map before passing it to load-binary.sh. Also extracts the agent branch separately for proper AGENT_TARGET_BRANCH env var support.
  • compute_libraries_and_scenarios.yml: Exposed the new has-target-branch output.
  • ci.yml: Updated the "Fail if target branch is specified" check to use the new has-target-branch output.

Backward compatibility is preserved: plain branch strings from external callers still work via the legacy fallback path.

Examples

PR Title Parsed Output
My PR [java@branch1] {"java":"branch1"}
My PR [java@b1][dotnet@b2] {"java":"b1","dotnet":"b2"}
My PR [java@b1][golang@b2][ruby@b3] {"java":"b1","golang":"b2","ruby":"b3"}
My PR (no override) empty

Workflow

  1. ⚠️ Create your PR as draft ⚠️
  2. Work on you PR until the CI passes
  3. Mark it as ready for review
    • Test logic is modified? -> Get a review from RFC owner.
    • Framework is modified, or non obvious usage of it -> get a review from R&P team

🚀 Once your PR is reviewed and the CI green, you can merge it!

🛟 #apm-shared-testing 🛟

Reviewer checklist

  • Anything but tests/ or manifests/ is modified ? I have the approval from R&P team
  • A docker base image is modified?
    • the relevant build-XXX-image label is present
  • A scenario is added, removed or renamed?

🤖 Generated with Claude Code

Previously, specifying a tracer branch override in the PR title (e.g.
[java@my-branch]) only supported a single override at a time. This
change allows multiple overrides like [java@branch1][dotnet@branch2]
so that different libraries can each use their own dev branch.

The get_target_branch action now outputs a JSON map of library to
branch, and the compute-workflow-parameters workflow extracts the
correct branch for each library before passing it to load-binary.sh.
Backward compatibility with plain branch strings is preserved.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@bm1549 bm1549 added the ai-generated The pull request includes a significant amount of AI-generated code label Mar 11, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 11, 2026

CODEOWNERS have been resolved as:

.github/actions/get_target_branch/action.yaml                           @DataDog/system-tests-core
.github/workflows/ci.yml                                                @DataDog/system-tests-core
.github/workflows/compute-workflow-parameters.yml                       @DataDog/system-tests-core
.github/workflows/compute_libraries_and_scenarios.yml                   @DataDog/system-tests-core
docs/CI/github-actions.md                                               @DataDog/system-tests-core
docs/CI/system-tests-ci.md                                              @DataDog/system-tests-core

@bm1549 bm1549 changed the title Support multiple [lang@branch] overrides in PR title Support multiple lang-branch overrides in PR title Mar 11, 2026
Update target branch selection docs to reflect that multiple
[lang@branch] pairs can now be specified simultaneously in the PR
title. Update the workflow parameter description to note JSON map
support.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@bm1549 bm1549 marked this pull request as ready for review March 13, 2026 18:04
@bm1549 bm1549 requested a review from a team as a code owner March 13, 2026 18:04
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c04ec34d65

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

id: extract_branch
shell: bash
run: |
TARGET_BRANCH_MAP='${{ inputs._system_tests_library_target_branch }}'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Avoid shell interpolation of untrusted branch map

inputs._system_tests_library_target_branch is populated from PR title content (via compute_libraries_and_scenarios.yml + get_target_branch), but this step injects it directly into a single-quoted shell assignment. Since branch names can legally contain ' (e.g. foo'bar), a crafted override like [java@x'; ...] can break quoting and execute unintended shell commands in this job; at minimum it causes syntax failures, and in CI contexts it can become command injection.

Useful? React with 👍 / 👎.

Comment on lines +166 to +168
elif echo "$TARGET_BRANCH_MAP" | jq empty 2>/dev/null; then
# It's valid JSON — extract the branch for this library and agent
library_branch=$(echo "$TARGET_BRANCH_MAP" | jq -r --arg lib "$LIBRARY" '.[$lib] // empty')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Require JSON object before extracting library keys

The JSON detection uses jq empty, which returns success for any valid JSON scalar, not just maps. That means legacy plain branch strings like 123 or true (both valid Git branch names) are treated as JSON, then .[$lib] is evaluated on a number/boolean and the step exits with Cannot index ... with string, breaking the documented backward-compatible plain-string path.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-generated The pull request includes a significant amount of AI-generated code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant