diff --git a/packit_service/worker/checker/abstract.py b/packit_service/worker/checker/abstract.py index ac7b180a1..542595af6 100644 --- a/packit_service/worker/checker/abstract.py +++ b/packit_service/worker/checker/abstract.py @@ -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, diff --git a/packit_service/worker/checker/bodhi.py b/packit_service/worker/checker/bodhi.py index 57a817e25..22bd0c3cb 100644 --- a/packit_service/worker/checker/bodhi.py +++ b/packit_service/worker/checker/bodhi.py @@ -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 diff --git a/packit_service/worker/checker/copr.py b/packit_service/worker/checker/copr.py index 57e36088b..17429ee71 100644 --- a/packit_service/worker/checker/copr.py +++ b/packit_service/worker/checker/copr.py @@ -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: diff --git a/packit_service/worker/checker/distgit.py b/packit_service/worker/checker/distgit.py index dc877ab8d..d911dadf7 100644 --- a/packit_service/worker/checker/distgit.py +++ b/packit_service/worker/checker/distgit.py @@ -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 @@ -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(), @@ -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", "") @@ -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 diff --git a/packit_service/worker/checker/open_scan_hub.py b/packit_service/worker/checker/open_scan_hub.py index 72f4440af..5f4d60b97 100644 --- a/packit_service/worker/checker/open_scan_hub.py +++ b/packit_service/worker/checker/open_scan_hub.py @@ -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, diff --git a/packit_service/worker/checker/run_condition.py b/packit_service/worker/checker/run_condition.py index 2a8ca74d6..1a108d771 100644 --- a/packit_service/worker/checker/run_condition.py +++ b/packit_service/worker/checker/run_condition.py @@ -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, diff --git a/packit_service/worker/checker/vm_image.py b/packit_service/worker/checker/vm_image.py index 27717132a..e2dc3c4d1 100644 --- a/packit_service/worker/checker/vm_image.py +++ b/packit_service/worker/checker/vm_image.py @@ -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: diff --git a/packit_service/worker/handlers/abstract.py b/packit_service/worker/handlers/abstract.py index 3fbba6abb..99869651f 100644 --- a/packit_service/worker/handlers/abstract.py +++ b/packit_service/worker/handlers/abstract.py @@ -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 @@ -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. """