commit 22fc282e5b5854bfd2b6abeb3e0926e77712d81d
Author: Daniel Moch <daniel@danielmoch.com>
Date: Sun, 2 Dec 2018 19:39:42 -0500
Initial commit
Diffstat:
8 files changed, 266 insertions(+), 0 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -0,0 +1,6 @@
+worker/*/
+server/*/
+*.log
+*.pid
+twistd.*
+*.sqlite
diff --git a/TODO.txt b/TODO.txt
@@ -0,0 +1,2 @@
+- Use libvirt latent worker
+- Harden configuration
diff --git a/buildbot-worker@.service b/buildbot-worker@.service
@@ -0,0 +1,22 @@
+[Unit]
+Description=Buildbot Worker
+Wants=network.target
+After=network.target
+
+[Service]
+User=http
+Group=http
+WorkingDirectory=/srv/http/buildbot
+ExecStart=/usr/bin/buildbot-worker start --nodaemon %I
+## if using EC2 Latent worker, you want to uncomment following line, and
+## comment out the Restart line
+# ExecStopPost=shutdown now
+Restart=always
+# Security!
+ProtectSystem=full
+ProtectHome=yes
+PrivateDevices=yes
+PrivateTmp=yes
+
+[Install]
+WantedBy=multi-user.target
diff --git a/buildbot@.service b/buildbot@.service
@@ -0,0 +1,21 @@
+[Unit]
+Description=Buildbot Master
+Wants=network.target
+After=network.target
+
+
+[Service]
+User=http
+Group=http
+WorkingDirectory=/srv/http/buildbot
+ExecStart=/usr/bin/buildbot start --nodaemon %I
+ExecReload=/bin/kill -HUP $MAINPID
+Restart=always
+# Security!
+ProtectSystem=full
+ProtectHome=yes
+PrivateDevices=yes
+PrivateTmp=yes
+
+[Install]
+WantedBy=multi-user.target
diff --git a/pacman.txt b/pacman.txt
@@ -0,0 +1,8 @@
+buildbot
+buildbot-worker
+python-buildbot-www
+python-buildbot-waterfall-view
+python-buildbot-console-view
+python-buildbot-grid-view
+python-buildbot-badges
+ttf-dejavu
diff --git a/server/buildbot.tac b/server/buildbot.tac
@@ -0,0 +1,31 @@
+import os
+
+from twisted.application import service
+from buildbot.master import BuildMaster
+
+basedir = '.'
+rotateLength = 10000000
+maxRotatedFiles = 10
+configfile = 'master.cfg'
+
+# Default umask for server
+umask = None
+
+# if this is a relocatable tac file, get the directory containing the TAC
+if basedir == '.':
+ import os
+ basedir = os.path.abspath(os.path.dirname(__file__))
+
+# note: this line is matched against to check that this is a buildmaster
+# directory; do not edit it.
+application = service.Application('buildmaster')
+from twisted.python.logfile import LogFile
+from twisted.python.log import ILogObserver, FileLogObserver
+logfile = LogFile.fromFullPath(os.path.join(basedir, "twistd.log"), rotateLength=rotateLength,
+ maxRotatedFiles=maxRotatedFiles)
+application.setComponent(ILogObserver, FileLogObserver(logfile).emit)
+
+m = BuildMaster(basedir, configfile, umask)
+m.setServiceParent(application)
+m.log_rotation.rotateLength = rotateLength
+m.log_rotation.maxRotatedFiles = maxRotatedFiles
diff --git a/server/master.cfg b/server/master.cfg
@@ -0,0 +1,133 @@
+# -*- python -*-
+# vim: 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 = {}
+c['buildbotNetUsageData'] = None
+
+####### SECRETS PROVIDERS
+c['secretsProviders'] = [secrets.SecretInAFile(dirname='/srv/http/buildbot/secrets')]
+
+####### 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("dotcom-worker", util.Secret('worker-pass'))]
+
+# '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. Here we point to the buildbot version of a python hello-world project.
+
+c['change_source'] = []
+c['change_source'].append(changes.PBChangeSource(port=9999, user='gitdotcom', util.Secret('cspass')))
+
+####### SCHEDULERS
+
+# Configure the Schedulers, which decide how to react to incoming changes. In this
+# case, just kick off a 'runtests' build
+
+c['schedulers'] = []
+c['schedulers'].append(schedulers.SingleBranchScheduler(
+ name="nncli master",
+ change_filter=util.ChangeFilter(branch="master", project="nncli"),
+ treeStableTimer=None,
+ builderNames=["nncli"]))
+c['schedulers'].append(schedulers.SingleBranchScheduler(
+ name="nncli PR",
+ change_filter=util.ChangeFilter(branch_re="pr_*", project="nncli"),
+ treeStableTimer=None,
+ builderNames=["nncli"]))
+c['schedulers'].append(schedulers.SingleBranchScheduler(
+ name="hookmeup master",
+ change_filter=util.ChangeFilter(branch="master", project="hookmeup"),
+ treeStableTimer=None,
+ builderNames=["hookmeup"]))
+c['schedulers'].append(schedulers.SingleBranchScheduler(
+ name="hookmeup PR",
+ change_filter=util.ChangeFilter(branch_re="pr_*", project="hookmeup"),
+ treeStableTimer=None,
+ builderNames=["hookmeup"]))
+c['schedulers'].append(schedulers.ForceScheduler(
+ name="force",
+ builderNames=["nncli", "hookmeup"]))
+
+####### 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.
+
+nncli_factory = util.BuildFactory()
+# check out the source
+nncli_factory.addStep(steps.Git(repourl='https://git.danielmoch.com/nncli.git', mode='incremental'))
+# run the tests (note that this will require that 'trial' is installed)
+nncli_factory.addStep(steps.Configure(command=["make", "test-install"], env={"PYTHONPATH": "."}))
+nncli_factory.addStep(steps.Test(command=["make", "test-all"], env={"PYTHONPATH": "."}))
+
+hookmeup_factory = util.BuildFactory()
+# check out the source
+hookmeup_factory.addStep(steps.Git(repourl='https://git.danielmoch.com/hookmeup.git', mode='incremental'))
+# run the tests (note that this will require that 'trial' is installed)
+hookmeup_factory.addStep(steps.Configure(command=["pipenv", "--bare", "install", "--dev", "--skip-lock"], env={"PYTHONPATH": "."}))
+hookmeup_factory.addStep(steps.Test(command=["make", "test-all"], env={"PYTHONPATH": "."}))
+
+c['builders'] = []
+c['builders'].append(
+ util.BuilderConfig(name="nncli",
+ workernames=["dotcom-worker"],
+ factory=nncli_factory))
+c['builders'].append(
+ util.BuilderConfig(name="hookmeup",
+ workernames=["dotcom-worker"],
+ factory=hookmeup_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
+
+# the 'title' string will appear at the top of this buildbot installation's
+# home pages (linked to the 'titleURL').
+
+c['title'] = "Daniel Moch CI"
+c['titleURL'] = "https://git.danielmoch.com/"
+
+# 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'] = "https://builds.danielmoch.com/"
+
+# minimalistic config to activate new web UI
+c['www'] = dict(port=8010,
+ plugins=dict(waterfall_view={}, console_view={},
+ grid_view={}, badges={"style": "flat"}))
+
+####### DB URL
+
+c['db'] = {
+ # This specifies what database buildbot uses to store its state. You can leave
+ # this at its default for all but the largest installations.
+ 'db_url' : "sqlite:///state.sqlite",
+}
diff --git a/worker/buildbot.tac b/worker/buildbot.tac
@@ -0,0 +1,43 @@
+
+import os
+
+from buildbot_worker.bot import Worker
+from buildbot.plugins import util
+from twisted.application import service
+
+basedir = '.'
+rotateLength = 10000000
+maxRotatedFiles = 10
+
+# if this is a relocatable tac file, get the directory containing the TAC
+if basedir == '.':
+ import os.path
+ basedir = os.path.abspath(os.path.dirname(__file__))
+
+# note: this line is matched against to check that this is a worker
+# directory; do not edit it.
+application = service.Application('buildbot-worker')
+
+from twisted.python.logfile import LogFile
+from twisted.python.log import ILogObserver, FileLogObserver
+logfile = LogFile.fromFullPath(
+ os.path.join(basedir, "twistd.log"), rotateLength=rotateLength,
+ maxRotatedFiles=maxRotatedFiles)
+application.setComponent(ILogObserver, FileLogObserver(logfile).emit)
+
+buildmaster_host = 'localhost'
+port = 9989
+workername = 'dotcom-worker'
+passwd = util.Secret('worker-pass')
+keepalive = 600
+umask = None
+maxdelay = 300
+numcpus = None
+allow_shutdown = None
+maxretries = None
+
+s = Worker(buildmaster_host, port, workername, passwd, basedir,
+ keepalive, umask=umask, maxdelay=maxdelay,
+ numcpus=numcpus, allow_shutdown=allow_shutdown,
+ maxRetries=maxretries)
+s.setServiceParent(application)