Skip to content

Fix RoG MR ID to differentiate builds within same merge request#376

Merged
kkaarreell merged 1 commit into
mainfrom
ks_fix_mr_id
Jun 11, 2026
Merged

Fix RoG MR ID to differentiate builds within same merge request#376
kkaarreell merged 1 commit into
mainfrom
ks_fix_mr_id

Conversation

@kkaarreell

@kkaarreell kkaarreell commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

The RoG (GitLab MR) support was not properly differentiating different builds within the same merge request. The ID string only contained the MR number but not the specific build task ID, making it impossible to track different builds/respins of the same MR.

Changes:

  • Add RoG case to ArtifactJob.short_id to return build_target instead of compose.id (checked before compose to take precedence)
  • Add RoG case to newa_id() to append "(task {build_task_id})" when partial=False, similar to how erratum events append builds list
  • Add comprehensive test coverage (12 tests) for RoG ID generation

This enables proper tracking of different builds within the same MR, correct filename generation, and proper Jira issue matching for RoG respins. Old issues are now correctly closed when on_respin: close.

Summary by Sourcery

Differentiate RoG GitLab merge request builds by incorporating build target and build task ID into artifact and Jira identifiers.

New Features:

  • Identify RoG ArtifactJobs by build target instead of compose ID to distinguish builds within the same merge request.
  • Extend Jira newa_id generation for RoG events to include the build task ID when generating full identifiers.

Tests:

  • Add comprehensive unit tests covering RoG short_id, newa_id behavior, and RoG Event.short_id parsing.

The RoG (GitLab MR) support was not properly differentiating different
builds within the same merge request. The ID string only contained the
MR number but not the specific build task ID, making it impossible to
track different builds/respins of the same MR.

Changes:
- Add RoG case to ArtifactJob.short_id to return build_target instead
  of compose.id (checked before compose to take precedence)
- Add RoG case to newa_id() to append "(task {build_task_id})" when
  partial=False, similar to how erratum events append builds list
- Add comprehensive test coverage (12 tests) for RoG ID generation

This enables proper tracking of different builds within the same MR,
correct filename generation, and proper Jira issue matching for RoG
respins. Old issues are now correctly closed when on_respin: close.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@kkaarreell kkaarreell self-assigned this Jun 11, 2026
@sourcery-ai

sourcery-ai Bot commented Jun 11, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds RoG-specific identification for ArtifactJobs and Jira NEWA IDs so that builds within the same GitLab MR are distinguished by build target and build task ID, and introduces comprehensive tests for RoG ID behavior.

File-Level Changes

Change Details Files
Use RoG build target as the primary short identifier for RoG ArtifactJobs, taking precedence over compose IDs.
  • Extend ArtifactJob.short_id to return rog.build_target when a RoG object is present.
  • Ensure RoG-based short_id is used even when both rog and compose are set, preserving any -draft suffixes.
  • Verify RoG ArtifactJob.id format uses Event.short_id and RoG short_id via new tests.
newa/models/jobs.py
tests/unit/test_rog_ids.py
Include RoG build task ID in full NEWA IDs for Jira so different builds of the same MR are uniquely tracked, while keeping partial IDs stable across respins.
  • Extend IssueHandler.newa_id to append '(task {build_task_id})' for RoG events when partial is False and a RoG object is present.
  • Keep partial NEWA IDs unchanged (no task suffix) so they group all respins of the same MR.
  • Maintain existing behavior for erratum events and custom action.newa_id overrides, covered by new RoG-focused tests.
newa/services/jira_service.py
tests/unit/test_rog_ids.py
Add focused unit tests to lock in RoG-specific ID generation semantics across ArtifactJob, Event, and IssueHandler.
  • Add tests for RoG ArtifactJob.short_id and id formatting, including precedence over compose and handling of draft suffixes.
  • Add tests for RoG IssueHandler.newa_id covering full vs partial forms, differentiation by task ID, custom action.newa_id, and no-action behavior.
  • Add tests for RoG Event.short_id parsing from various GitLab MR URL shapes (with/without trailing slash and different project structures).
tests/unit/test_rog_ids.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • In IssueHandler.newa_id, the ROG branch always appends (task {self.artifact_job.rog.build_task_id}); consider guarding against missing or empty build_task_id to avoid emitting (task None) or (task ) in the ID.
  • The RoG tests construct very similar RoG, Event, and ArtifactJob instances repeatedly; consider extracting a small factory/helper or shared fixture to reduce duplication and make future changes to the RoG structure easier.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `IssueHandler.newa_id`, the ROG branch always appends `(task {self.artifact_job.rog.build_task_id})`; consider guarding against missing or empty `build_task_id` to avoid emitting `(task None)` or `(task )` in the ID.
- The RoG tests construct very similar `RoG`, `Event`, and `ArtifactJob` instances repeatedly; consider extracting a small factory/helper or shared fixture to reduce duplication and make future changes to the RoG structure easier.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@kkaarreell kkaarreell merged commit d7956ed into main Jun 11, 2026
16 checks passed
@kkaarreell kkaarreell deleted the ks_fix_mr_id branch June 11, 2026 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant