Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated code #2532

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
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
15 changes: 0 additions & 15 deletions packit_service/trigger_mapping.py

This file was deleted.

3 changes: 0 additions & 3 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 @@ -146,7 +145,6 @@ def run_for_comment(command: str):
```
@configured_as(job_type=JobType.propose_downstream)
@run_for_comment(command="propose-downstream")
@run_for_comment(command="propose-update")
@reacts_to(event=ReleaseEvent)
@reacts_to(event=IssueCommentEvent)
class ProposeDownstreamHandler(JobHandler):
Expand All @@ -173,7 +171,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
3 changes: 0 additions & 3 deletions packit_service/worker/handlers/copr.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,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 @@ -144,7 +143,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 @@ -229,7 +227,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
2 changes: 0 additions & 2 deletions packit_service/worker/handlers/distgit.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@ def sync_branch(
"create_pr": True,
"local_pr_branch_suffix": branch_suffix,
"use_downstream_specfile": is_pull_from_upstream_job,
"sync_default_files": not is_pull_from_upstream_job,
"add_pr_instructions": True,
"resolved_bugs": self.get_resolved_bugs(),
"release_monitoring_project_id": self.data.event_dict.get(
Expand Down Expand Up @@ -577,7 +576,6 @@ class AbortSyncRelease(Exception):

@configured_as(job_type=JobType.propose_downstream)
@run_for_comment(command="propose-downstream")
@run_for_comment(command="propose-update") # deprecated
@run_for_check_rerun(prefix="propose-downstream")
@reacts_to(event=ReleaseEvent)
@reacts_to(event=ReleaseGitlabEvent)
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 @@ -84,11 +84,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 @@ -264,7 +261,6 @@ def run(self):
return TaskResults(success=True, details={"msg": msg})


@configured_as(job_type=JobType.production_build)
@configured_as(job_type=JobType.upstream_koji_build)
@reacts_to(event=KojiTaskEvent)
class KojiTaskReportHandler(AbstractKojiTaskReportHandler):
Expand Down
12 changes: 2 additions & 10 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 @@
SRPMBuildModel,
)
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,10 +148,7 @@ 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 @@ -174,11 +170,7 @@ def job_tests_all(self) -> list[JobConfig]:
self._job_tests_all = [
job
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))
]

return self._job_tests_all
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 @@ -33,7 +33,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
2 changes: 1 addition & 1 deletion packit_service/worker/helpers/open_scan_hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,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
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

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 @@ -102,7 +101,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
21 changes: 2 additions & 19 deletions packit_service/worker/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@
import celery
from ogr.exceptions import GithubAppNotInstalledError
from packit.config import JobConfig, JobConfigTriggerType, JobConfigView, JobType
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 (
COMMENT_REACTION,
DOCS_CONFIGURATION_URL,
PACKIT_VERIFY_FAS_COMMAND,
TASK_ACCEPTED,
)
Expand Down Expand Up @@ -640,30 +638,15 @@ def should_task_be_created_for_job_config_and_handler(
)
return False

if not handler_kls.pre_check(
return handler_kls.pre_check(
package_config=(
self.event.packages_config.get_package_config_for(job_config)
if self.event.packages_config
else None
),
job_config=job_config,
event=self.event.get_dict(),
):
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 @@ -186,7 +186,7 @@ def test_check_copr_build_updated(
PackageConfig(
jobs=[
JobConfig(
type=JobType.build,
type=JobType.copr_build,
trigger=JobConfigTriggerType.pull_request,
packages={"package": CommonPackageConfig(specfile_path="some.spec")},
),
Expand Down Expand Up @@ -273,7 +273,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(specfile_path="some.spec")},
),
Expand Down Expand Up @@ -379,7 +379,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(specfile_path="some.spec")},
),
Expand Down Expand Up @@ -467,7 +467,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 @@ -380,7 +380,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 @@ -406,22 +406,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 @@ -347,7 +347,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 @@ -360,7 +360,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
2 changes: 0 additions & 2 deletions tests/integration/test_new_hotness_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ def test_new_hotness_update(new_hotness_update, sync_release_model):
create_pr=True,
local_pr_branch_suffix="update-pull_from_upstream",
use_downstream_specfile=True,
sync_default_files=False,
add_pr_instructions=True,
resolved_bugs=["rhbz#2106196"],
release_monitoring_project_id=4181,
Expand Down Expand Up @@ -391,7 +390,6 @@ def test_new_hotness_update_non_git(new_hotness_update, sync_release_model_non_g
create_pr=True,
local_pr_branch_suffix="update-pull_from_upstream",
use_downstream_specfile=True,
sync_default_files=False,
add_pr_instructions=True,
resolved_bugs=["rhbz#2106196"],
release_monitoring_project_id=4181,
Expand Down
2 changes: 0 additions & 2 deletions tests/integration/test_pr_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -2727,7 +2727,6 @@ def _get_project(url, *_, **__):
create_pr=True,
local_pr_branch_suffix="update-pull_from_upstream",
use_downstream_specfile=True,
sync_default_files=False,
add_pr_instructions=True,
resolved_bugs=["rhbz#123", "rhbz#124"],
release_monitoring_project_id=None,
Expand Down Expand Up @@ -2894,7 +2893,6 @@ def _get_project(url, *_, **__):
create_pr=True,
local_pr_branch_suffix="update-pull_from_upstream",
use_downstream_specfile=True,
sync_default_files=False,
add_pr_instructions=True,
resolved_bugs=["rhbz#123", "rhbz#124"],
release_monitoring_project_id=None,
Expand Down
6 changes: 0 additions & 6 deletions tests/integration/test_release_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ def test_dist_git_push_release_handle(
create_pr=True,
local_pr_branch_suffix="update-propose_downstream",
use_downstream_specfile=False,
sync_default_files=True,
add_pr_instructions=True,
resolved_bugs=[],
release_monitoring_project_id=None,
Expand Down Expand Up @@ -357,7 +356,6 @@ def test_dist_git_push_release_handle_multiple_branches(
create_pr=True,
local_pr_branch_suffix="update-propose_downstream",
use_downstream_specfile=False,
sync_default_files=True,
add_pr_instructions=True,
resolved_bugs=[],
release_monitoring_project_id=None,
Expand Down Expand Up @@ -507,7 +505,6 @@ def test_dist_git_push_release_handle_one_failed(
create_pr=True,
local_pr_branch_suffix="update-propose_downstream",
use_downstream_specfile=False,
sync_default_files=True,
add_pr_instructions=True,
resolved_bugs=[],
release_monitoring_project_id=None,
Expand All @@ -532,7 +529,6 @@ def test_dist_git_push_release_handle_one_failed(
create_pr=True,
local_pr_branch_suffix="update-propose_downstream",
use_downstream_specfile=False,
sync_default_files=True,
add_pr_instructions=True,
resolved_bugs=[],
release_monitoring_project_id=None,
Expand Down Expand Up @@ -785,7 +781,6 @@ def test_retry_propose_downstream_task(
create_pr=True,
local_pr_branch_suffix="update-propose_downstream",
use_downstream_specfile=False,
sync_default_files=True,
add_pr_instructions=True,
resolved_bugs=[],
release_monitoring_project_id=None,
Expand Down Expand Up @@ -901,7 +896,6 @@ def test_dont_retry_propose_downstream_task(
create_pr=True,
local_pr_branch_suffix="update-propose_downstream",
use_downstream_specfile=False,
sync_default_files=True,
add_pr_instructions=True,
resolved_bugs=[],
release_monitoring_project_id=None,
Expand Down
Loading
Loading