-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Retrigger downstream koji builds #1586
Retrigger downstream koji builds #1586
Conversation
Build failed. ✔️ pre-commit SUCCESS in 2m 08s |
3d798a1
to
79d5003
Compare
Build succeeded. ✔️ pre-commit SUCCESS in 2m 24s |
79d5003
to
7d031e2
Compare
Build succeeded. ✔️ pre-commit SUCCESS in 2m 03s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a one comment about checking whether user who triggers the jobs have write access to the dist-git repository so we don't write duplicated code. Feel free to ignore the other suggestions since they are just nitpicks :D
@@ -461,6 +464,19 @@ def pre_check(self) -> bool: | |||
f"configuration: {self.job_config.allowed_committers}." | |||
) | |||
return False | |||
elif self.data.event_type in (PullRequestCommentPagureEvent.__name__,): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see that we are doing similar thing here (I am implementing #1541). Can you please move this elif
block to the method into JobHandler
superclass so I can later use it in CreateBodhiUpdateHandler
? Just moving this block of code to separated method in the superclass is enough... I will update this method later to fit the needs of both cases.
(Or if you want, replacing the koji builds
part in the stings with some variable should be enough)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I have fixed it, as Laura wrote maybe I am doing the wrong check now, I will move it in a separate method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved the check in a separate method, but in the same class. I am not really sure you should reuse this check. I think that not every packager (as is for the koji-build
) should be able to do a bodhi-update
but I may be wrong.
@@ -90,11 +90,18 @@ def get_dict(self, default_dict: Optional[Dict] = None) -> dict: | |||
return result | |||
|
|||
def get_base_project(self) -> GitProject: | |||
if isinstance(self, PullRequestCommentPagureEvent): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
personal preference: I would use ternary operator here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe I am missing something, but since this is a method of PullRequestCommentPagureEvent
, can the else
block happen?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes you are right! I was thinking of being in a more general PagureEvent...
packit_service/worker/jobs.py
Outdated
self.event, PullRequestCommentPagureEvent | ||
): | ||
if ( | ||
job.type == JobType.koji_build |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
personal preference: It would be awesome if you named this longer condition so that it's clear to a person what it means without a few extra seconds of thinking (yes, I am a lazy person :D). What about reusing the comment you posted bellow "A koji_build can be retriggered by a Pagure comment in a PR"... so something like can_koji_build_be_retriggered
?
packit_service/worker/jobs.py
Outdated
and self.event.job_config_trigger_type | ||
== JobConfigTriggerType.pull_request | ||
): | ||
"A koji_build can be retriggered by a Pagure comment in a PR" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"A koji_build can be retriggered by a Pagure comment in a PR" | |
# A koji_build can be retriggered by a Pagure comment in a PR |
7d031e2
to
ec89652
Compare
Build succeeded. ✔️ pre-commit SUCCESS in 2m 11s |
logger.debug( | ||
f"Triggering downstream koji build through comment by: {commenter}" | ||
) | ||
if commenter not in self.job_config.allowed_committers: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since this is an explicit comment, I think the commenter doesn't need to be allowed in the project configuration but only has a write access to the dist-git repo...but maybe we can discuss it on standup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, so if I understand it correctly: re-triggering a koji-build through a comment should be allowed to more developers.
Some of them, which may be not allowed to do a koji-build through propose-downstream are instead allowed to re-trigger someone else propose-downstream koji-builds, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my thinking was that with the configurable allowed_committers
and allowed_pr_authors
we wanted to preserve the proven packager workflow, but if someone explicitly creates a comment to retrigger the build, it doesn't make that much sense to me to require this user to be allowed in the configuration...@lachmanfrantisek what do you think? should we discuss this in a meeting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the conclusion from the architecture discussion: we will only require the user who retriggers the koji build by a dist-git comment to be a packager
@@ -479,9 +495,14 @@ def run(self) -> TaskResults: | |||
self.job_config, | |||
downstream_local_project=self.local_project, | |||
) | |||
branch = ( | |||
self.project.get_pr(self.data.pr_id).source_branch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we are interested in the branch the changes were merged into, so I think this should be the target_branch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, thanks. I was not sure. Just a thing I do not understand: if I do checkout the target_branch
I think I do not have all the commits in the PR and thus I perform a koji-build with not all commits. Am I wrong or this is ok for the koji-build we want?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the target_branch
should be up to date
@@ -90,11 +90,18 @@ def get_dict(self, default_dict: Optional[Dict] = None) -> dict: | |||
return result | |||
|
|||
def get_base_project(self) -> GitProject: | |||
if isinstance(self, PullRequestCommentPagureEvent): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe I am missing something, but since this is a method of PullRequestCommentPagureEvent
, can the else
block happen?
ec89652
to
5eefafd
Compare
Build succeeded. ✔️ pre-commit SUCCESS in 3m 08s |
5eefafd
to
476081c
Compare
Build succeeded. ✔️ pre-commit SUCCESS in 1m 59s |
476081c
to
445f515
Compare
Build succeeded. ✔️ pre-commit SUCCESS in 3m 50s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done! Thanks!
packit_service/worker/jobs.py
Outdated
def allow_non_matching_events(self): | ||
"""Do explicit exceptions for non matching event/jobs triggers | ||
|
||
Returns: | ||
list of jobs | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am still wondering why is this needed and if we can't fix this elsewhere. This is because of the commit
vs pull_request
trigger, isn't it?
TBH, I was a bit confused by the method name and docstring. Could you please rename it to something like check_manual_mapping
/check_explicit_matching
/.. or something like that? (From the name, I thought we are allowing any combination...;) And then, I've seen the word exception
and was confused completely..;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes this is because of the commit
vs pull_request
trigger.
I may be wrong but I don't see how to allow this without this hack.
But we could probably ask to the users to put in their configuration a job with trigger pull_request
for the koji_build
if they want to trigger it through a comment in a pull_request
.
I copied the config file from osbuilder project and they do not have such a job in their config, they only have a koji_build
job triggered by a commit
and I wanted my code to be able to trigger a build with their configuration.
But I can remove this lines if we agree that a change in the config file should be needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I don't think we should ask users to add another job. (It's same as with the propose-downstream
where nothing is needed to be able to retrigger the job by an issue comment.)
We can leave it as is and try to refactor it later.
Through Pagure comments on PR
445f515
to
5bb916f
Compare
Build succeeded. ✔️ pre-commit SUCCESS in 2m 24s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks! let's test this on stage
logger.debug( | ||
f"Triggering downstream koji build through comment by: {commenter}" | ||
) | ||
if not self.is_packager(commenter): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in this case, it could be nice to notify user about this, but we can discuss if and how we want to do it (PR comment?) as a follow-up and be also consistent with retriggering bodhi updates
Build succeeded (gate pipeline). ✔️ pre-commit SUCCESS in 2m 02s |
Through a Pagure comment in a PR
Fixes #1540
Merge after packit/packit-service-fedmsg#70
RELEASE NOTES BEGIN
A downstream koji-build can now be re-triggered commenting in a PR like this:
/packit koji-build
.RELEASE NOTES END