lab132 / buildbot-gitea

Buildbot plugin for integration with gitea.
MIT License
62 stars 21 forks source link

Unable to load buildbot.reporters:GiteaStatusPush: cannot import name 'MessageFormatterRenderable' #23

Closed s-daveb closed 3 years ago

s-daveb commented 3 years ago

Hi, I hope you're doing well.

I was wondering if you could help me. I'm trying to set up a simple buildbot instance in a FreeBSD Jail.... but whenver I try to launch the system with the reporter, I get the error message in the title,

Environment:

Twistd.log:

21-07-06 06:30:35+0000 [-] Loading buildbot.tac...
2021-07-06 06:30:35+0000 [-] Loaded.
2021-07-06 06:30:35+0000 [-] twistd 20.3.0 (/usr/local/bin/python3.7 3.7.10) starting up.
2021-07-06 06:30:35+0000 [-] reactor class: twisted.internet.pollreactor.PollReactor.
2021-07-06 06:30:35+0000 [-] Starting BuildMaster -- buildbot.version: 2.7.0
2021-07-06 06:30:35+0000 [-] Loading configuration from '/var/live/buildbot/master.cfg'
2021-07-06 06:30:35+0000 [-] Traceback (most recent call last):
2021-07-06 06:30:35+0000 [-]   File "/usr/local/lib/python3.7/site-packages/buildbot/plugins/db.py", line 214, in _load_entry
2021-07-06 06:30:35+0000 [-]     result = entry.load()
2021-07-06 06:30:35+0000 [-]   File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2443, in load
2021-07-06 06:30:35+0000 [-]     return self.resolve()
2021-07-06 06:30:35+0000 [-]   File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2449, in resolve
2021-07-06 06:30:35+0000 [-]     module = __import__(self.module_name, fromlist=['__name__'], level=0)
2021-07-06 06:30:35+0000 [-]   File "/usr/local/lib/python3.7/site-packages/buildbot_gitea-1.4.0-py3.7.egg/buildbot_gitea/reporter.py", line 21, in <module>
2021-07-06 06:30:35+0000 [-]     from buildbot.reporters.generators.build import BuildStartEndStatusGenerator
2021-07-06 06:30:35+0000 [-]   File "/usr/local/lib/python3.7/site-packages/buildbot/reporters/generators/build.py", line 22, in <module>
2021-07-06 06:30:35+0000 [-]     from buildbot.reporters.message import MessageFormatterRenderable
2021-07-06 06:30:35+0000 [-] ImportError: cannot import name 'MessageFormatterRenderable' from 'buildbot.reporters.message' (/usr/local/lib/python3.7/site-packages/buildbot/reporters/message.py)
2021-07-06 06:30:35+0000 [-] error while parsing config file:
    Traceback (most recent call last):
      File "/usr/local/lib/python3.7/site-packages/twisted/python/threadpool.py", line 266, in <lambda>
        inContext.theWork = lambda: context.call(ctx, func, *args, **kw)
      File "/usr/local/lib/python3.7/site-packages/twisted/python/context.py", line 122, in callWithContext
        return self.currentContext().callWithContext(ctx, func, *args, **kw)
      File "/usr/local/lib/python3.7/site-packages/twisted/python/context.py", line 85, in callWithContext
        return func(*args,**kw)
      File "/usr/local/lib/python3.7/site-packages/buildbot/config.py", line 170, in loadConfig
        self.basedir, self.configFileName)
    --- <exception caught here> ---
      File "/usr/local/lib/python3.7/site-packages/buildbot/config.py", line 128, in loadConfigDict
        execfile(filename, localDict)
      File "/usr/local/lib/python3.7/site-packages/twisted/python/compat.py", line 247, in execfile
        exec(code, globals, locals)
      File "/var/live/buildbot/master.cfg", line 51, in <module>
        reporters.GiteaStatusPush(
      File "/usr/local/lib/python3.7/site-packages/buildbot/plugins/db.py", line 275, in __getattr__
        raise AttributeError(str(err))
    builtins.AttributeError: Unable to load buildbot.reporters:GiteaStatusPush: cannot import name 'MessageFormatterRenderable' from 'buildbot.reporters.message' (/usr/local/lib/python3.7/site-packages/buildbot/reporters/message.py)

2021-07-06 06:30:35+0000 [-] Configuration Errors:
2021-07-06 06:30:35+0000 [-]   error while parsing config file: Unable to load buildbot.reporters:GiteaStatusPush: cannot import name 'MessageFormatterRenderable' from 'buildbot.reporters.message' (/usr/local/lib/python3.7/site-packages/buildbot/reporters/message.py) (traceback in logfile)
2021-07-06 06:30:35+0000 [-] Halting master.

master.cfg:

# -*- python -*-
# ex: set filetype=python:

from buildbot.plugins import *

# This is a sample buildmaster config file. It must be installed as
# 'master.cfg' in your buildmaster's base directory.

# This is the dictionary that the buildmaster pays attention to. We also use
# a shorter alias to save typing.
c = BuildmasterConfig = {}

####### PROJECT IDENTITY

# the 'title' string will appear at the top of this buildbot installation's
# home pages (linked to the 'titleURL').

c['title'] = "Buildbot"
c['titleURL'] = "http://buildbot.local/"

# the 'buildbotURL' string should point to the location where the buildbot's
# internal web server is visible. This typically uses the port number set in
# the 'www' entry below, but with an externally-visible host name which the
# buildbot cannot figure out without some help.

c['buildbotURL'] = "http://buildbot.local/"

# minimalistic config to activate new web UI
c['www'] = {
    'port': 80,
    'plugins': {
        #'waterfall_view' : {},
        #'console_view'   : {},
        #'grid_view'      : {},
    },
    'change_hook_dialects' : {
        'gitea': {
            'secret' : 'REDACTED',
            'onlyIncludePushCommit': False
        }
    }
}

####### BUILDBOT SERVICES

# 'services' is a list of BuildbotService items like reporter targets. The
# status of each build will be pushed to these targets. buildbot/reporters/*.py
# has a variety to choose from, like IRC bots.
#
c['services'] =  []
c['services'].append(
    reporters.GiteaStatusPush('http://gitea.local',
                              'REDACTED')
)
#

####### WORKERS

# The 'workers' list defines the set of recognized workers. Each element is
# a Worker object, specifying a unique worker name and password.  The same
# worker name and password must be configured on the worker.
c['workers'] = [worker.Worker("worker0", "REDACTED")]

# 'protocols' contains information about protocols which master will use for
# communicating with workers. You must define at least 'port' option that workers
# could connect to your master with this protocol.
# 'port' must match the value configured into the workers (with their
# --master option)
c['protocols'] = {'pb': {'port': 9989}}

####### CHANGESOURCES

# the 'change_source' setting tells the buildmaster how it should find out
#  about source code changes.
c['change_source'] = []
####### SCHEDULERS

# Configure the Schedulers, which decide how to react to incoming changes.
c['schedulers'] = []

# In this case, just kick off a 'automake' build
c['schedulers'].append(schedulers.SingleBranchScheduler(
                            name="gitea webhooks",
                            change_filter=util.ChangeFilter(branch_re=".*"),
                            codebases={'quartz-warriors': {}},
                            builderNames=["automake"]))

c['schedulers'].append(schedulers.ForceScheduler(
                            name="force",
                            builderNames=["automake"]))

####### BUILDERS

# The 'builders' list defines the Builders, which tell Buildbot how to perform a build:
# what steps, and which workers can execute them.  Note that any particular build will
# only take place on one worker.

factory = util.BuildFactory()

factory.addStep(steps.Git(
    repourl="http://gitea.local/sdaveb/qw-game.git",
    mode='incremental',
    workdir="build",
    branch="devel",
    progress=True,
    logEnviron=False,
))

factory.addStep(steps.ShellCommand(command=["sh", "bootstrap.sh"]))
factory.addStep(steps.ShellCommand(command=["sh", "build-debug.sh"],
                                   env={"PYTHONPATH": "."}))

c['builders'] = []
c['builders'].append(
    util.BuilderConfig(name="automake",
      workernames=["worker0"],
      factory=factory))

####### DB URL

c['db'] = {
    # This specifies what database buildbot uses to store its state.
    # It's easy to start with sqlite, but it's recommended to switch to a dedicated
    # database, such as PostgreSQL or MySQL, for use in production environments.
    # http://docs.buildbot.net/current/manual/configuration/global.html#database-specification
    'db_url' : "sqlite:///state.sqlite",
}

# vim: set noet ts=4 sts=0 sw=4 :
pampersrocker commented 3 years ago

Seems like the minimum dependent version for this plugin for buildbot is incorrect. The MessageFormatterRenderable was introduced around buildbot 2.10. You are using buildbot 2.7.0. If that is not possible you can use this plugin in Version v1.3.1.

pampersrocker commented 3 years ago

Your log is stating you are using buildbot_gitea v1.4.0 Which has the dependency

install_requires=[
          "buildbot>=3.0.0"
      ]

So i'm not sure how that got installed in the first place.

s-daveb commented 3 years ago

Oh, I've tried it with the latest version and was thinking maybe some of my system application versions were incompatible.

. The MessageFormatterRenderable was introduced around buildbot 2.10. You are using buildbot 2.7.0. If that is not possible you can use this plugin in Version v1.3.1.

I had a hunch it was something like this.

s-daveb commented 3 years ago

It seems the latest version of Buildbot in FreeBSD Ports is 2.10.5, which should support that new API. Will open another issue if I still have problems.

@pampersrocker Thank you for your help