[154412] contrib/buildbot-test/master.cfg

larryv at macports.org larryv at macports.org
Sat Oct 29 02:46:22 CEST 2016


Revision: 154412
          https://trac.macports.org/changeset/154412
Author:   larryv at macports.org
Date:     2016-10-29 02:46:22 +0200 (Sat, 29 Oct 2016)
Log Message:
-----------
buildbot: Clean up change filters

- The ChangeFilters are only used once each, so instantiate them when
  they're needed.

- Rewrite the port test into a function we can reuse.

- Reduce `change_has_ports` to a lambda.

Modified Paths:
--------------
    contrib/buildbot-test/master.cfg

Modified: contrib/buildbot-test/master.cfg
===================================================================
--- contrib/buildbot-test/master.cfg	2016-10-29 00:29:14 UTC (rev 154411)
+++ contrib/buildbot-test/master.cfg	2016-10-29 00:46:22 UTC (rev 154412)
@@ -20,7 +20,18 @@
         res.update(d)
     return res
 
+def port_from_path(path, sep='/'):
+    components = path.split(sep)
+    try:
+        if (components[0] == 'dports' and components[1] != '_resources'
+                and components[3] in ('Portfile', 'files')):
+            return components[2]
+    except IndexError:
+        pass
+    # Might be better to throw a custom exception here?
+    return None
 
+
 # This is the dictionary that the buildmaster pays attention to. We also use
 # a shorter alias to save typing.
 c = BuildmasterConfig = {}
@@ -107,18 +118,9 @@
         category='macports',
         project='ports')
 
+
 ####### SCHEDULERS #######
 
-def change_has_ports(change):
-    for f in change.files:
-        if '_resources' in f:
-            continue
-        # should actually skip changes to files/ only, but only if we know the
-        # last build of the port succeeded
-        if 'dports' in f and ('Portfile' in f or 'files' in f):
-            return True
-    return False
-
 def change_has_base(change):
     for f in change.files:
         if f.startswith('base'):
@@ -138,10 +140,6 @@
     return False
 
 from buildbot.changes.filter import ChangeFilter
-portsfilter = ChangeFilter(filter_fn=change_has_ports)
-basefilter = ChangeFilter(filter_fn=change_has_base)
-wwwfilter = ChangeFilter(filter_fn=change_has_www)
-guidefilter = ChangeFilter(filter_fn=change_has_guide)
 
 base_buildernames = ['base-'+plat for plat in build_platforms if 'legacy' not in plat and '10.6_i386' not in plat]
 portwatcher_buildernames = ['ports-'+plat+'-watcher' for plat in build_platforms if 'linux' not in plat and '10.5_ppc' != plat]
@@ -157,12 +155,16 @@
     SingleBranchScheduler(
         name='base',
         treeStableTimer=None,
-        change_filter=basefilter,
+        change_filter=ChangeFilter(
+            filter_fn=change_has_base),
         builderNames=base_buildernames),
     SingleBranchScheduler(
         name='ports',
         treeStableTimer=None,
-        change_filter=portsfilter,
+        change_filter=ChangeFilter(
+            # Should actually skip changes to files/ only, but only if
+            # we know the last build of the port succeeded.
+            filter_fn=lambda change: any(port_from_path(f) for f in change.files)),
         builderNames=portwatcher_buildernames),
     ForceScheduler(
         name='base_force',
@@ -193,7 +195,8 @@
         SingleBranchScheduler(
             name='www',
             treeStableTimer=300,
-            change_filter=wwwfilter,
+            change_filter=ChangeFilter(
+                filter_fn=change_has_www),
             builderNames=['docs-www']),
         ForceScheduler(
             name='www_force',
@@ -205,7 +208,8 @@
         SingleBranchScheduler(
             name='guide',
             treeStableTimer=300,
-            change_filter=guidefilter,
+            change_filter=ChangeFilter(
+                filter_fn=change_has_guide),
             builderNames=['docs-guide']),
         ForceScheduler(
             name='guide_force',
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macports.org/pipermail/macports-changes/attachments/20161029/52af6599/attachment-0002.html>


More information about the macports-changes mailing list