Login | Register
My pages Projects Community openCollabNet

repoguard
Wiki: NewFeature

Edit this page | Links to this page | Page information | Attachments | Refresh page

 

General Implementation Flow

The general flow for creation of a new feature for ?RepoGuard is the following:

  • Propose and discuss the new feature on the developer mailing list.

    • You should subscribe to the Developers and Builds discussions.

  • If the feature is considered "useful", you have to create a new issue in the tracker.

    • Define the target milestone.
    • Using Eclipse and Mylyn makes it easier to work with the issue tracker.

    • Implement the new feature:
      • Follow the coding standard.

      • Provide proper unit tests using the pytest and mock library. Try to achieve a line coverage of at least 80%.

      • If possible provide a separate small integration test which tests the feature end-to-end.
      • Run the audit build target and clean up all errors before you commit your changes.

      • Commit changes using the following commit template: ISSUE #<TASKID>:<COMMENT>

      • Ensure that the Continuous Integration build is still running.

  • A feature is considered "done" if:
    • Unit tests and integrations tests are provided and running.
    • Sufficient user documentation has been provided.

Hints on Implementing a new Check

Basically, you should consider existing check implementations and their respective tests. The following example shows a minimal check implementation with its corresponding configuration.

from repoguard.core.module import Boolean, Check, ConfigSerializer

class Config(ConfigSerializer): # Describes the configuration parameters and maps it to the configuration file
    class types(ConfigSerializer.types):
         success = Boolean(optional=True, default=True)

class DummyCheck(Check): # Name is used in the configuration file
    
    __config__ = Config # Binds the configuration to the check
    
def _run(self, config): # Implements the behavior
    if config.success:
        return self.success("Done!") 
    else:
        return self.error("Failure!")

Hints on Implementing a new Handler

Basically, you should consider existing handler implementations and their respective tests. The following shows a minimal check implementation with its corresponding configuration.

from repoguard.core.module import Handler, HandlerConfig, String

class Config(HandlerConfig):
    class types(HandlerConfig.types):
        filepath = String()

class DummyFile(Handler): # Name is used in the configuration file
    
    __config__ = Config
        
    def _write(self, config, entry): ' Does the work
       file_object = open(config.filepath , "a")
       try:
           file_object.write(str(entry))
       finally:
           file_object.close()
        
    def _singularize(self, config, entry): # Interface which called when a check has been finished. 
        self._write(config, entry)
        
    def _summarize(self, config, protocol): # Interface which called when all checks (of a profile) have been finished.
        self._write(config, protocol)

Using RepoGuard entry points

Assuming you implement a check or a handler in your own package. To make it available for ?RepoGuard just extend your setup script as follows:

setuptools.setup(
    ... other stuff ...
    entry_points={
        "repoguard.checks": ["FooCheck = foo.foo_check:FooCheck"],
        "repoguard.handlers": ["FooHandler = foo.foo_handler:FooHandler"]}) 

When you install your package foo, ?RepoGuard can make us of the check FooCheck and the handler FooHandler.

NewFeature (last edited 2012-09-12 14:45:02 -0800 by ?schlauch)