Skip to content

Commit

Permalink
Rename /packit propose-update to propose-downstream
Browse files Browse the repository at this point in the history
  • Loading branch information
jpopelka committed Jan 5, 2021
1 parent deaafcb commit f62205d
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 20 deletions.
2 changes: 1 addition & 1 deletion packit_service/worker/handlers/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class TaskName(str, enum.Enum):
installation = "task.run_installation_handler"
testing_farm = "task.run_testing_farm_handler"
testing_farm_results = "task.run_testing_farm_results_handler"
propose_update_comment = "task.run_propose_update_comment_handler"
propose_downstream_comment = "task.run_propose_downstream_comment_handler"
propose_downstream = "task.run_propose_downstream_handler"
koji_build = "task.run_koji_build_handler"
distgit_commit = "task.run_distgit_commit_handler"
Expand Down
14 changes: 9 additions & 5 deletions packit_service/worker/handlers/github_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
from typing import Optional

from celery.app.task import Task

from ogr.abstract import CommitStatus, GitProject
from packit.api import PackitAPI
from packit.config import (
Expand All @@ -39,6 +38,7 @@
from packit.config.package_config import PackageConfig
from packit.exceptions import PackitException
from packit.local_project import LocalProject

from packit_service import sentry_integration
from packit_service.constants import (
FAQ_URL_HOW_TO_RETRIGGER,
Expand Down Expand Up @@ -144,7 +144,8 @@ def run(self) -> TaskResults:


@configured_as(job_type=JobType.propose_downstream)
@run_for_comment(command="propose-update")
@run_for_comment(command="propose-downstream")
@run_for_comment(command="propose-update") # deprecated
@reacts_to(event=ReleaseEvent)
@reacts_to(event=IssueCommentEvent)
class ProposeDownstreamHandler(JobHandler):
Expand Down Expand Up @@ -204,22 +205,25 @@ def run(self) -> TaskResults:
err_without_new_lines = err.replace("\n", " ")
branch_errors += f"| `{branch}` | `{err_without_new_lines}` |\n"

msg_retrigger = MSG_RETRIGGER.format(
job="update", command="propose-downstream", place="issue"
)
body_msg = (
f"Packit failed on creating pull-requests in dist-git:\n\n"
f"| dist-git branch | error |\n"
f"| --------------- | ----- |\n"
f"{branch_errors}\n\n"
f"{MSG_RETRIGGER.format(job='update', command='propose-update', place='issue')}\n"
f"{msg_retrigger}\n"
)

self.project.create_issue(
title=f"[packit] Propose update failed for release {self.data.tag_name}",
title=f"[packit] Propose downstream failed for release {self.data.tag_name}",
body=body_msg,
)

return TaskResults(
success=False,
details={"msg": "Propose update failed.", "errors": errors},
details={"msg": "Propose downstream failed.", "errors": errors},
)

return TaskResults(success=True, details={})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"id": 489618683,
"node_id": "MDU6SXNzdWU0ODk2MTg2ODM=",
"number": 512,
"title": "[DO-NOT-MERGE] testing /packit propose-update",
"title": "[DO-NOT-MERGE] testing /packit propose-downstream",
"user": {
"login": "phracek",
"id": 3416672,
Expand Down Expand Up @@ -73,7 +73,7 @@
"created_at": "2019-09-05T09:44:31Z",
"updated_at": "2019-09-05T09:44:31Z",
"author_association": "CONTRIBUTOR",
"body": "/packit propose-update"
"body": "/packit propose-downstream"
},
"repository": {
"id": 156365951,
Expand Down
12 changes: 7 additions & 5 deletions tests/integration/test_issue_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@


@pytest.fixture(scope="module")
def issue_comment_propose_update_event():
def issue_comment_propose_downstream_event():
return json.loads(
(DATA_DIR / "webhooks" / "github" / "issue_propose_update.json").read_text()
(DATA_DIR / "webhooks" / "github" / "issue_propose_downstream.json").read_text()
)


Expand Down Expand Up @@ -91,8 +91,8 @@ def mock_issue_comment_functionality():
flexmock(Whitelist, check_and_report=True)


def test_issue_comment_propose_update_handler(
mock_issue_comment_functionality, issue_comment_propose_update_event
def test_issue_comment_propose_downstream_handler(
mock_issue_comment_functionality, issue_comment_propose_downstream_event
):
flexmock(PackitAPI).should_receive("sync_release").and_return(
PullRequest(
Expand Down Expand Up @@ -120,7 +120,9 @@ def test_issue_comment_propose_update_handler(
)
flexmock(Signature).should_receive("apply_async").once()

processing_results = SteveJobs().process_message(issue_comment_propose_update_event)
processing_results = SteveJobs().process_message(
issue_comment_propose_downstream_event
)
event_dict, job, job_config, package_config = get_parameters_from_results(
processing_results
)
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/test_release_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,12 @@ def test_dist_git_push_release_handle_all_failed(
)
.should_receive("create_issue")
.with_args(
title="[packit] Propose update failed for release 0.3.0",
title="[packit] Propose downstream failed for release 0.3.0",
body="Packit failed on creating pull-requests in dist-git:\n\n"
"| dist-git branch | error |\n"
"| --------------- | ----- |\n"
f"{table_content}\n\n"
"You can retrigger the update by adding a comment (`/packit propose-update`)"
"You can retrigger the update by adding a comment (`/packit propose-downstream`)"
" into this issue.\n",
)
.once()
Expand Down
10 changes: 5 additions & 5 deletions tests/unit/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ def github_installation(self, request):
return json.load(outfile)

@pytest.fixture()
def github_issue_comment_propose_update(self):
def github_issue_comment_propose_downstream(self):
with open(
DATA_DIR / "webhooks" / "github" / "issue_propose_update.json"
DATA_DIR / "webhooks" / "github" / "issue_propose_downstream.json"
) as outfile:
return json.load(outfile)

Expand Down Expand Up @@ -446,8 +446,8 @@ def test_parse_pr_comment_empty(self, github_pr_comment_empty):

assert event_object.package_config

def test_parse_issue_comment(self, github_issue_comment_propose_update):
event_object = Parser.parse_event(github_issue_comment_propose_update)
def test_parse_issue_comment(self, github_issue_comment_propose_downstream):
event_object = Parser.parse_event(github_issue_comment_propose_downstream)

assert isinstance(event_object, IssueCommentEvent)
assert event_object.action == IssueCommentAction.created
Expand All @@ -461,7 +461,7 @@ def test_parse_issue_comment(self, github_issue_comment_propose_update):
assert event_object.base_ref == "master"
assert event_object.project_url == "https://github.com/packit-service/packit"
assert event_object.user_login == "phracek"
assert event_object.comment == "/packit propose-update"
assert event_object.comment == "/packit propose-downstream"

assert isinstance(event_object.project, GithubProject)
assert event_object.project.full_repo_name == "packit-service/packit"
Expand Down

0 comments on commit f62205d

Please sign in to comment.