Skip to content

Allow retriggering builds/tests on ELN rawhide PRs independently#3032

Open
betulependule wants to merge 9 commits intopackit:mainfrom
betulependule:trigger-job-for-branch
Open

Allow retriggering builds/tests on ELN rawhide PRs independently#3032
betulependule wants to merge 9 commits intopackit:mainfrom
betulependule:trigger-job-for-branch

Conversation

@betulependule
Copy link
Contributor

@betulependule betulependule commented Mar 2, 2026

TODO:

  • Write new tests or update the old ones to cover new functionality.
  • Update doc-strings where appropriate.
  • Update or write new documentation in packit/packit.dev.

NOTE 1
When figuring out how to implement this PR, I noticed that separate handlers are run when running jobs for eln and rawhide. This implementation is based on discarding the one handler associated with the jobs that are not needed (removing it from the handlers_triggered_by_job variable). For example:

/packit-ci test rpminspect eln

Would lead to the handler corresponding with the rawhide target being removed from the list of handlers to be run. It's possible that there could be a better way of implementing this.

NOTE 2
I implemented the retriggering comment syntax as was described in the issue. However, having it implemented as a positional argument means that comments like this are valid:

/packit-ci test custom eln
/packit-ci build rawhide

But the following would be invalid and lead to a parsing error because of the missing positional argument before eln (the first positional argument cannot be missing if the second one is present):

/packit-ci test eln

If needed, I could instead turn the new argument into a keyword argument like this:

/packit-ci test --target-branch eln

EDIT: I've made it into a keyword argument in the second commit. I should probably write a new test to test the functionality of /packit-ci test --target-branch eln.

Fixes #2958

RELEASE NOTES BEGIN

In Fedora CI, it is now possible to retrigger builds and tests on ELN rawhide PRs independently.

RELEASE NOTES END

Copy link
Contributor

@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 introduces a mechanism to independently retrigger builds and tests for eln and rawhide on Fedora CI pull requests. The implementation adds a new argument to the comment parser and a decorator to map handlers to specific branches. The changes are well-implemented and include thorough test coverage.

My feedback includes a suggestion to improve the user experience by changing the new command-line argument from positional to a keyword argument, which would make it more explicit and less prone to user error. I also noted a minor type inconsistency in a new helper function and provided a fix.

@centosinfra-prod-github-app
Copy link
Contributor

@betulependule betulependule force-pushed the trigger-job-for-branch branch 2 times, most recently from 9bf9816 to 689a6b2 Compare March 2, 2026 09:22
@centosinfra-prod-github-app
Copy link
Contributor

@centosinfra-prod-github-app
Copy link
Contributor

@betulependule betulependule force-pushed the trigger-job-for-branch branch from 689a6b2 to 5f888f5 Compare March 2, 2026 09:33
@centosinfra-prod-github-app
Copy link
Contributor

@nforro
Copy link
Member

nforro commented Mar 2, 2026

/packit test custom eln

What's invalid about this? Isn't it the same pattern as /packit test rpminspect eln above it? (I assume /packit should be /packit-ci).

@betulependule
Copy link
Contributor Author

What's invalid about this? Isn't it the same pattern as /packit test rpminspect eln above it? (I assume /packit should be /packit-ci).

That command is definitely valid. The line regarding a command not being valid was referring to the following command below:

But this would be invalid and lead to a parsing error because of the missing positional argument before eln (the first positional argument cannot be missing if the second one is present):

/packit-ci test eln

I've edited /packit to /packit-ci for consistency.

@centosinfra-prod-github-app
Copy link
Contributor

@centosinfra-prod-github-app
Copy link
Contributor

@centosinfra-prod-github-app
Copy link
Contributor

@centosinfra-prod-github-app
Copy link
Contributor

@betulependule betulependule force-pushed the trigger-job-for-branch branch from 7863486 to bf7cdb6 Compare March 4, 2026 09:56
@centosinfra-prod-github-app
Copy link
Contributor

@betulependule betulependule force-pushed the trigger-job-for-branch branch from bf7cdb6 to f4a319b Compare March 4, 2026 10:09
@centosinfra-prod-github-app
Copy link
Contributor

@lbarcziova lbarcziova moved this from New to In review in Packit pull requests Mar 4, 2026
Comment on lines +73 to +103
MAP_TARGET_BRANCH_TO_HANDLER: dict[type["FedoraCIJobHandler"], str] = defaultdict(str)


def corresponds_to_check_target_branch(check_target_branch: str):
"""
[class decorator]
Specify which target branch the handler corresponds to.

Normally, when retriggering jobs for eln packages on a PR against the
rawhide branch, jobs would be run for both the rawhide and eln targets.
When the check target branch is specified like this,

/packit-ci test installability rawhide

then only the handler corresponding to the specified target branch
(rawhide in this example) will be run, resulting in jobs being run
only for the desired target.

Example:
```
@corresponds_to_check_target_branch(check_target_branch="rawhide")
class DownstreamKojiScratchBuildHandler(
```
"""

def _add_to_mapping(kls: type["FedoraCIJobHandler"]):
MAP_TARGET_BRANCH_TO_HANDLER[kls] = check_target_branch
return kls

return _add_to_mapping

Copy link
Member

Choose a reason for hiding this comment

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

While this isn't user facing, it's still technically incorrect to call it target branch. Could you rename the variables/functions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes definitely. Thank you for pointing this out.

def report_task_accepted_for_fedora_ci(
self,
handler_kls: type[FedoraCIJobHandler],
user_specified_target_branch: Optional[str] = None,
Copy link
Member

Choose a reason for hiding this comment

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

This one is a bit tricky, FedoraCIHelper has target_branch attribute that comes from a target_branch argument of StatusReporter.set_status() and was originally used for target branch, but now it's actually the build target (in eln and main cases). But I would probably keep this as it is.

test_parser = subparsers.add_parser("test", help="Run tests in Testing Farm")
test_parser.add_argument(
"target",
"test_type",
Copy link
Member

Choose a reason for hiding this comment

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

In the docs we call these test identifiers, I often refer to them as checks, technically they are fmf/tmt test plans, it's a bit of a mess 😅 We should figure out consistent naming, but for this particular case test_identifier sounds better to me than test_type.

@centosinfra-prod-github-app
Copy link
Contributor

Merge Failed.

This change or one of its cross-repo dependencies was unable to be automatically merged with the current state of its repository. Please rebase the change and upload a new patchset.
Warning:
Error merging github.com/packit/packit-service for 3032,7a3e9970deb66587720192382cb075b1a8242e68

betulependule and others added 9 commits March 5, 2026 11:33
The check should pass when using the `--target-branch` argument.
There is no need to skip it.
Co-authored-by: Nikola Forró <nforro@redhat.com>
Fedora CI arguments have been changed for clarity and factual
correctness.
The functionality defined in `filter_handlers_based_on_branch_fedora_ci`
has been moved to `get_handlers_for_command_fedora_ci`.
@betulependule betulependule force-pushed the trigger-job-for-branch branch from 7a3e997 to 82ca6e8 Compare March 5, 2026 10:33
@centosinfra-prod-github-app
Copy link
Contributor

Copy link
Member

@nforro nforro left a comment

Choose a reason for hiding this comment

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

Thanks! Could you just squash the commits?

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

Labels

None yet

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

Allow retriggering builds/tests on ELN rawhide PRs independently

3 participants