Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packit_service/worker/checker/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@


class Checker(ConfigFromEventMixin, PackitAPIWithDownstreamMixin):
"""Verifies conditions before proceeding based on supplied event data,
task name, job and package configuration."""

def __init__(
self,
package_config: PackageConfig,
Expand Down
2 changes: 2 additions & 0 deletions packit_service/worker/checker/bodhi.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ def _pre_check(self) -> bool:


class IsAuthorAPackager(ActorChecker, PackitAPIWithDownstreamMixin):
"""Verifies that the author is a packager if the event is `pagure.pr.Comment`."""

def _pre_check(self) -> bool:
if self.data.event_type not in (pagure.pr.Comment.event_type(),) or self.is_packager(
user=self.actor
Expand Down
3 changes: 3 additions & 0 deletions packit_service/worker/checker/copr.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ class IsGitForgeProjectAndEventOk(
ConfigFromEventMixin,
GetCoprBuildJobHelperMixin,
):
"""Verifies that mergerequest isn't closed, is in appropriate stage
and in case of custom projects that it satisfies criteria for using Copr."""

def pre_check(
self,
) -> bool:
Expand Down
19 changes: 19 additions & 0 deletions packit_service/worker/checker/distgit.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@


class LabelsOnDistgitPR(Checker, GetPagurePullRequestMixin):
"""Verifies that state of labels on the PR matches the configuration.

The check passes also if the event is not a `pagure.push.Commit`,
or if no configuration exists."""

def pre_check(self) -> bool:
if self.data.event_type not in (pagure.push.Commit.event_type(),) or not (
self.job_config.require.label.present or self.job_config.require.label.absent
Expand All @@ -44,6 +49,11 @@ def pre_check(self) -> bool:


class PermissionOnDistgit(Checker, GetPagurePullRequestMixin):
"""Verifies that author of given event has permissions for the workflow.

If the check fails for `pagure.pr.Comment` event, a notification is posted
in the same thread."""

def pre_check(self) -> bool:
if self.data.event_type in (
pagure.push.Commit.event_type(),
Expand Down Expand Up @@ -129,6 +139,8 @@ def pre_check(self) -> bool:


class PermissionOnDistgitForFedoraCI(Checker, GetPagurePullRequestMixin):
"""Verifies if user posting a comment with command is a packager."""

def pre_check(self) -> bool:
if self.data.event_type in (pagure.pr.Comment.event_type(),):
comment = self.data.event_dict.get("comment", "")
Expand Down Expand Up @@ -275,6 +287,13 @@ def pre_check(self) -> bool:


class IsUpstreamTagMatchingConfig(Checker):
"""Verifies that the tag is either among configured included tags,
or not among configured excluded tags.

If the tag in event is `None`, for example in case of pull-from-upstream
retriggering the check passes.
"""

def pre_check(self) -> bool:
tag = self.data.tag_name

Expand Down
2 changes: 2 additions & 0 deletions packit_service/worker/checker/open_scan_hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
class RawhideX86Target(
Checker,
):
"""Verifies that build targets include `fedora-rawhide-x86_64`."""

def pre_check(self) -> bool:
branches = aliases.get_build_targets(
*self.job_config.targets,
Expand Down
3 changes: 3 additions & 0 deletions packit_service/worker/checker/run_condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@


class IsRunConditionSatisfied(Checker, ConfigFromEventMixin, PackitAPIWithUpstreamMixin):
"""Verifies if the user defined run_condition action passes,
optionally cloning the repository to evaluate the condition in the project's context."""

def __init__(
self,
package_config: PackageConfig,
Expand Down
2 changes: 2 additions & 0 deletions packit_service/worker/checker/vm_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ def report_status(self, status: VMImageBuildStatus, markdown_content: str):


class IsCoprBuildForChrootOk(Checker, GetVMImageBuildReporterFromJobHelperMixin):
"""Verifies that copr build is associated with given task."""

def pre_check(
self,
) -> bool:
Expand Down
5 changes: 5 additions & 0 deletions packit_service/worker/handlers/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,8 @@ def _clean_workplace(self):

@staticmethod
def get_checkers() -> tuple[type[Checker], ...]:
"""Return tuple of Checker objects to be one by one executed
during pre_check."""
return ()

@classmethod
Expand All @@ -338,6 +340,9 @@ def pre_check(
event: dict,
) -> bool:
"""
Verify that the handler should be used for incoming event with given
job and package configuration.

Returns
bool: False if we have to skip the job execution.
"""
Expand Down
Loading