Freshmaker is a service which:
Freshmaker waits for new fedmsg messages about artifact being updated,
this happens in consumer.py
. Every fedmsg message handled by a Freshmaker
is parsed by one of the parsers which can be found in the parsers
directory.
This parser converts the fedmsg to Event
object (inherits from BaseEvent
).
All the events are defined in the events.py
.
This Event object is then handled by one or more handlers defined
in the handlers
directory.
The handlers typically do following:
Most of the common tasks for handlers are already implemented in Freshmaker including:
The handler which rebuilds all the modules after the .spec
file of RPM including in a module is updated can look like this:
class RebuildImagesOnGitRPMSpecChange(BaseHandler): name = "RebuildImagesOnGitRPMSpecChange" def can_handle(self, event): return isinstance(event, GitRPMSpecChangeEvent) def handle(self, event): # Get the list of modules with this package from this branch using PDC. pdc = PDC(conf) modules = pdc.get_latest_modules(component_name=event.rpm, component_branch=event.branch, active='true') for module in modules: name = module['variant_name'] version = module['variant_version'] # Check if Freshmaker is configured to rebuild this module. if not self.allow_build(ArtifactType.MODULE, name=name, version=version): continue # To rebuild a module, we need to bump its release in dist-git repo. commit_msg = "Bump to rebuild because of %s rpm spec update (%s)." % (event.rpm, event.rev) rev = utils.bump_distgit_repo('modules', name, branch=version, commit_msg=commit_msg, logger=log) # We start the rebuild of a module and store it in Freshmkaer DB. build_id = self.build_module(name, version, rev) if build_id is not None: self.record_build(event, name, ArtifactType.MODULE, build_id)
Create and activate a Python virtual environment.
Install the dependencies with:
python3 setup.py develop
Install the requirements:
pip3 install -r requirements.txt
Install the requirements useful to run the tests:
pip3 install -r test-requirements.txt
Run the tests:
pytest tests/