Skip to content
Stéphane Brunner edited this page Mar 20, 2024 · 9 revisions

Create

To create a module you should implement the interface github_app_geo_project.module.Module

Then provide it as a ghci.module entry point, if you use Poetry with something like:

[tool.poetry.plugins."ghci.module"]
changelog = "github_app_geo_project.module.changelog:Changelog"

Use

To use it, it should be adder in the application module, in the production.ini file in the key application.<application>.modules

Then some configuration should be added in the application configuration profiles or in the repositories in the configuration file, using the main key as the module entrypoint name.

Module base

from github_app_geo_project.module import Module, utils

class MyModule(Module[dict]):

    def title(self) -> str:
       return "My title"

    def description(self) -> str:
       return "My description"

    def documentation_url(self) -> str:
       return "http://example.com/documentation"

    def get_actions(self, context: GetActionContext) -> list[Action]:
       """This function will "convert" the webhool call and the command line events into a job to fill the queue"""
       return [...]

    def process(self, context: ProcessContext[T]) -> str | None:
       """This function will process the job"""
       return None

    def cleanup(self, context: CleanupContext) -> None:
       """Optional, called if the module is disable by configuration"""

    def get_json_schema(self) -> JsonDict:
       """The schema is used to provide a combined schema for the project configuration"""

    def get_github_application_permissions(self) -> GitHubApplicationPermissions:
       """Provids the permissons end events required by the module"""

Working with issue dashboard

The module can interact with his own part of the dashboard, for that, you should write something like:

from github_app_geo_project.module import Module, utils

class MyModule(Module[dict]):
    def required_issue_dashboard(self) -> bool:
       return True

    def process(self, context: ProcessContext[dict]) -> Optional[str]:
       dashboard = utils.DashboardIssue(context.issue_data)
       todo = dashboard.is_checked('<name>')
       if todo:
          ...
          dashboard.set_check('<name>', False)
          return dashboard.to_string()
       return None