Skip to content

Conversation

@sundaram123krishnan
Copy link

@sundaram123krishnan sundaram123krishnan commented Dec 27, 2025

Fixes #2844

Make builds repeatable when SRPM build is successful but failed to import to dist-git.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly implements the logic to allow resubmission of builds that fail during the SRPM import phase. The changes in the Build model and the backend view are logical and are accompanied by new tests. I have provided a couple of suggestions to improve code conciseness and test coverage.

Comment on lines +1396 to +1401
if self.source_status == StatusEnum("succeeded"):
return True
if (self.source_status == StatusEnum("failed") and
self.fail_type == FailTypeEnum("srpm_import_failed")):
return True
return False

Choose a reason for hiding this comment

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

medium

The logic for determining if a build is repeatable can be simplified into a single boolean expression. This improves conciseness and readability.

        return (self.source_status == StatusEnum("succeeded") or
                (self.source_status == StatusEnum("failed") and
                 self.fail_type == FailTypeEnum("srpm_import_failed")))

Comment on lines 192 to 205
def test_repeatable_succeeded(self, f_users, f_coprs, f_builds, f_db):
"""
Test that builds with succeeded source_status are repeatable.
"""
self.b1.source_status = StatusEnum("succeeded")
assert self.b1.repeatable

def test_repeatable_import_failed(self, f_users, f_coprs, f_builds, f_db):
"""
Test that builds which failed during import phase are repeatable.
"""
self.b1.source_status = StatusEnum("failed")
self.b1.fail_type = FailTypeEnum("srpm_import_failed")
assert self.b1.repeatable

Choose a reason for hiding this comment

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

medium

The new tests cover the cases where a build should be repeatable. It would be beneficial to also add test cases for when a build is not repeatable to ensure the logic is fully covered. For example, when a build fails for a different reason or is in a different state.

    def test_repeatable_succeeded(self, f_users, f_coprs, f_builds, f_db):
        """
        Test that builds with succeeded source_status are repeatable.
        """
        self.b1.source_status = StatusEnum("succeeded")
        assert self.b1.repeatable

    def test_repeatable_import_failed(self, f_users, f_coprs, f_builds, f_db):
        """
        Test that builds which failed during import phase are repeatable.
        """
        self.b1.source_status = StatusEnum("failed")
        self.b1.fail_type = FailTypeEnum("srpm_import_failed")
        assert self.b1.repeatable

    def test_not_repeatable(self, f_users, f_coprs, f_builds, f_db):
        """
        Test that builds that failed for other reasons are not repeatable.
        """
        # failed for another reason
        self.b1.source_status = StatusEnum("failed")
        self.b1.fail_type = FailTypeEnum("unknown_error")
        assert not self.b1.repeatable

        # still running
        self.b1.source_status = StatusEnum("running")
        self.b1.fail_type = FailTypeEnum("unset")
        assert not self.b1.repeatable

        # just failed, but fail_type is not set
        self.b1.source_status = StatusEnum("failed")
        self.b1.fail_type = FailTypeEnum("unset")
        assert not self.b1.repeatable

@github-actions
Copy link

Pull Request validation

Failed

🔴 Review - Missing review from a member (2 required)

Success

🟢 CI - All checks have passed

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.

Can't retrigger the build upon an unsuccessful srpm build or import

1 participant