[154424] contrib/buildbot-test

larryv at macports.org larryv at macports.org
Sat Oct 29 03:25:46 CEST 2016


Revision: 154424
          https://trac.macports.org/changeset/154424
Author:   larryv at macports.org
Date:     2016-10-29 03:25:46 +0200 (Sat, 29 Oct 2016)
Log Message:
-----------
buildbot: Improve configuration override

- Trim config.json.sample by removing keys that are unlikely to be
  changed. They just duplicate the defaults from master.cfg.

- Replace hardcoded settings with config defaults to allow overriding
  them from the config file.

- Organize defaults a bit since there are so many of them now.

- Catch IOError when reading the config file instead of checking for
  existence.

Modified Paths:
--------------
    contrib/buildbot-test/config.json.sample
    contrib/buildbot-test/master.cfg

Modified: contrib/buildbot-test/config.json.sample
===================================================================
--- contrib/buildbot-test/config.json.sample	2016-10-29 01:25:02 UTC (rev 154423)
+++ contrib/buildbot-test/config.json.sample	2016-10-29 01:25:46 UTC (rev 154424)
@@ -1,13 +1,7 @@
 {
     "production":   false,
     "privkey":      "/var/keys/macports-privkey.pem",
-    "slaveport":    9989,
-    "httpport":     8010,
-    "buildboturl":  "http://localhost:8010/",
-    "htpasswdfile": "htpasswd",
-    "mpbbsvnurl":   "https://svn.macports.org/repository/macports/contrib/mp-buildbot",
-    "svnurl":       "https://svn.macports.org/repository/macports/trunk",
-    "archivesite":  "https://packages.macports.org",
+    "buildboturl":  "http://domain.tld:8010/",
     "slaveprefix":  "/opt/local",
     "toolsprefix":  "/opt/mports",
     "deploy": {

Modified: contrib/buildbot-test/master.cfg
===================================================================
--- contrib/buildbot-test/master.cfg	2016-10-29 01:25:02 UTC (rev 154423)
+++ contrib/buildbot-test/master.cfg	2016-10-29 01:25:46 UTC (rev 154424)
@@ -45,29 +45,57 @@
 # a shorter alias to save typing.
 c = BuildmasterConfig = {}
 
-# Master variable to toggle config between testing on your personal system
-# (where /opt/local shouldn't be messed with) and the production server (where
-# it has to be)
-
 config = {
+    # Production or development
     'production': False,
-    'privkey': '',
+
+    # Connections
     'slaveport': 9989,
     'httpport': 8010,
-    'buildboturl': 'http://localhost:8010/',
-    'htpasswdfile': 'htpasswd',
+
+    # External configuration. Use absolute paths when overriding these.
+    'configfile': _path('config.json'),
+    'workersfile': _path('slaves.json'),
+    'htpasswdfile': _path('htpasswd'),
+
+    # Sources
     'mpbbsvnurl': 'https://svn.macports.org/repository/macports/contrib/mp-buildbot',
     'svnurl': 'https://svn.macports.org/repository/macports/trunk',
-    'archivesite': 'https://packages.macports.org',
+
+    # Tooling
     'slaveprefix': '/opt/local',
     'toolsprefix': '/opt/mports',
-    'deploy': {}
+
+    # Deployment
+    'archivesite': 'https://packages.macports.org',
+    'privkey': '',
+    'deploy': {},
+
+    # Site definitions
+    # (http://docs.buildbot.net/0.8.12/manual/cfg-global.html#site-definitions)
+    'title': 'MacPorts',
+    'titleurl': 'https://www.macports.org/',
+    'buildboturl': 'http://localhost:8010/',
+
+    # Database
+    # (http://docs.buildbot.net/0.8.12/manual/cfg-global.html#database-specification)
+    'db': {'db_url': 'sqlite:///state.sqlite'},
+
+    # Data lifetime
+    # (http://docs.buildbot.net/0.8.12/manual/cfg-global.html#data-lifetime)
+    'buildcachesize': 600,
+    'buildhorizon': 10000,
+    'eventhorizon': 2000,
+    'loghorizon': 5000
     }
 
-if os.path.exists(_path('config.json')):
-    with open(_path('config.json')) as f:
-        configdata = json.load(f)
-    config.update(configdata)
+# Override defaults with external settings.
+try:
+    with open(config['configfile']) as f:
+        extconfig = json.load(f)
+except IOError:
+    extconfig = {}
+config.update(extconfig)
 
 path_base = '/usr/bin:/bin:/usr/sbin:/sbin'
 path_ports = os.path.join(config['toolsprefix'], 'bin') + ':' + path_base
@@ -83,7 +111,7 @@
 # a BuildSlave object, specifying a unique slave name and password.  The same
 # slave name and password must be configured on the slave.
 
-with open(_path('slaves.json')) as f:
+with open(config['workersfile']) as f:
     slavedata = json.load(f)
 
 # convert unicode to byte strings
@@ -774,9 +802,8 @@
 # installation's WebStatus home page (linked to the
 # 'titleURL') and is embedded in the title of the waterfall HTML page.
 
-c['title'] = 'MacPorts'
-c['titleURL'] = 'https://www.macports.org/'
-
+c['title'] = config['title']
+c['titleURL'] = config['titleurl']
 c['buildbotURL'] = config['buildboturl']
 c['status'].append(WebStatus(
     http_port=config['httpport'],
@@ -791,11 +818,11 @@
 
 # This specifies what database buildbot uses to store its state. You can
 # leave this at its default for all but the largest installations.
-c['db'] = {'db_url': 'sqlite:///state.sqlite'}
+c['db'] = config['db']
 
 
 ####### DATA LIFETIME #######
-c['buildHorizon'] = 10000
-c['logHorizon'] = 5000
-c['eventHorizon'] = 2000
-c['buildCacheSize'] = 600
+c['buildHorizon'] = config['buildhorizon']
+c['logHorizon'] = config['loghorizon']
+c['eventHorizon'] = config['eventhorizon']
+c['buildCacheSize'] = config['buildcachesize']
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macports.org/pipermail/macports-changes/attachments/20161029/19107516/attachment-0002.html>


More information about the macports-changes mailing list