コード例 #1
0
ファイル: check.py プロジェクト: NiklasRosenstein/shut
  def _run_project_checks(self, project: Project) -> t.Iterator[Check]:
    checks = []
    for plugin_name in sorted(self.config[project].plugins):
      plugin = load_entrypoint(CheckPlugin, plugin_name)()
      try:
        for check in sorted(plugin.get_project_checks(project), key=lambda c: c.name):
          check.name = f'{plugin_name}:{check.name}'
          yield check
          checks.append(check)
      except Exception as exc:
        logger.exception(
          'Uncaught exception in project <subj>%s</subj> application checks for plugin <val>%s</val>',
          project, plugin_name
        )
        check = Check(f'{plugin_name}', CheckResult.ERROR, str(exc))
        yield check
        checks.append(check)
      if not self.app.repository.is_monorepo:
        try:
          for check in sorted(plugin.get_application_checks(self.app), key=lambda c: c.name):
            check.name = f'{plugin_name}:{check.name}'
            yield check
            checks.append(check)
        except Exception as exc:
          logger.exception('Uncaught exception in application checks for plugin <val>%s</val>', plugin_name)
          check = Check(f'{plugin_name}', CheckResult.ERROR, str(exc))
          yield check
          checks.append(check)

    if checks:
      if self.app.repository.is_monorepo:
        self.line(f'Checks for project <info>{project.id}</info>')
        self.line('')
      self._print_checks(checks)
      self.line('')
コード例 #2
0
ファイル: project.py プロジェクト: NiklasRosenstein/shut
    def _get_project_handler(self) -> ProjectHandlerPlugin:
        """ Returns the handler for this project. """

        from nr.util.plugins import load_entrypoint
        from slam.plugins import ProjectHandlerPlugin

        handler_name = self.config().handler or 'default'
        assert isinstance(handler_name, str), repr(handler_name)

        handler = load_entrypoint(ProjectHandlerPlugin,
                                  handler_name)()  # type: ignore[misc]
        assert handler.matches_project(self), (self, handler)
        return handler
コード例 #3
0
ファイル: check.py プロジェクト: NiklasRosenstein/shut
  def _run_application_checks(self) -> t.Iterable[Check]:
    plugin_names = {p for project in self.app.repository.projects() for p in self.config[project].plugins}
    checks = []
    for plugin_name in sorted(plugin_names):
      plugin = load_entrypoint(CheckPlugin, plugin_name)()
      for check in sorted(plugin.get_application_checks(self.app), key=lambda c: c.name):
        check.name = f'{plugin_name}:{check.name}'
        yield check
        checks.append(check)

    if checks:
      self.line(f'Global checks:')
      self._print_checks(checks)
      self.line('')
コード例 #4
0
ファイル: repository.py プロジェクト: NiklasRosenstein/shut
    def _get_repository_handler(self) -> RepositoryHandlerPlugin:
        """ Returns the handler for this repository. """

        from nr.util.plugins import load_entrypoint
        from slam.plugins import RepositoryHandlerPlugin

        handler_name = self.raw_config().get('repository',
                                             {}).get('handler') or 'default'
        assert isinstance(handler_name, str), repr(handler_name)

        handler = load_entrypoint(RepositoryHandlerPlugin,
                                  handler_name)()  # type: ignore[misc]
        assert handler.matches_repository(self), (self, handler)
        return handler
コード例 #5
0
    def handle(self) -> int:
        from nr.util.plugins import iter_entrypoints, load_entrypoint

        if not self._validate_arguments():
            return 1

        if self.option("list"):
            for ep in iter_entrypoints(
                    ChangelogUpdateAutomationPlugin.ENTRYPOINT):
                self.line(f'  • {ep.name}')
            return 0

        automation_plugin: ChangelogUpdateAutomationPlugin | None = None
        if plugin_name := self.option("use"):
            logger.info(
                'Loading changelog update automation plugin <subj>%s</subj>',
                plugin_name)
            automation_plugin = load_entrypoint(
                ChangelogUpdateAutomationPlugin,
                plugin_name)()  # type: ignore[misc]
            automation_plugin.io = self.io
            automation_plugin.initialize()
            base_revision: str = automation_plugin.get_base_ref()