Skip to content

Commit

Permalink
fix: reference GitHub Installation event explicitly
Browse files Browse the repository at this point in the history
Signed-off-by: Matej Focko <[email protected]>
  • Loading branch information
mfocko committed Oct 28, 2024
1 parent 1cd634b commit 7f6c114
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions alembic/versions/c6250555a36c_.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

from alembic import op
from packit_service.constants import ALLOWLIST_CONSTANTS
from packit_service.worker.events import InstallationEvent
from packit_service.worker.events import github

# revision identifiers, used by Alembic.
revision = "c6250555a36c"
Expand Down Expand Up @@ -224,7 +224,7 @@ def db(cls) -> PersistentDict:

class RedisInstallation(RedisModel):
table_name = "github_installation"
event_data: InstallationEvent
event_data: github.installation.Installation


class RedisBuild(RedisModel):
Expand Down
6 changes: 3 additions & 3 deletions packit_service/worker/allowlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
AbstractCoprBuildEvent,
CheckRerunEvent,
EventData,
InstallationEvent,
IssueCommentEvent,
IssueCommentGitlabEvent,
KojiTaskEvent,
Expand All @@ -44,6 +43,7 @@
PushPagureEvent,
ReleaseEvent,
TestingFarmResultsEvent,
github,
)
from packit_service.worker.events.comment import CommitCommentEvent
from packit_service.worker.events.gitlab import ReleaseGitlabEvent
Expand All @@ -61,7 +61,7 @@
PullRequestCommentPagureEvent,
AbstractCoprBuildEvent,
TestingFarmResultsEvent,
InstallationEvent,
github.installation.Installation,
KojiTaskEvent,
KojiBuildEvent,
CheckRerunEvent,
Expand Down Expand Up @@ -518,7 +518,7 @@ def check_and_report(
PullRequestCommentPagureEvent,
AbstractCoprBuildEvent,
TestingFarmResultsEvent,
InstallationEvent,
github.installation.Installation,
KojiTaskEvent,
KojiBuildEvent,
KojiBuildTagEvent,
Expand Down
6 changes: 3 additions & 3 deletions packit_service/worker/handlers/forges.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
from packit_service.worker.checker.abstract import Checker
from packit_service.worker.checker.forges import IsIssueInNotificationRepoChecker
from packit_service.worker.events import (
InstallationEvent,
IssueCommentEvent,
github,
)
from packit_service.worker.handlers.abstract import (
JobHandler,
Expand All @@ -44,7 +44,7 @@
logger = logging.getLogger(__name__)


@reacts_to(event=InstallationEvent)
@reacts_to(event=github.installation.Installation)
class GithubAppInstallationHandler(
JobHandler,
ConfigFromEventMixin,
Expand All @@ -66,7 +66,7 @@ def __init__(
event=event,
)

self.installation_event = InstallationEvent.from_event_dict(event)
self.installation_event = github.installation.Installation.from_event_dict(event)
self.account_type = self.installation_event.account_type
self.account_login = self.installation_event.account_login
self.sender_login = self.installation_event.sender_login
Expand Down
4 changes: 2 additions & 2 deletions packit_service/worker/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
CheckRerunEvent,
Event,
EventData,
InstallationEvent,
IssueCommentEvent,
PullRequestCommentPagureEvent,
github,
)
from packit_service.worker.events.comment import (
AbstractCommentEvent,
Expand Down Expand Up @@ -221,7 +221,7 @@ def process(self) -> list[TaskResults]:

# installation is handled differently b/c app is installed to GitHub account
# not repository, so package config with jobs is missing
if isinstance(self.event, InstallationEvent):
if isinstance(self.event, github.installation.Installation):
GithubAppInstallationHandler.get_signature(
event=self.event,
job=None,
Expand Down
8 changes: 4 additions & 4 deletions packit_service/worker/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
CheckRerunReleaseEvent,
CoprBuildEndEvent,
CoprBuildStartEvent,
InstallationEvent,
IssueCommentEvent,
IssueCommentGitlabEvent,
KojiTaskEvent,
Expand All @@ -56,6 +55,7 @@
TagPushGitlabEvent,
TestingFarmResultsEvent,
VMImageBuildResultEvent,
github,
)
from packit_service.worker.events.comment import CommitCommentEvent
from packit_service.worker.events.enums import (
Expand Down Expand Up @@ -98,7 +98,7 @@ def parse_event(
) -> Optional[
Union[
PullRequestGithubEvent,
InstallationEvent,
github.installation.Installation,
ReleaseEvent,
TestingFarmResultsEvent,
PullRequestCommentGithubEvent,
Expand Down Expand Up @@ -1125,7 +1125,7 @@ def parse_check_rerun_event(
return event

@staticmethod
def parse_installation_event(event) -> Optional[InstallationEvent]:
def parse_installation_event(event) -> Optional[github.installation.Installation]:
"""Look into the provided event and see if it is Github App installation details."""
# Check if installation key in JSON isn't enough, we have to check the account as well
if not nested_get(event, "installation", "account"):
Expand Down Expand Up @@ -1157,7 +1157,7 @@ def parse_installation_event(event) -> Optional[InstallationEvent]:
sender_id = event["sender"]["id"]
sender_login = event["sender"]["login"]

return InstallationEvent(
return github.installation.Installation(
installation_id,
account_login,
account_id,
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/events/test_github.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
CheckRerunCommitEvent,
CheckRerunPullRequestEvent,
CheckRerunReleaseEvent,
InstallationEvent,
IssueCommentEvent,
PullRequestCommentGithubEvent,
PullRequestGithubEvent,
PushGitHubEvent,
ReleaseEvent,
github,
)
from packit_service.worker.events.comment import CommitCommentEvent
from packit_service.worker.events.enums import (
Expand Down Expand Up @@ -105,7 +105,7 @@ def commit_comment():
def test_parse_installation(github_installation):
event_object = Parser.parse_event(github_installation)

assert isinstance(event_object, InstallationEvent)
assert isinstance(event_object, github.installation.Installation)
assert event_object.installation_id == 1708454
assert event_object.account_login == "packit-service"
assert event_object.account_id == 46870917
Expand Down
6 changes: 3 additions & 3 deletions tests_openshift/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
TFTTestRunTargetModel,
sa_session_transaction,
)
from packit_service.worker.events import InstallationEvent
from packit_service.worker.events import github


class SampleValues:
Expand Down Expand Up @@ -1382,7 +1382,7 @@ def new_allowlist_entry(clean_before_and_after):
@pytest.fixture()
def installation_events():
return [
InstallationEvent(
github.installation.Installation(
installation_id=3767734,
account_login="teg",
account_id=5409,
Expand All @@ -1393,7 +1393,7 @@ def installation_events():
sender_id=5409,
sender_login="teg",
),
InstallationEvent(
github.installation.Installation(
installation_id=6813698,
account_login="Pac23",
account_id=11048203,
Expand Down

0 comments on commit 7f6c114

Please sign in to comment.