Skip to content

Commit

Permalink
Skip actor pre_check if actor not present
Browse files Browse the repository at this point in the history
This should make the behaviour the same as it was previously
(before handler pre_checks refactoring
https://github.com/packit/packit-service/blob/da94cc9b511843d73e9b94d20677f0b1d1426bf8/packit_service/worker/jobs.py#L422):
if the actor is None, the actor pre_check will be skipped (e.g.
pushes to branch, releases).
  • Loading branch information
lbarcziova authored and nforro committed Nov 2, 2022
1 parent 15b3ca9 commit 250708d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packit_service/worker/checker/abstract.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
from abc import abstractmethod
from typing import Optional

Expand All @@ -7,6 +8,8 @@
from packit_service.worker.events import EventData
from packit_service.worker.mixin import ConfigMixin, PackitAPIWithDownstreamMixin

logger = logging.getLogger(__name__)


class Checker(ConfigMixin, PackitAPIWithDownstreamMixin):
def __init__(
Expand Down Expand Up @@ -35,5 +38,6 @@ def _pre_check(self) -> bool:

def pre_check(self) -> bool:
if not self.actor:
return False
logger.debug("Actor not set for this event, skipping the actor check.")
return True
return self._pre_check()
24 changes: 24 additions & 0 deletions tests/integration/test_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,30 @@ def test_precheck_push_to_a_different_branch(github_push_event):
assert not CoprBuildHandler.pre_check(package_config, job_config, event)


def test_precheck_push_actor_check(github_push_event):
flexmock(GitBranchModel).should_receive("get_or_create").and_return(
flexmock(id=1, job_config_trigger_type=JobConfigTriggerType.commit)
)

package_config = PackageConfig(
jobs=[
JobConfig(
type=JobType.copr_build,
trigger=JobConfigTriggerType.commit,
branch="branch",
),
]
)
job_config = JobConfig(
type=JobType.copr_build,
trigger=JobConfigTriggerType.commit,
branch="branch",
)
event = github_push_event.get_dict()
actor_checker = CoprBuildHandler.get_checkers()[1]
assert actor_checker(package_config, job_config, event).pre_check()


def test_precheck_koji_build_non_scratch(github_pr_event):
flexmock(PullRequestModel).should_receive("get_or_create").with_args(
pr_id=342,
Expand Down

0 comments on commit 250708d

Please sign in to comment.