Skip to content

Commit

Permalink
Remove support for deprecated job types
Browse files Browse the repository at this point in the history
  • Loading branch information
majamassarini committed Sep 17, 2024
1 parent 2d4caae commit dcc8540
Show file tree
Hide file tree
Showing 15 changed files with 220 additions and 274 deletions.
15 changes: 0 additions & 15 deletions packit_service/trigger_mapping.py

This file was deleted.

2 changes: 0 additions & 2 deletions packit_service/worker/handlers/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ class ProposeDownstreamHandler(JobHandler):
E.g. CoprBuildHandler uses both copr_build and build:
```
@configured_as(job_type=JobType.copr_build)
@configured_as(job_type=JobType.build)
class CoprBuildHandler(JobHandler):
```
"""
Expand Down Expand Up @@ -149,7 +148,6 @@ def run_for_check_rerun(prefix: str):
Example:
```
@configured_as(job_type=JobType.copr_build)
@configured_as(job_type=JobType.build)
@run_for_check_rerun(prefix="rpm-build")
@reacts_to(CheckRerunPullRequestEvent)
@reacts_to(CheckRerunCommitEvent)
Expand Down
5 changes: 1 addition & 4 deletions packit_service/worker/handlers/copr.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@


@configured_as(job_type=JobType.copr_build)
@configured_as(job_type=JobType.build)
@run_for_comment(command="build")
@run_for_comment(command="copr-build")
@run_for_comment(command="rebuild-failed")
Expand Down Expand Up @@ -151,7 +150,6 @@ def get_checkers() -> Tuple[Type[Checker], ...]:


@configured_as(job_type=JobType.copr_build)
@configured_as(job_type=JobType.build)
@reacts_to(event=CoprBuildStartEvent)
class CoprBuildStartHandler(AbstractCoprBuildReportHandler):
topic = "org.fedoraproject.prod.copr.build.start"
Expand Down Expand Up @@ -242,7 +240,6 @@ def run(self):


@configured_as(job_type=JobType.copr_build)
@configured_as(job_type=JobType.build)
@reacts_to(event=CoprBuildEndEvent)
class CoprBuildEndHandler(AbstractCoprBuildReportHandler):
topic = "org.fedoraproject.prod.copr.build.end"
Expand Down Expand Up @@ -613,7 +610,7 @@ def find_base_build_job(self) -> Optional[JobConfig]:

for job in self.copr_build_helper.package_config.get_job_views():
if (
job.type in (JobType.copr_build, JobType.build)
job.type == JobType.copr_build
and job.trigger == JobConfigTriggerType.commit
and (
(
Expand Down
4 changes: 0 additions & 4 deletions packit_service/worker/handlers/koji.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,8 @@
logger = logging.getLogger(__name__)


@configured_as(job_type=JobType.production_build)
@configured_as(job_type=JobType.upstream_koji_build)
@run_for_comment(command="production-build")
@run_for_comment(command="upstream-koji-build")
@run_for_check_rerun(prefix="production-build")
@run_for_check_rerun(prefix="koji-build")
@reacts_to(ReleaseEvent)
@reacts_to(ReleaseGitlabEvent)
Expand Down Expand Up @@ -127,7 +124,6 @@ def run(self) -> TaskResults:
return self.koji_build_helper.run_koji_build()


@configured_as(job_type=JobType.production_build)
@configured_as(job_type=JobType.upstream_koji_build)
@reacts_to(event=KojiTaskEvent)
class KojiTaskReportHandler(
Expand Down
15 changes: 8 additions & 7 deletions packit_service/worker/helpers/build/build_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
ProjectEventModel,
)
from packit_service.service.urls import get_srpm_build_info_url
from packit_service.trigger_mapping import are_job_types_same
from packit_service.worker.events import EventData
from packit_service.worker.helpers.job_helper import BaseJobHelper
from packit_service.worker.monitoring import Pushgateway
Expand Down Expand Up @@ -149,9 +148,10 @@ def job_build(self) -> Optional[JobConfig]:
return None
if not self._job_build:
for job in [self.job_config] + self.package_config.jobs:
if are_job_types_same(
job.type, self.job_type_build
) and self.is_job_config_trigger_matching(job):
if (
job.type == self.job_type_build
and self.is_job_config_trigger_matching(job)
):
self._job_build = job
break
return self._job_build
Expand All @@ -173,9 +173,10 @@ def job_tests_all(self) -> List[JobConfig]:

if not self._job_tests_all:
for job in self.package_config.jobs:
if are_job_types_same(
job.type, self.job_type_test
) and self.is_job_config_trigger_matching(job):
if (
job.type == self.job_type_test
and self.is_job_config_trigger_matching(job)
):
matching_jobs.append(job)
self._job_tests_all = matching_jobs

Expand Down
2 changes: 1 addition & 1 deletion packit_service/worker/helpers/build/koji_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@


class KojiBuildJobHelper(BaseBuildJobHelper):
job_type_build = JobType.production_build
job_type_build = JobType.upstream_koji_build
job_type_test = None
status_name_build: str = "koji-build"
status_name_test: str = None
Expand Down
3 changes: 1 addition & 2 deletions packit_service/worker/helpers/sync_release/sync_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from packit.config import aliases
from packit_service.config import ServiceConfig
from packit_service.models import ProjectEventModel
from packit_service.trigger_mapping import are_job_types_same
from packit_service.worker.events import EventData
from packit_service.worker.helpers.job_helper import BaseJobHelper

Expand Down Expand Up @@ -98,7 +97,7 @@ def job(self) -> Optional[JobConfig]:
"""
if not self._job:
for job in [self.job_config] + self.package_config.jobs:
if are_job_types_same(job.type, self.job_type) and (
if job.type == self.job_type and (
self._db_project_object
and (
self._db_project_object.job_config_trigger_type == job.trigger
Expand Down
14 changes: 0 additions & 14 deletions packit_service/worker/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@

from ogr.exceptions import GithubAppNotInstalledError
from packit.config import JobConfig, JobConfigView, JobType, JobConfigTriggerType
from packit.config.job_config import DEPRECATED_JOB_TYPES
from packit.utils import nested_get
from packit_service.config import PackageConfig, PackageConfigGetter, ServiceConfig
from packit_service.constants import (
DOCS_CONFIGURATION_URL,
TASK_ACCEPTED,
COMMENT_REACTION,
PACKIT_VERIFY_FAS_COMMAND,
Expand Down Expand Up @@ -565,18 +563,6 @@ def should_task_be_created_for_job_config_and_handler(
):
return False

if deprecation_msg := DEPRECATED_JOB_TYPES.get(job_config.type):
job_helper = self.initialize_job_helper(handler_kls, job_config)
job_helper.status_reporter.report(
state=BaseCommitStatus.error,
description=f"Job name `{job_config.type.name}` deprecated.",
url=f"{DOCS_CONFIGURATION_URL}/#supported-jobs",
check_names=f"config-deprecation-{job_config.type.name}",
markdown_content=f"{deprecation_msg}\n\n"
"The support for the old name will be removed "
"by the end of the year.",
)

return True

def is_project_public_or_enabled_private(self) -> bool:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"created_at": "2019-08-08T15:22:24Z",
"updated_at": "2019-08-08T15:22:24Z",
"author_association": "NONE",
"body": "/packit production-build"
"body": "/packit upstream-koji-build"
},
"repository": {
"id": 184635124,
Expand Down
8 changes: 4 additions & 4 deletions tests/integration/test_babysit.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def test_check_copr_build_updated(
PackageConfig(
jobs=[
JobConfig(
type=JobType.build,
type=JobType.copr_build,
trigger=JobConfigTriggerType.pull_request,
packages={"package": CommonPackageConfig()},
)
Expand Down Expand Up @@ -243,7 +243,7 @@ def test_check_copr_build_waiting_started(add_pull_request_event_with_sha_123456
PackageConfig(
jobs=[
JobConfig(
type=JobType.build,
type=JobType.copr_build,
trigger=JobConfigTriggerType.pull_request,
packages={"package": CommonPackageConfig()},
)
Expand Down Expand Up @@ -342,7 +342,7 @@ def test_check_copr_build_waiting_srpm_failed(add_pull_request_event_with_sha_12
PackageConfig(
jobs=[
JobConfig(
type=JobType.build,
type=JobType.copr_build,
trigger=JobConfigTriggerType.pull_request,
packages={"package": CommonPackageConfig()},
)
Expand Down Expand Up @@ -425,7 +425,7 @@ def test_check_copr_build_waiting_already_started(
PackageConfig(
jobs=[
JobConfig(
type=JobType.build,
type=JobType.copr_build,
trigger=JobConfigTriggerType.pull_request,
packages={"package": CommonPackageConfig()},
)
Expand Down
18 changes: 1 addition & 17 deletions tests/integration/test_check_rerun.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ def test_check_rerun_pr_koji_build_handler(
[
{
"trigger": "pull_request",
"job": "production_build",
"job": "upstream_koji_build",
"metadata": {"targets": "fedora-all", "scratch": "true"},
}
]
Expand All @@ -404,22 +404,6 @@ def test_check_rerun_pr_koji_build_handler_old_job_name(
flexmock(koji_build).should_receive("get_koji_targets").and_return(
{"rawhide", "f34"}
)
flexmock(StatusReporterGithubChecks).should_receive("set_status").with_args(
state=BaseCommitStatus.error,
description="Job name `production_build` deprecated.",
check_name="config-deprecation-production_build",
url="https://packit.dev/docs/configuration/#supported-jobs",
links_to_external_services=None,
markdown_content="The `production_build` name for upstream Koji build is misleading "
"because it is not used to run production/non-scratch builds and "
"because it can be confused with "
"the `koji_build` job that is triggered for dist-git commits. "
"(The `koji_build` job can trigger both scratch and "
"non-scratch/production builds.) "
"To be explicit, use `upstream_koji_build` for builds triggered in upstream and "
"`koji_build` for builds triggered in downstream.\n\n"
"The support for the old name will be removed by the end of the year.",
).once()
flexmock(StatusReporterGithubChecks).should_receive("set_status").with_args(
state=BaseCommitStatus.pending,
description=TASK_ACCEPTED,
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/test_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ def test_precheck_koji_build_non_scratch(github_pr_event):
package_config = PackageConfig(
jobs=[
JobConfig(
type=JobType.production_build,
type=JobType.upstream_koji_build,
trigger=JobConfigTriggerType.pull_request,
packages={
"package": CommonPackageConfig(
Expand All @@ -369,7 +369,7 @@ def test_precheck_koji_build_non_scratch(github_pr_event):
packages={"package": CommonPackageConfig()},
)
job_config = JobConfig(
type=JobType.production_build,
type=JobType.upstream_koji_build,
trigger=JobConfigTriggerType.pull_request,
packages={
"package": CommonPackageConfig(
Expand Down
Loading

0 comments on commit dcc8540

Please sign in to comment.