Skip to content

Commit

Permalink
Pass release monitoring project ID to sync_release (#2263)
Browse files Browse the repository at this point in the history
Pass release monitoring project ID to sync_release

So that it can be linked from the PR description.
Followup of packit/packit#2173

RELEASE NOTES BEGIN
N/A
RELEASE NOTES END

Reviewed-by: František Lachman <[email protected]>
  • Loading branch information
softwarefactory-project-zuul[bot] authored Nov 30, 2023
2 parents f93eedc + 11b6381 commit 6483a03
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packit_service/worker/events/new_hotness.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,19 @@
@use_for_job_config_trigger(trigger_type=JobConfigTriggerType.release)
class NewHotnessUpdateEvent(Event):
def __init__(
self, package_name: str, version: str, distgit_project_url: str, bug_id: int
self,
package_name: str,
version: str,
distgit_project_url: str,
bug_id: int,
release_monitoring_project_id: int,
):
super().__init__()
self.package_name = package_name
self.version = version
self.distgit_project_url = distgit_project_url
self.bug_id = bug_id
self.release_monitoring_project_id = release_monitoring_project_id

self._repo_url: Optional[RepoUrl] = None
self._db_project_object: Optional[ProjectReleaseModel]
Expand Down
3 changes: 3 additions & 0 deletions packit_service/worker/handlers/distgit.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,9 @@ def sync_branch(
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(
"release_monitoring_project_id"
),
)
except PackitDownloadFailedException as ex:
# the archive has not been uploaded to PyPI yet
Expand Down
4 changes: 4 additions & 0 deletions packit_service/worker/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1551,6 +1551,9 @@ def parse_new_hotness_update_event(event) -> Optional[NewHotnessUpdateEvent]:
version = nested_get(event, "trigger", "msg", "project", "version")

bug_id = nested_get(event, "bug", "bug_id")
release_monitoring_project_id = nested_get(
event, "trigger", "msg", "project", "id"
)

logger.info(
f"New hotness update event for package: {package_name}, version: {version},"
Expand All @@ -1562,6 +1565,7 @@ def parse_new_hotness_update_event(event) -> Optional[NewHotnessUpdateEvent]:
version=version,
distgit_project_url=distgit_project_url,
bug_id=bug_id,
release_monitoring_project_id=release_monitoring_project_id,
)

# The .__func__ are needed for Python < 3.10
Expand Down
1 change: 1 addition & 0 deletions tests/integration/test_new_hotness_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ def test_new_hotness_update(new_hotness_update, sync_release_model):
sync_default_files=False,
add_pr_instructions=True,
resolved_bugs=["rhbz#2106196"],
release_monitoring_project_id=4181,
).and_return(pr).once()
flexmock(PackitAPI).should_receive("clean")

Expand Down
1 change: 1 addition & 0 deletions tests/integration/test_pr_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -2611,6 +2611,7 @@ def _get_project(url, *_, **__):
sync_default_files=False,
add_pr_instructions=True,
resolved_bugs=["rhbz#123", "rhbz#124"],
release_monitoring_project_id=None,
).and_return(pr).once()
flexmock(PackitAPI).should_receive("clean")

Expand Down
6 changes: 6 additions & 0 deletions tests/integration/test_release_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ def test_dist_git_push_release_handle(github_release_webhook, propose_downstream
sync_default_files=True,
add_pr_instructions=True,
resolved_bugs=[],
release_monitoring_project_id=None,
).and_return(pr).once()
flexmock(PackitAPI).should_receive("clean")

Expand Down Expand Up @@ -299,6 +300,7 @@ def test_dist_git_push_release_handle_multiple_branches(
sync_default_files=True,
add_pr_instructions=True,
resolved_bugs=[],
release_monitoring_project_id=None,
).and_return(pr).once()

flexmock(ProposeDownstreamJobHelper).should_receive(
Expand Down Expand Up @@ -429,6 +431,7 @@ def test_dist_git_push_release_handle_one_failed(
sync_default_files=True,
add_pr_instructions=True,
resolved_bugs=[],
release_monitoring_project_id=None,
).and_return(pr).once()
flexmock(ProposeDownstreamJobHelper).should_receive(
"report_status_for_branch"
Expand All @@ -448,6 +451,7 @@ def test_dist_git_push_release_handle_one_failed(
sync_default_files=True,
add_pr_instructions=True,
resolved_bugs=[],
release_monitoring_project_id=None,
).and_raise(Exception, f"Failed {model.branch}").once()
flexmock(ProposeDownstreamJobHelper).should_receive(
"report_status_for_branch"
Expand Down Expand Up @@ -686,6 +690,7 @@ def test_retry_propose_downstream_task(
sync_default_files=True,
add_pr_instructions=True,
resolved_bugs=[],
release_monitoring_project_id=None,
).and_raise(
PackitDownloadFailedException, "Failed to download source from example.com"
).once()
Expand Down Expand Up @@ -794,6 +799,7 @@ def test_dont_retry_propose_downstream_task(
sync_default_files=True,
add_pr_instructions=True,
resolved_bugs=[],
release_monitoring_project_id=None,
).and_raise(
PackitDownloadFailedException, "Failed to download source from example.com"
).once()
Expand Down
1 change: 1 addition & 0 deletions tests/unit/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -1672,6 +1672,7 @@ def test_parse_new_hotness_update(
assert isinstance(event_object, NewHotnessUpdateEvent)
assert isinstance(event_object.project, PagureProject)
assert event_object.package_name == "redis"
assert event_object.release_monitoring_project_id == 4181
assert event_object.repo_namespace == repo_namespace
assert event_object.repo_name == repo_name
assert (
Expand Down
1 change: 1 addition & 0 deletions tests/unit/test_steve.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ def test_process_message(event, private, enabled_private_namespaces, success):
sync_default_files=True,
add_pr_instructions=True,
resolved_bugs=[],
release_monitoring_project_id=None,
).and_return(pr).times(1 if success else 0)
flexmock(shutil).should_receive("rmtree").with_args("")

Expand Down

0 comments on commit 6483a03

Please sign in to comment.