# -*- python -*- # ex: set filetype=python: import multiprocessing import os import yaml from pathlib import Path from buildbot.plugins import changes, schedulers, steps, worker, util basedir = os.path.abspath(os.path.dirname(__file__)) with (Path(basedir).parent / 'passwords.yaml').open() as fp: passwords = yaml.safe_load(fp) c = BuildmasterConfig = {} ####### WORKERS # TODO switch building podman checkupdates image to LocalWorkers? mb = multiprocessing.cpu_count() c['workers'] = [ worker.Worker("checkupdates", passwords['workers']['checkupdates'], max_builds=mb), # TODO use DockerLatentWorker+podman for running `fdroid checkupdates` worker.DockerLatentWorker( 'docker', None, docker_host='unix:/run/user/1000/podman/podman.sock', image='localhost/checkupdates', dockerfile='Containerfile', hostconfig={ 'network_mode': 'host', 'privileged': True, }, max_builds=mb, ), ] c['protocols'] = {"pb": {"port": "tcp:9989:interface=127.0.0.1"}} ####### CHANGESOURCES c['change_source'] = [ changes.PBChangeSource( port='tcp:9999:interface=127.0.0.1', user='checkupdates', passwd=passwords['change_source']['checkupdates'], ), ] ####### SCHEDULERS c['schedulers'] = [ schedulers.SingleBranchScheduler( name="checkupdates", change_filter=util.ChangeFilter(branch='checkupdates'), treeStableTimer=None, builderNames=["checkupdates"], ), schedulers.ForceScheduler(name="force", builderNames=["checkupdates"]), schedulers.ForceScheduler(name="force-podman", builderNames=["podman"]), schedulers.Nightly( name="podman-weekly", builderNames=["podman"], dayOfWeek=0, hour=0 ), ] ####### BUILDERS checkupdates_factory = util.BuildFactory() checkupdates_factory.addSteps( [ # Run the container with low priority, one CPU, and a timeout # to avoid a single job dominating the system # steps.ShellCommand( # command=[ # 'nice', # '-n19', # 'ionice', # '-c3', # 'podman', # 'run', # '--name', # util.Property('packageName'), # '--detach', # '--rm', # '--cpus=1', # force one job per CPU # 'checkupdates', # 'sleep', # '3600', # hard 1 hour timeout # ] # ), steps.ShellCommand( workdir='/home/fdroid/fdroiddata', command=[ # 'nice', # '-n19', # 'ionice', # '-c3', # 'podman', # 'exec', # util.Property('packageName'), '/home/fdroid/fdroidserver/fdroid', 'checkupdates', '--auto', '--commit', '--verbose', util.Property('packageName'), ], logfiles={ "status": { "filename": "repo/status/checkupdates.json", } }, lazylogfiles=True, ), # steps.ShellCommand( # command=['podman', 'stop', '--ignore', util.Property('packageName')] # ), ] ) # TODO ensure only one of these jobs runs at a time podman_factory = util.BuildFactory() podman_factory.addSteps( [ steps.ShellCommand( command=['git', 'remote', 'update', '--prune'], workdir='/home/fdroid/fdroiddata', ), steps.ShellCommand( command=['git', 'reset', '--hard', 'upstream/master'], workdir='/home/fdroid/fdroiddata', ), steps.ShellCommand( command=['podman', 'system', 'prune', '--force'], ), steps.ShellCommand( command=[ 'podman', 'build', '--pull-always', '--volume', '/home/fdroid/fdroiddata:/fdroiddata:ro', '--tag', 'checkupdates', '/home/fdroid/checkupdates-buildbot', ], ), ] ) c['builders'] = [ util.BuilderConfig( name="checkupdates", workernames=["docker"], factory=checkupdates_factory ), util.BuilderConfig( name="podman", workernames=["checkupdates"], factory=podman_factory ), ] ####### 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'] = [] ####### PROJECT IDENTITY c['title'] = "Check Updates" # c['titleURL'] = "https://checkupdates.f-droid.org/" # c['buildbotURL'] = "https://checkupdates.f-droid.org/" c['titleURL'] = "https://checkupdates.at.or.at/" c['buildbotURL'] = "https://checkupdates.at.or.at/" c['www'] = dict( port='tcp:8010:interface=127.0.0.1', plugins=dict(waterfall_view={}, console_view={}, grid_view={}), ) ####### 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", } c['buildbotNetUsageData'] = None