From b5ff71c62637b6a79cbf7ce480e5061ee011e2a6 Mon Sep 17 00:00:00 2001 From: Matej Focko Date: Tue, 28 Jan 2025 15:50:43 +0100 Subject: [PATCH] =?UTF-8?q?fix(events):=20rename=20from=20=E2=80=B9Synchro?= =?UTF-8?q?nize=E2=80=BA=20to=20=E2=80=B9Action=E2=80=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Matej Focko --- packit_service/worker/allowlist.py | 12 +-- packit_service/worker/checker/copr.py | 2 +- packit_service/worker/checker/koji.py | 6 +- packit_service/worker/checker/testing_farm.py | 2 +- packit_service/worker/events/event_data.py | 6 +- packit_service/worker/events/github/pr.py | 4 +- packit_service/worker/events/gitlab/mr.py | 10 +- packit_service/worker/events/pagure/pr.py | 4 +- packit_service/worker/handlers/copr.py | 4 +- packit_service/worker/handlers/distgit.py | 2 +- packit_service/worker/handlers/koji.py | 4 +- .../worker/handlers/testing_farm.py | 4 +- packit_service/worker/helpers/testing_farm.py | 4 +- packit_service/worker/jobs.py | 2 +- packit_service/worker/parser.py | 18 ++-- tests/conftest.py | 4 +- tests/unit/events/test_github.py | 4 +- tests/unit/events/test_gitlab.py | 6 +- tests/unit/events/test_pagure.py | 6 +- tests/unit/test_allowlist.py | 10 +- tests/unit/test_checkers.py | 20 ++-- tests/unit/test_copr_build.py | 6 +- tests/unit/test_jobs.py | 102 +++++++++--------- tests/unit/test_koji_build.py | 2 +- tests/unit/test_srpm_logs.py | 4 +- tests/unit/test_testing_farm.py | 8 +- tests_openshift/database/test_events.py | 6 +- 27 files changed, 130 insertions(+), 132 deletions(-) diff --git a/packit_service/worker/allowlist.py b/packit_service/worker/allowlist.py index 4402ffdac..474920b2b 100644 --- a/packit_service/worker/allowlist.py +++ b/packit_service/worker/allowlist.py @@ -49,7 +49,7 @@ koji.Task, koji.Build, pagure.pr.Comment, - pagure.pr.Synchronize, + pagure.pr.Action, pagure.push.Commit, testing_farm.Result, ] @@ -314,9 +314,9 @@ def _check_release_push_event( def _check_pr_event( self, event: Union[ - github.pr.Synchronize, + github.pr.Action, github.pr.Comment, - gitlab.mr.Synchronize, + gitlab.mr.Action, gitlab.mr.Comment, ], project: GitProject, @@ -500,7 +500,7 @@ def check_and_report( ] = { ( # events that are not checked against allowlist pagure.push.Commit, - pagure.pr.Synchronize, + pagure.pr.Action, pagure.pr.Comment, copr.CoprBuild, testing_farm.Result, @@ -520,9 +520,9 @@ def check_and_report( gitlab.push.Commit, ): self._check_release_push_event, ( - github.pr.Synchronize, + github.pr.Action, github.pr.Comment, - gitlab.mr.Synchronize, + gitlab.mr.Action, gitlab.mr.Comment, ): self._check_pr_event, ( diff --git a/packit_service/worker/checker/copr.py b/packit_service/worker/checker/copr.py index f36bead2f..d56a63dfc 100644 --- a/packit_service/worker/checker/copr.py +++ b/packit_service/worker/checker/copr.py @@ -40,7 +40,7 @@ def pre_check( self, ) -> bool: if ( - self.data.event_type == gitlab.mr.Synchronize.event_type() + self.data.event_type == gitlab.mr.Action.event_type() and self.data.event_dict["action"] == gitlab.enums.Action.closed.value ): # Not interested in closed merge requests diff --git a/packit_service/worker/checker/koji.py b/packit_service/worker/checker/koji.py index ecbf90a3f..5f10cb989 100644 --- a/packit_service/worker/checker/koji.py +++ b/packit_service/worker/checker/koji.py @@ -31,15 +31,15 @@ def pre_check(self) -> bool: class PermissionOnKoji(Checker, GetKojiBuildJobHelperMixin): def pre_check(self) -> bool: if ( - self.data.event_type == gitlab.mr.Synchronize.event_type() + self.data.event_type == gitlab.mr.Action.event_type() and self.data.event_dict["action"] == gitlab.enums.Action.closed.value ): # Not interested in closed merge requests return False if self.data.event_type in ( - github.pr.Synchronize.event_type(), - gitlab.mr.Synchronize.event_type(), + github.pr.Action.event_type(), + gitlab.mr.Action.event_type(), ): user_can_merge_pr = self.project.can_merge_pr(self.data.actor) if not (user_can_merge_pr or self.data.actor in self.service_config.admins): diff --git a/packit_service/worker/checker/testing_farm.py b/packit_service/worker/checker/testing_farm.py index 1d2eabc30..d528773b4 100644 --- a/packit_service/worker/checker/testing_farm.py +++ b/packit_service/worker/checker/testing_farm.py @@ -38,7 +38,7 @@ class IsEventOk( ): def pre_check(self) -> bool: if ( - self.data.event_type == gitlab.mr.Synchronize.event_type() + self.data.event_type == gitlab.mr.Action.event_type() and self.data.event_dict["action"] == gitlab.enums.Action.closed.value ): # Not interested in closed merge requests diff --git a/packit_service/worker/events/event_data.py b/packit_service/worker/events/event_data.py index b6cf21534..532ff408e 100644 --- a/packit_service/worker/events/event_data.py +++ b/packit_service/worker/events/event_data.py @@ -152,9 +152,9 @@ def _add_project_object_and_event(self): # TODO, do a better job # Probably, try to recreate original classes. if self.event_type in { - "github.pr.Synchronize", - "pagure.pr.Synchronize", - "gitlab.mr.Synchronize", + "github.pr.Action", + "pagure.pr.Action", + "gitlab.mr.Action", "github.pr.Comment", "pagure.pr.Comment", "gitlab.mr.Comment", diff --git a/packit_service/worker/events/github/pr.py b/packit_service/worker/events/github/pr.py index 65c1953df..f8cfd0391 100644 --- a/packit_service/worker/events/github/pr.py +++ b/packit_service/worker/events/github/pr.py @@ -15,7 +15,7 @@ from packit_service.worker.events.github.abstract import GithubEvent -class Synchronize(AddPullRequestEventToDb, GithubEvent): +class Action(AddPullRequestEventToDb, GithubEvent): def __init__( self, action: PullRequestAction, @@ -43,7 +43,7 @@ def __init__( @classmethod def event_type(cls) -> str: - return "github.pr.Synchronize" + return "github.pr.Action" def get_dict(self, default_dict: Optional[dict] = None) -> dict: result = super().get_dict() diff --git a/packit_service/worker/events/gitlab/mr.py b/packit_service/worker/events/gitlab/mr.py index 3c7d084aa..21de46b15 100644 --- a/packit_service/worker/events/gitlab/mr.py +++ b/packit_service/worker/events/gitlab/mr.py @@ -14,13 +14,13 @@ ) from .abstract import GitlabEvent -from .enums import Action +from .enums import Action as GitlabAction -class Synchronize(AddPullRequestEventToDb, GitlabEvent): +class Action(AddPullRequestEventToDb, GitlabEvent): def __init__( self, - action: Action, + action: GitlabAction, actor: str, object_id: int, object_iid: int, @@ -62,7 +62,7 @@ def __init__( @classmethod def event_type(cls) -> str: - return "gitlab.mr.Synchronize" + return "gitlab.mr.Action" def get_dict(self, default_dict: Optional[dict] = None) -> dict: result = super().get_dict() @@ -79,7 +79,7 @@ def get_base_project(self) -> GitProject: class Comment(AbstractPRCommentEvent, GitlabEvent): def __init__( self, - action: Action, + action: GitlabAction, object_id: int, object_iid: int, source_repo_namespace: str, diff --git a/packit_service/worker/events/pagure/pr.py b/packit_service/worker/events/pagure/pr.py index 29a4301c7..870d358d3 100644 --- a/packit_service/worker/events/pagure/pr.py +++ b/packit_service/worker/events/pagure/pr.py @@ -145,7 +145,7 @@ def repo_name(self) -> Optional[str]: return self.repo_url.repo if self.repo_url else None -class Synchronize(AddPullRequestEventToDb, PagureEvent): +class Action(AddPullRequestEventToDb, PagureEvent): def __init__( self, action: PullRequestAction, @@ -176,7 +176,7 @@ def __init__( @classmethod def event_type(cls) -> str: - return "pagure.pr.Synchronize" + return "pagure.pr.Action" def get_dict(self, default_dict: Optional[dict] = None) -> dict: result = super().get_dict() diff --git a/packit_service/worker/handlers/copr.py b/packit_service/worker/handlers/copr.py index 7fdbe0e5e..fc0d9f048 100644 --- a/packit_service/worker/handlers/copr.py +++ b/packit_service/worker/handlers/copr.py @@ -77,10 +77,10 @@ @run_for_check_rerun(prefix="rpm-build") @reacts_to(github.release.Release) @reacts_to(gitlab.release.Release) -@reacts_to(github.pr.Synchronize) +@reacts_to(github.pr.Action) @reacts_to(github.push.Commit) @reacts_to(gitlab.push.Commit) -@reacts_to(gitlab.mr.Synchronize) +@reacts_to(gitlab.mr.Action) @reacts_to(github.check.Rerun) @reacts_to(abstract.comment.Commit) @reacts_to(abstract.comment.PullRequest) diff --git a/packit_service/worker/handlers/distgit.py b/packit_service/worker/handlers/distgit.py index 461c8aada..0d2fdbf9b 100644 --- a/packit_service/worker/handlers/distgit.py +++ b/packit_service/worker/handlers/distgit.py @@ -734,7 +734,7 @@ def run(self) -> TaskResults: return super().run() -@reacts_to_as_fedora_ci(event=pagure.pr.Synchronize) +@reacts_to_as_fedora_ci(event=pagure.pr.Action) class DownstreamKojiScratchBuildHandler( RetriableJobHandler, ConfigFromUrlMixin, LocalProjectMixin, PackitAPIWithDownstreamMixin ): diff --git a/packit_service/worker/handlers/koji.py b/packit_service/worker/handlers/koji.py index 5520c0ba8..eb1e9e4a1 100644 --- a/packit_service/worker/handlers/koji.py +++ b/packit_service/worker/handlers/koji.py @@ -81,10 +81,10 @@ @run_for_check_rerun(prefix="koji-build") @reacts_to(github.release.Release) @reacts_to(gitlab.release.Release) -@reacts_to(github.pr.Synchronize) +@reacts_to(github.pr.Action) @reacts_to(github.push.Commit) @reacts_to(gitlab.push.Commit) -@reacts_to(gitlab.mr.Synchronize) +@reacts_to(gitlab.mr.Action) @reacts_to(abstract.comment.PullRequest) @reacts_to(github.check.Rerun) class KojiBuildHandler( diff --git a/packit_service/worker/handlers/testing_farm.py b/packit_service/worker/handlers/testing_farm.py index b334c237e..c359e053e 100644 --- a/packit_service/worker/handlers/testing_farm.py +++ b/packit_service/worker/handlers/testing_farm.py @@ -72,10 +72,10 @@ @run_for_check_rerun(prefix="testing-farm") @reacts_to(github.release.Release) @reacts_to(gitlab.release.Release) -@reacts_to(github.pr.Synchronize) +@reacts_to(github.pr.Action) @reacts_to(github.push.Commit) @reacts_to(gitlab.push.Commit) -@reacts_to(gitlab.mr.Synchronize) +@reacts_to(gitlab.mr.Action) @reacts_to(abstract.comment.PullRequest) @reacts_to(github.check.PullRequest) @reacts_to(github.check.Commit) diff --git a/packit_service/worker/helpers/testing_farm.py b/packit_service/worker/helpers/testing_farm.py index 782e9798f..fc2abdaac 100644 --- a/packit_service/worker/helpers/testing_farm.py +++ b/packit_service/worker/helpers/testing_farm.py @@ -334,10 +334,10 @@ def build_required(self) -> bool: self.metadata.event_type in ( github.push.Commit.event_type(), - github.pr.Synchronize.event_type(), + github.pr.Action.event_type(), github.commit.Comment.event_type(), gitlab.push.Commit.event_type(), - gitlab.mr.Synchronize.event_type(), + gitlab.mr.Action.event_type(), gitlab.commit.Comment.event_type(), ) or self.is_copr_build_comment_event() diff --git a/packit_service/worker/jobs.py b/packit_service/worker/jobs.py index 90b1be94d..1f42a1c68 100644 --- a/packit_service/worker/jobs.py +++ b/packit_service/worker/jobs.py @@ -231,7 +231,7 @@ def process(self) -> list[TaskResults]: # should we comment about not processing if the comment is not # on the issue created by us or not in packit/notifications? elif ( - isinstance(self.event, (pagure.pr.Synchronize, koji.Task)) + isinstance(self.event, (pagure.pr.Action, koji.Task)) and self.event.db_project_object and (url := self.event.db_project_object.project.project_url) and url in self.service_config.enabled_projects_for_fedora_ci diff --git a/packit_service/worker/parser.py b/packit_service/worker/parser.py index dbdf36f30..71240e8e2 100644 --- a/packit_service/worker/parser.py +++ b/packit_service/worker/parser.py @@ -76,14 +76,14 @@ def parse_event( github.check.PullRequest, github.check.Release, github.pr.Comment, - github.pr.Synchronize, + github.pr.Action, github.issue.Comment, github.installation.Installation, github.push.Commit, github.release.Release, gitlab.issue.Comment, gitlab.mr.Comment, - gitlab.mr.Synchronize, + gitlab.mr.Action, gitlab.pipeline.Pipeline, gitlab.push.Commit, gitlab.push.Tag, @@ -95,7 +95,7 @@ def parse_event( openscanhub.task.Started, pagure.pr.Comment, pagure.pr.Flag, - pagure.pr.Synchronize, + pagure.pr.Action, pagure.push.Commit, testing_farm.Result, vm_image.Result, @@ -158,7 +158,7 @@ def parse_event( return None @staticmethod - def parse_mr_event(event) -> Optional[gitlab.mr.Synchronize]: + def parse_mr_event(event) -> Optional[gitlab.mr.Action]: """Look into the provided event and see if it's one for a new gitlab MR.""" if event.get("object_kind") != "merge_request": return None @@ -220,7 +220,7 @@ def parse_mr_event(event) -> Optional[gitlab.mr.Synchronize]: description = nested_get(event, "object_attributes", "description") url = nested_get(event, "object_attributes", "url") - return gitlab.mr.Synchronize( + return gitlab.mr.Action( action=gitlab.enums.Action[action], actor=actor, object_id=object_id, @@ -241,7 +241,7 @@ def parse_mr_event(event) -> Optional[gitlab.mr.Synchronize]: ) @staticmethod - def parse_pr_event(event) -> Optional[github.pr.Synchronize]: + def parse_pr_event(event) -> Optional[github.pr.Action]: """Look into the provided event and see if it's one for a new github PR.""" if not event.get("pull_request"): return None @@ -293,7 +293,7 @@ def parse_pr_event(event) -> Optional[github.pr.Synchronize]: commit_sha = nested_get(event, "pull_request", "head", "sha") https_url = event["repository"]["html_url"] - return github.pr.Synchronize( + return github.pr.Action( action=PullRequestAction[action], pr_id=pr_id, base_repo_namespace=base_repo_namespace, @@ -1673,7 +1673,7 @@ def parse_pagure_pull_request_comment_event( @staticmethod def parse_pagure_pull_request_event( event, - ) -> Optional[pagure.pr.Synchronize]: + ) -> Optional[pagure.pr.Action]: if (topic := event.get("topic", "")) not in ( "org.fedoraproject.prod.pagure.pull-request.new", "org.fedoraproject.prod.pagure.pull-request.updated", @@ -1700,7 +1700,7 @@ def parse_pagure_pull_request_event( commit_sha = event["pullrequest"]["commit_stop"] target_branch = event["pullrequest"]["branch"] - return pagure.pr.Synchronize( + return pagure.pr.Action( action=PullRequestAction[action], pr_id=pr_id, base_repo_namespace=base_repo_namespace, diff --git a/tests/conftest.py b/tests/conftest.py index 2179047c7..27da58134 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -501,7 +501,7 @@ def github_vm_image_build_comment(): @pytest.fixture(scope="module") -def github_pr_event(github_pr_webhook) -> events.github.pr.Synchronize: +def github_pr_event(github_pr_webhook) -> events.github.pr.Action: return Parser.parse_pr_event(github_pr_webhook) @@ -528,7 +528,7 @@ def distgit_push_event(distgit_push_packit) -> events.pagure.push.Commit: @pytest.fixture(scope="module") -def gitlab_mr_event(gitlab_mr_webhook) -> events.gitlab.mr.Synchronize: +def gitlab_mr_event(gitlab_mr_webhook) -> events.gitlab.mr.Action: return Parser.parse_mr_event(gitlab_mr_webhook) diff --git a/tests/unit/events/test_github.py b/tests/unit/events/test_github.py index c4f89af89..ba686fd67 100644 --- a/tests/unit/events/test_github.py +++ b/tests/unit/events/test_github.py @@ -131,7 +131,7 @@ def test_parse_release(github_release_webhook): def test_parse_pr(github_pr_webhook): event_object = Parser.parse_event(github_pr_webhook) - assert isinstance(event_object, pr.Synchronize) + assert isinstance(event_object, pr.Action) assert event_object.action == PullRequestAction.opened assert event_object.pr_id == 342 assert event_object.base_repo_namespace == "lbarcziova" @@ -222,7 +222,7 @@ def test_parse_github_push_branch(github_push_branch): def test_get_project_pr(github_pr_webhook, mock_config): event_object = Parser.parse_event(github_pr_webhook) - assert isinstance(event_object, pr.Synchronize) + assert isinstance(event_object, pr.Action) assert isinstance(event_object.project, GithubProject) assert isinstance(event_object.project.service, GithubService) diff --git a/tests/unit/events/test_gitlab.py b/tests/unit/events/test_gitlab.py index 59fd2a3f6..6aa1a70a5 100644 --- a/tests/unit/events/test_gitlab.py +++ b/tests/unit/events/test_gitlab.py @@ -124,7 +124,7 @@ def test_parse_gitlab_tag_push(gitlab_tag_push): def test_parse_mr(merge_request): event_object = Parser.parse_event(merge_request) - assert isinstance(event_object, mr.Synchronize) + assert isinstance(event_object, mr.Action) assert event_object.action == enums.Action.opened assert event_object.object_id == 58759529 assert event_object.identifier == "1" @@ -157,7 +157,7 @@ def test_parse_mr(merge_request): def test_parse_mr_action(merge_request_update): event_object = Parser.parse_event(merge_request_update) - assert isinstance(event_object, mr.Synchronize) + assert isinstance(event_object, mr.Action) assert event_object.action == enums.Action.update assert event_object.commit_sha == "45e272a57335e4e308f3176df6e9226a9e7805a9" assert event_object.oldrev == "94ccba9f986629e24b432c11d9c7fd20bb2ea51d" @@ -183,7 +183,7 @@ def test_parse_mr_action(merge_request_update): def test_parse_mr_closed(merge_request_closed): event_object = Parser.parse_event(merge_request_closed) - assert isinstance(event_object, mr.Synchronize) + assert isinstance(event_object, mr.Action) assert event_object.action == enums.Action.closed diff --git a/tests/unit/events/test_pagure.py b/tests/unit/events/test_pagure.py index d7dd3d287..1760a25c7 100644 --- a/tests/unit/events/test_pagure.py +++ b/tests/unit/events/test_pagure.py @@ -120,7 +120,7 @@ def test_distgit_pagure_push(distgit_commit): def test_parse_pagure_pull_request_new(pagure_pr_new): event_object = Parser.parse_event(pagure_pr_new) - assert isinstance(event_object, pr.Synchronize) + assert isinstance(event_object, pr.Action) assert event_object.action == PullRequestAction.opened assert event_object.pr_id == 2 assert event_object.base_repo_namespace == "rpms" @@ -157,7 +157,7 @@ def test_parse_pagure_pull_request_new(pagure_pr_new): def test_parse_pagure_pull_request_updated(pagure_pr_updated): event_object = Parser.parse_event(pagure_pr_updated) - assert isinstance(event_object, pr.Synchronize) + assert isinstance(event_object, pr.Action) assert event_object.action == PullRequestAction.synchronize assert event_object.pr_id == 32 assert event_object.base_repo_namespace == "rpms" @@ -194,7 +194,7 @@ def test_parse_pagure_pull_request_updated(pagure_pr_updated): def test_parse_pagure_pull_request_rebased(pagure_pr_rebased): event_object = Parser.parse_event(pagure_pr_rebased) - assert isinstance(event_object, pr.Synchronize) + assert isinstance(event_object, pr.Action) assert event_object.action == PullRequestAction.synchronize assert event_object.pr_id == 6 assert event_object.base_repo_namespace == "rpms" diff --git a/tests/unit/test_allowlist.py b/tests/unit/test_allowlist.py index e951faa05..830d27662 100644 --- a/tests/unit/test_allowlist.py +++ b/tests/unit/test_allowlist.py @@ -485,7 +485,7 @@ def events(request) -> Iterable[tuple[github.abstract.GithubEvent, bool, Iterabl }, ), "pr": ( - github.pr.Synchronize, + github.pr.Action, lambda forge, namespace, repository: { "action": PullRequestAction.opened, "pr_id": 1, @@ -642,7 +642,7 @@ def test_check_and_report( }, ), ] - flexmock(github.pr.Synchronize).should_receive("get_packages_config").and_return( + flexmock(github.pr.Action).should_receive("get_packages_config").and_return( flexmock( jobs=job_configs, get_package_config_for=lambda job_config: flexmock( @@ -676,7 +676,7 @@ def test_check_and_report( if isinstance(event, github.release.Release) and not is_valid: flexmock(git_project).should_receive("get_sha_from_tag") flexmock(git_project).should_receive("commit_comment") - if isinstance(event, github.pr.Synchronize) and not is_valid: + if isinstance(event, github.pr.Action) and not is_valid: notification_project_mock = flexmock() notification_project_mock.should_receive("get_issue_list").with_args( author="packit-as-a-service[bot]", @@ -809,7 +809,7 @@ def test_check_and_report_actor_pull_request( allowlist, add_pull_request_event_with_empty_sha, ): - event = github.pr.Synchronize( + event = github.pr.Action( action=PullRequestAction.opened, pr_id=0, base_repo_namespace="base", @@ -841,7 +841,7 @@ def test_check_and_report_actor_pull_request( }, ), ] - flexmock(github.pr.Synchronize).should_receive("get_packages_config").and_return( + flexmock(github.pr.Action).should_receive("get_packages_config").and_return( flexmock( jobs=job_configs, get_package_config_for=lambda job_config: flexmock( diff --git a/tests/unit/test_checkers.py b/tests/unit/test_checkers.py index 0299f02eb..6f72a8944 100644 --- a/tests/unit/test_checkers.py +++ b/tests/unit/test_checkers.py @@ -75,7 +75,7 @@ def construct_dict(event, action=None, git_ref="random-non-configured-branch"): ( pytest.param( False, - construct_dict(event=gitlab.mr.Synchronize.event_type(), action="closed"), + construct_dict(event=gitlab.mr.Action.event_type(), action="closed"), True, True, JobConfigTriggerType.pull_request, @@ -83,7 +83,7 @@ def construct_dict(event, action=None, git_ref="random-non-configured-branch"): ), pytest.param( False, - construct_dict(event=github.pr.Synchronize.event_type()), + construct_dict(event=github.pr.Action.event_type()), True, False, JobConfigTriggerType.pull_request, @@ -91,7 +91,7 @@ def construct_dict(event, action=None, git_ref="random-non-configured-branch"): ), pytest.param( False, - construct_dict(event=gitlab.mr.Synchronize.event_type()), + construct_dict(event=gitlab.mr.Action.event_type()), True, False, JobConfigTriggerType.pull_request, @@ -99,7 +99,7 @@ def construct_dict(event, action=None, git_ref="random-non-configured-branch"): ), pytest.param( False, - construct_dict(event=gitlab.mr.Synchronize.event_type()), + construct_dict(event=gitlab.mr.Action.event_type()), False, True, JobConfigTriggerType.pull_request, @@ -107,7 +107,7 @@ def construct_dict(event, action=None, git_ref="random-non-configured-branch"): ), pytest.param( True, - construct_dict(event=github.pr.Synchronize.event_type()), + construct_dict(event=github.pr.Action.event_type()), True, True, JobConfigTriggerType.pull_request, @@ -115,7 +115,7 @@ def construct_dict(event, action=None, git_ref="random-non-configured-branch"): ), pytest.param( True, - construct_dict(event=gitlab.mr.Synchronize.event_type()), + construct_dict(event=gitlab.mr.Action.event_type()), True, True, JobConfigTriggerType.pull_request, @@ -237,28 +237,28 @@ def test_branch_push_event_checker(success, event, trigger, checker_kls): pytest.param( "the-branch", True, - construct_dict(event=github.pr.Synchronize.event_type()), + construct_dict(event=github.pr.Action.event_type()), JobConfigTriggerType.pull_request, id="GitHub PR target branch matches", ), pytest.param( "the-other-branch", False, - construct_dict(event=github.pr.Synchronize.event_type()), + construct_dict(event=github.pr.Action.event_type()), JobConfigTriggerType.pull_request, id="GitHub PR target branch does not match", ), pytest.param( "the-branch", True, - construct_dict(event=gitlab.mr.Synchronize.event_type()), + construct_dict(event=gitlab.mr.Action.event_type()), JobConfigTriggerType.pull_request, id="GitLab PR target branch matches", ), pytest.param( "the-other-branch", False, - construct_dict(event=gitlab.mr.Synchronize.event_type()), + construct_dict(event=gitlab.mr.Action.event_type()), JobConfigTriggerType.pull_request, id="GitLab PR target branch does not match", ), diff --git a/tests/unit/test_copr_build.py b/tests/unit/test_copr_build.py index cfb39cfad..249f474a3 100644 --- a/tests/unit/test_copr_build.py +++ b/tests/unit/test_copr_build.py @@ -294,7 +294,7 @@ def test_run_copr_build_from_source_script(github_pr_event, srpm_build_deps): flexmock(CoprBuildTargetModel).should_receive("create").and_return(build) flexmock(CoprBuildGroupModel).should_receive("create").and_return(group) flexmock(CoprBuildTargetModel).should_receive("create").and_return(build).times(4) - flexmock(github.pr.Synchronize).should_receive("db_project_object").and_return( + flexmock(github.pr.Action).should_receive("db_project_object").and_return( flexmock(), ) @@ -399,7 +399,7 @@ def test_run_copr_build_from_source_script_github_outage_retry( flexmock(), ), ) - flexmock(github.pr.Synchronize).should_receive("db_project_object").and_return( + flexmock(github.pr.Action).should_receive("db_project_object").and_return( flexmock(), ) @@ -1024,7 +1024,7 @@ def test_check_if_actor_can_run_job_and_report(jobs, should_pass): package_config, jobs[0], { - "event_type": "github.pr.Synchronize", + "event_type": "github.pr.Action", "actor": "actor", "project_url": "url", "commit_sha": "abcdef", diff --git a/tests/unit/test_jobs.py b/tests/unit/test_jobs.py index 60a5ee79f..c5e460d7d 100644 --- a/tests/unit/test_jobs.py +++ b/tests/unit/test_jobs.py @@ -54,7 +54,7 @@ [ # Single job defined: pytest.param( - github.pr.Synchronize, + github.pr.Action, flexmock(job_config_trigger_type=JobConfigTriggerType.pull_request), [ JobConfig( @@ -64,10 +64,10 @@ ), ], {CoprBuildHandler}, - id="config=build_for_pr&pull_request&github.pr.Synchronize", + id="config=build_for_pr&pull_request&github.pr.Action", ), pytest.param( - github.pr.Synchronize, + github.pr.Action, flexmock(job_config_trigger_type=JobConfigTriggerType.pull_request), [ JobConfig( @@ -77,10 +77,10 @@ ), ], {CoprBuildHandler}, - id="config=copr_build_for_pr&pull_request&github.pr.Synchronize", + id="config=copr_build_for_pr&pull_request&github.pr.Action", ), pytest.param( - github.pr.Synchronize, + github.pr.Action, flexmock(job_config_trigger_type=JobConfigTriggerType.pull_request), [ JobConfig( @@ -90,11 +90,11 @@ ), ], {TestingFarmHandler}, - id="config=test_for_pr&pull_request&github.pr.Synchronize", + id="config=test_for_pr&pull_request&github.pr.Action", ), # Not matching event: pytest.param( - github.pr.Synchronize, + github.pr.Action, flexmock(job_config_trigger_type=JobConfigTriggerType.pull_request), [ JobConfig( @@ -104,11 +104,11 @@ ), ], set(), - id="config=build_for_commit&pull_request&github.pr.Synchronize", + id="config=build_for_commit&pull_request&github.pr.Action", ), # Matching events: pytest.param( - gitlab.mr.Synchronize, + gitlab.mr.Action, flexmock(job_config_trigger_type=JobConfigTriggerType.pull_request), [ JobConfig( @@ -118,7 +118,7 @@ ), ], {CoprBuildHandler}, - id="config=build_for_pr&pull_request&gitlab.mr.Synchronize", + id="config=build_for_pr&pull_request&gitlab.mr.Action", ), pytest.param( github.push.Commit, @@ -228,7 +228,7 @@ ), # Koji: pytest.param( - github.pr.Synchronize, + github.pr.Action, flexmock(job_config_trigger_type=JobConfigTriggerType.pull_request), [ JobConfig( @@ -238,10 +238,10 @@ ), ], {KojiBuildHandler}, - id="config=upstream_koji_build_for_pr&pull_request&github.pr.Synchronize", + id="config=upstream_koji_build_for_pr&pull_request&github.pr.Action", ), pytest.param( - gitlab.mr.Synchronize, + gitlab.mr.Action, flexmock(job_config_trigger_type=JobConfigTriggerType.pull_request), [ JobConfig( @@ -251,7 +251,7 @@ ), ], {KojiBuildHandler}, - id="config=upstream_koji_build_for_pr&pull_request&gitlab.mr.Synchronize", + id="config=upstream_koji_build_for_pr&pull_request&gitlab.mr.Action", ), pytest.param( github.push.Commit, @@ -307,7 +307,7 @@ ), # Build and test: pytest.param( - github.pr.Synchronize, + github.pr.Action, flexmock(job_config_trigger_type=JobConfigTriggerType.pull_request), [ JobConfig( @@ -322,7 +322,7 @@ ), ], {CoprBuildHandler, TestingFarmHandler}, - id="config=build_for_pr+test_for_pr&pull_request&github.pr.Synchronize", + id="config=build_for_pr+test_for_pr&pull_request&github.pr.Action", ), pytest.param( copr.Start, @@ -380,7 +380,7 @@ ), # Multiple triggers for copr-build: pytest.param( - github.pr.Synchronize, + github.pr.Action, flexmock(job_config_trigger_type=JobConfigTriggerType.pull_request), [ JobConfig( @@ -401,7 +401,7 @@ ], {CoprBuildHandler}, id="config=build_for_pr+build_for_commit+build_for_release" - "&pull_request&github.pr.Synchronize", + "&pull_request&github.pr.Action", ), pytest.param( github.push.Commit, @@ -470,7 +470,7 @@ ), # multiple events for build but test only for push: pytest.param( - github.pr.Synchronize, + github.pr.Action, flexmock(job_config_trigger_type=JobConfigTriggerType.pull_request), [ JobConfig( @@ -496,10 +496,10 @@ ], {CoprBuildHandler, TestingFarmHandler}, id="config=build_for_pr+test_for_pr+build_for_commit+build_for_release" - "&pull_request&github.pr.Synchronize", + "&pull_request&github.pr.Action", ), pytest.param( - github.pr.Synchronize, + github.pr.Action, flexmock(job_config_trigger_type=JobConfigTriggerType.pull_request), [ JobConfig( @@ -513,10 +513,10 @@ ), ], {TestingFarmHandler}, - id="config=test_for_pr_skip_build&pull_request&github.pr.Synchronize", + id="config=test_for_pr_skip_build&pull_request&github.pr.Action", ), pytest.param( - github.pr.Synchronize, + github.pr.Action, flexmock(job_config_trigger_type=JobConfigTriggerType.pull_request), [ JobConfig( @@ -535,7 +535,7 @@ ), ], {CoprBuildHandler, TestingFarmHandler}, - id="config=copr_build_for_pr+test_for_pr_skip_build&pull_request&github.pr.Synchronize", + id="config=copr_build_for_pr+test_for_pr_skip_build&pull_request&github.pr.Action", ), pytest.param( github.push.Commit, @@ -684,7 +684,7 @@ ), # build for commit and release, test only for push: pytest.param( - github.pr.Synchronize, + github.pr.Action, flexmock(job_config_trigger_type=JobConfigTriggerType.pull_request), [ JobConfig( @@ -705,7 +705,7 @@ ], {TestingFarmHandler}, id="config=test_for_pr+build_for_commit+build_for_release" - "&pull_request&github.pr.Synchronize", + "&pull_request&github.pr.Action", ), pytest.param( github.push.Commit, @@ -779,7 +779,7 @@ ), # copr and koji build combination pytest.param( - github.pr.Synchronize, + github.pr.Action, flexmock(job_config_trigger_type=JobConfigTriggerType.pull_request), [ JobConfig( @@ -794,7 +794,7 @@ ), ], {CoprBuildHandler, KojiBuildHandler}, - id="config=build_for_pr+upstream_koji_build_for_pr&pull_request&github.pr.Synchronize", + id="config=build_for_pr+upstream_koji_build_for_pr&pull_request&github.pr.Action", ), pytest.param( copr.Start, @@ -1375,7 +1375,7 @@ def packages_config(self): # Basic copr build: pytest.param( CoprBuildHandler, - github.pr.Synchronize, + github.pr.Action, flexmock(job_config_trigger_type=JobConfigTriggerType.pull_request), [ JobConfig( @@ -1391,7 +1391,7 @@ def packages_config(self): packages={"package": CommonPackageConfig()}, ), ], - id="build_for_pr&CoprBuildHandler&github.pr.Synchronize", + id="build_for_pr&CoprBuildHandler&github.pr.Action", ), pytest.param( CoprBuildStartHandler, @@ -1436,7 +1436,7 @@ def packages_config(self): # Test only for pr: pytest.param( CoprBuildHandler, - github.pr.Synchronize, + github.pr.Action, flexmock(job_config_trigger_type=JobConfigTriggerType.pull_request), [ JobConfig( @@ -1446,12 +1446,12 @@ def packages_config(self): ), ], [], - id="tests_for_pr&CoprBuildHandler&github.pr.Synchronize", + id="tests_for_pr&CoprBuildHandler&github.pr.Action", ), # Both test and build for pr: pytest.param( CoprBuildHandler, - github.pr.Synchronize, + github.pr.Action, flexmock(job_config_trigger_type=JobConfigTriggerType.pull_request), [ JobConfig( @@ -1472,11 +1472,11 @@ def packages_config(self): packages={"package": CommonPackageConfig()}, ), ], - id="build_for_pr+tests_for_pr&CoprBuildHandler&github.pr.Synchronize", + id="build_for_pr+tests_for_pr&CoprBuildHandler&github.pr.Action", ), pytest.param( CoprBuildHandler, - github.pr.Synchronize, + github.pr.Action, flexmock(job_config_trigger_type=JobConfigTriggerType.pull_request), [ # Reverse order: @@ -1498,12 +1498,12 @@ def packages_config(self): packages={"package": CommonPackageConfig()}, ), ], - id="test_for_pr+build_for_pr&CoprBuildHandler&github.pr.Synchronize", + id="test_for_pr+build_for_pr&CoprBuildHandler&github.pr.Action", ), # Multiple builds for pr: pytest.param( CoprBuildHandler, - github.pr.Synchronize, + github.pr.Action, flexmock(job_config_trigger_type=JobConfigTriggerType.pull_request), [ JobConfig( @@ -1545,12 +1545,12 @@ def packages_config(self): }, ), ], - id="build_for_pr_twice&CoprBuildHandler&github.pr.Synchronize", + id="build_for_pr_twice&CoprBuildHandler&github.pr.Action", ), # Multiple triggers for build: pytest.param( CoprBuildHandler, - github.pr.Synchronize, + github.pr.Action, flexmock(job_config_trigger_type=JobConfigTriggerType.pull_request), [ JobConfig( @@ -1592,8 +1592,7 @@ def packages_config(self): }, ), ], - id="build_for_pr+build_for_commit+build_for_release" - "&CoprBuildHandler&github.pr.Synchronize", + id="build_for_pr+build_for_commit+build_for_release&CoprBuildHandler&github.pr.Action", ), pytest.param( CoprBuildHandler, @@ -1690,7 +1689,7 @@ def packages_config(self): # Build for commit and release, test for pr pytest.param( CoprBuildHandler, - github.pr.Synchronize, + github.pr.Action, flexmock(job_config_trigger_type=JobConfigTriggerType.pull_request), [ JobConfig( @@ -1722,8 +1721,7 @@ def packages_config(self): ), ], [], - id="tests_for_pr+build_for_commit+build_for_release" - "&CoprBuildHandler&github.pr.Synchronize", + id="tests_for_pr+build_for_commit+build_for_release&CoprBuildHandler&github.pr.Action", ), pytest.param( CoprBuildHandler, @@ -1867,7 +1865,7 @@ def packages_config(self): # Build for pr, commit and release, test for pr pytest.param( CoprBuildHandler, - github.pr.Synchronize, + github.pr.Action, flexmock(job_config_trigger_type=JobConfigTriggerType.pull_request), [ JobConfig( @@ -1919,7 +1917,7 @@ def packages_config(self): ), ], id="build_for_pr+tests_for_pr+build_for_commit+build_for_release" - "&CoprBuildHandler&github.pr.Synchronize", + "&CoprBuildHandler&github.pr.Action", ), pytest.param( CoprBuildHandler, @@ -2204,7 +2202,7 @@ def packages_config(self): # copr build and koji build: pytest.param( CoprBuildHandler, - github.pr.Synchronize, + github.pr.Action, flexmock(job_config_trigger_type=JobConfigTriggerType.pull_request), [ JobConfig( @@ -2225,11 +2223,11 @@ def packages_config(self): packages={"package": CommonPackageConfig()}, ), ], - id="build_for_pr+upstream_koji_build_for_pr&CoprBuildHandler&github.pr.Synchronize", + id="build_for_pr+upstream_koji_build_for_pr&CoprBuildHandler&github.pr.Action", ), pytest.param( KojiBuildHandler, - github.pr.Synchronize, + github.pr.Action, flexmock(job_config_trigger_type=JobConfigTriggerType.pull_request), [ JobConfig( @@ -2250,7 +2248,7 @@ def packages_config(self): packages={"package": CommonPackageConfig()}, ), ], - id="build_for_pr+upstream_koji_build_for_pr&KojiBuildHandler&github.pr.Synchronize", + id="build_for_pr+upstream_koji_build_for_pr&KojiBuildHandler&github.pr.Action", ), pytest.param( KojiTaskReportHandler, @@ -2839,7 +2837,7 @@ def __init__(self): {}, ), pytest.param( - github.pr.Synchronize, + github.pr.Action, JobConfigTriggerType.pull_request, [ JobConfig( @@ -2962,7 +2960,7 @@ def __init__(self): {}, ), pytest.param( - gitlab.mr.Synchronize, + gitlab.mr.Action, JobConfigTriggerType.pull_request, [ JobConfig( diff --git a/tests/unit/test_koji_build.py b/tests/unit/test_koji_build.py index 33cf22335..22f4e65a8 100644 --- a/tests/unit/test_koji_build.py +++ b/tests/unit/test_koji_build.py @@ -40,7 +40,7 @@ def build_helper( event: Union[ - github.pr.Synchronize, + github.pr.Action, github.pr.Comment, github.push.Commit, github.release.Release, diff --git a/tests/unit/test_srpm_logs.py b/tests/unit/test_srpm_logs.py index c126d0fa2..faf139f53 100644 --- a/tests/unit/test_srpm_logs.py +++ b/tests/unit/test_srpm_logs.py @@ -20,10 +20,10 @@ from packit_service.config import ServiceConfig from packit_service.models import SRPMBuildModel from packit_service.worker.events.github.pr import ( - Comment as PullRequestCommentGithubEvent, + Action as PullRequestGithubEvent, ) from packit_service.worker.events.github.pr import ( - Synchronize as PullRequestGithubEvent, + Comment as PullRequestCommentGithubEvent, ) from packit_service.worker.events.github.push import Commit as PushGitHubEvent from packit_service.worker.events.github.release import Release as ReleaseEvent diff --git a/tests/unit/test_testing_farm.py b/tests/unit/test_testing_farm.py index d82afb508..e3620d3e8 100644 --- a/tests/unit/test_testing_farm.py +++ b/tests/unit/test_testing_farm.py @@ -1865,7 +1865,7 @@ def test_get_artifacts(chroot, build, additional_build, result): }, ), ], - {"event_type": "github.pr.Synchronize", "commit_sha": "abcdef"}, + {"event_type": "github.pr.Action", "commit_sha": "abcdef"}, False, id="one_internal_test_job", ), @@ -1895,7 +1895,7 @@ def test_get_artifacts(chroot, build, additional_build, result): }, ), ], - {"event_type": "github.pr.Synchronize", "commit_sha": "abcdef"}, + {"event_type": "github.pr.Action", "commit_sha": "abcdef"}, False, id="multiple_test_jobs_build_required", ), @@ -1926,7 +1926,7 @@ def test_get_artifacts(chroot, build, additional_build, result): }, ), ], - {"event_type": "github.pr.Synchronize", "commit_sha": "abcdef"}, + {"event_type": "github.pr.Action", "commit_sha": "abcdef"}, True, id="multiple_test_jobs_build_required_internal_job_skip_build", ), @@ -1960,7 +1960,7 @@ def test_get_artifacts(chroot, build, additional_build, result): }, ), ], - {"event_type": "github.pr.Synchronize", "commit_sha": "abcdef"}, + {"event_type": "github.pr.Action", "commit_sha": "abcdef"}, True, id="multiple_test_jobs_build_required_internal_job_skip_build_manual_trigger", ), diff --git a/tests_openshift/database/test_events.py b/tests_openshift/database/test_events.py index 700aab9bd..bf74280c4 100644 --- a/tests_openshift/database/test_events.py +++ b/tests_openshift/database/test_events.py @@ -119,7 +119,7 @@ def test_push_branch_event_non_existing_branch( def test_pr_event_existing_pr(clean_before_and_after, pr_model, pr_event_dict): event_object = Parser.parse_event(pr_event_dict) - assert isinstance(event_object, github.pr.Synchronize) + assert isinstance(event_object, github.pr.Action) assert event_object.identifier == "342" assert event_object.git_ref is None @@ -137,7 +137,7 @@ def test_pr_event_existing_pr(clean_before_and_after, pr_model, pr_event_dict): def test_mr_event_existing_mr(clean_before_and_after, mr_model, mr_event_dict): event_object = Parser.parse_event(mr_event_dict) - assert isinstance(event_object, gitlab.mr.Synchronize) + assert isinstance(event_object, gitlab.mr.Action) assert event_object.git_ref is None assert event_object.commit_sha == "45e272a57335e4e308f3176df6e9226a9e7805a9" @@ -193,7 +193,7 @@ def test_push_gitlab_event( def test_pr_event_non_existing_pr(clean_before_and_after, pr_event_dict): event_object = Parser.parse_event(pr_event_dict) - assert isinstance(event_object, github.pr.Synchronize) + assert isinstance(event_object, github.pr.Action) assert event_object.identifier == "342" assert event_object.git_ref is None