Skip to content
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

Check of allowed_pr_authors for dist-git PRs with multiple commits is not correct #2271

Closed
lbarcziova opened this issue Dec 7, 2023 · 3 comments
Assignees
Labels
area/fedora Related to Fedora ecosystem gain/high This brings a lot of value to (not strictly a lot of) users. kind/bug Something isn't working.

Comments

@lbarcziova
Copy link
Member

lbarcziova commented Dec 7, 2023

For pushes to dist-git, when downstream Koji builds are configured, we check in case the commit is coming from a PR whether the PR author matches the configuration of allowed_pr_authors.

The problem is in getting the PR here in case we don't react to the head commit (there are multiple commits in the PR and the head commit doesn't have specfile change):

def pull_request(self):
if not self._pull_request and self.data.event_dict["committer"] == "pagure":
logger.debug(
f"Getting pull request with head commit {self.data.commit_sha}"
f"for repo {self.project.namespace}/{self.project.repo}"
)
prs = [
pr
for pr in self.project.get_pr_list(status=PRStatus.all)
if pr.head_commit == self.data.commit_sha
]
if prs:
self._pull_request = prs[0]
return self._pull_request

Example:

Logs:

2023-11-16T07:03:31.506+00:00	Getting pull request with head commit 43b577b8642d26db0509c342d3c2dfcf674320a9for repo rpms/python-ibm-cloud-sdk-core
2023-11-16T07:03:32.091+00:00	PR author: None
2023-11-16T07:03:32.092+00:00	Push event rawhide with corresponding PR created by None that is not allowed in project configuration: ['packit'].
@lbarcziova lbarcziova added kind/bug Something isn't working. area/fedora Related to Fedora ecosystem labels Dec 7, 2023
@lbarcziova lbarcziova added the gain/high This brings a lot of value to (not strictly a lot of) users. label Dec 7, 2023
@lbarcziova lbarcziova moved this from new to ready-to-refine in Packit Kanban Board Dec 7, 2023
@lachmanfrantisek lachmanfrantisek moved this from ready-to-refine to refined in Packit Kanban Board Dec 7, 2023
@lbarcziova lbarcziova moved this from refined to in-progress in Packit Kanban Board Dec 8, 2023
@lbarcziova lbarcziova self-assigned this Dec 8, 2023
lbarcziova added a commit to lbarcziova/ogr that referenced this issue Dec 11, 2023
lbarcziova added a commit to lbarcziova/packit-service-fedmsg that referenced this issue Dec 11, 2023
The check will be done later in the packit-service.

Related to packit/packit-service#2271
@lbarcziova
Copy link
Member Author

I opened draft PRs for the proposed solution: packit/ogr#826, #2275 and packit/packit-service-fedmsg#99 - in fedmsg, filter the pushes (with the check for specfile changes) only if the commit doesn't come from a PR. If the commit comes for a PR, we should run the Koji build for the head commit of the PR which doesn't necessarily have to have the specfile change, so we will now check whether the whole PR has a specfile change. WDYT about this solution?

@nforro
Copy link
Member

nforro commented Dec 11, 2023

I think it makes sense, but it doesn't solve the case when someone pushes multiple commits directly (with the HEAD commit not containing a spec file change), right? That could theoretically happen if someone follows this workflow: https://packit.dev/docs/fedora-releases-guide#keeping-dist-git-branches-non-divergent

@lbarcziova
Copy link
Member Author

lbarcziova commented Dec 11, 2023

good point, but I have to correct myself, after looking into the code of running the build, we just checkout the corresponding dist-git branch and do not checkout the specific commit, so that should be ok.

But this proabbly still seems to me like one of the easier solutions, as I haven't found a way (API) to get a list of all commits of a Pagure PR => a way of getting the PR from a commit that is not the first/last commit of a PR (that way, only the method for getting the corresponding PR would need to be adjusted).

lbarcziova added a commit to lbarcziova/ogr that referenced this issue Dec 12, 2023
lbarcziova added a commit to lbarcziova/ogr that referenced this issue Dec 12, 2023
softwarefactory-project-zuul bot added a commit to packit/ogr that referenced this issue Dec 12, 2023
Implement get_pr_diff for Pagure

Needed for packit/packit-service#2271
TODO:

 test

RELEASE NOTES BEGIN
There is a new get_pr_files_diff method supported for Pagure.
RELEASE NOTES END

Reviewed-by: František Lachman <[email protected]>
lbarcziova added a commit to lbarcziova/packit-service-fedmsg that referenced this issue Dec 12, 2023
The check will be done later in the packit-service.

Related to packit/packit-service#2271
softwarefactory-project-zuul bot added a commit that referenced this issue Dec 15, 2023
Adjust check of dist-git PRs for Koji builds

If the dist-git push comes from a PR, check that
the specfile was changed in that PR.
Related to #2271
Needs packit/ogr#826
TODO:

 Write new tests or update the old ones to cover new functionality.


RELEASE NOTES BEGIN
We have fixed a bug of not running Koji builds for Packit PRs with multiple commits if the last commit of the PR did not contain the specfile change.
RELEASE NOTES END

Reviewed-by: Nikola Forró
Reviewed-by: Laura Barcziová
Reviewed-by: František Lachman <[email protected]>
Reviewed-by: Maja Massarini
lbarcziova added a commit to lbarcziova/packit-service-fedmsg that referenced this issue Dec 15, 2023
The check will be done later in the packit-service.

Related to packit/packit-service#2271
softwarefactory-project-zuul bot added a commit to packit/packit-service-fedmsg that referenced this issue Dec 15, 2023
Skip the specfile changed check for PR pushes

The check will be done later in the packit-service.
Related to packit/packit-service#2271

Reviewed-by: František Lachman <[email protected]>
Reviewed-by: Nikola Forró
@github-project-automation github-project-automation bot moved this from in-progress to done in Packit Kanban Board Dec 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/fedora Related to Fedora ecosystem gain/high This brings a lot of value to (not strictly a lot of) users. kind/bug Something isn't working.
Projects
Archived in project
Development

No branches or pull requests

2 participants