[Python-Dev] Buildbot questions

Trent Mick trentm at ActiveState.com
Sat Jan 7 01:12:21 CET 2006


> > To wipe out the build occassionally you could (presumably) add a
> > starting step to the Python 'builder' (in the build master.cfg) to 
> >     rm -rf $builddir
> > every, say, Sunday night.
> 
> Sure, that would be the idea. How to formulate it?

I think I'm part of the way there with the following. I've subclassed
the "SVN" source build step to add support for new source mode:
"update_and_clobber_occassionally". Basically it (hackily) changes the
source type btwn "update", which we usually want, and "clobber", which
we sometimes want.

The current problem with this is that I don't know if the build step
objects have access to a local data store -- so it could, say, count how
many builds have been done to know to clobber every tenth one. The
current code just chooses to clobber for any build on Sunday. Not a very
satisfying solution.

Brian,
Is there a way for build steps to maintain some state?


    ------------ clipped from the build master's master.cfg -----------------
    ...
    class SVNEx(step.SVN):
        """A SVN Source build step that adds the ability for the Source
        "mode" to be a combination of "update" and "clobber". This is useful if
        your general just want to update the source tree from source code control,
        but occassionally want to clobber and start fresh.

        To use this functionality use mode="update_and_clobber_occassionally".
        To control when "occassionally" is now override the "should_clobber"
        method. The default implementation is currently hardcoded to
        "every Sunday". (This is a HACK. Perhaps there should be constructor
        options to clobber every Nth time or to have cron-like arguments -- see
        "Nightly" in scheduler.py. I don't know if "steps" have access to a local
        data store to be able to do this -- e.g. keep a counter.)

        Ideally this would be an option of the base "Source" class in
        buildbot/process/step.py.
        """
        def __init__(self, **kwargs):
            if kwargs.has_key("mode") \
               and kwargs["mode"] == "update_and_clobber_occassionally":
                self.update_and_clobber_occassionally = True
                kwargs["mode"] = "update"
            else:
                self.update_and_clobber_occassionally = False
            step.SVN.__init__(self, **kwargs)

        def should_clobber(self):
            from datetime import date
            is_sunday = date.today().weekday() == 6 # it is Sunday
            from twisted.python import log
            log.msg("should_clobber? %s", (is_sunday and "yes" or "no"))
            return is_sunday

        def startVC(self, *args, **kwargs):
            if self.update_and_clobber_occassionally:
                if self.should_clobber():
                    self.args["mode"] = "clobber"
                else:
                    self.args["mode"] = "update"
            step.SVN.startVC(self, *args, **kwargs)


    python_factory = factory.GNUAutoconf(
        s(SVNEx, svnurl="http://svn.python.org/projects/python/trunk",
          mode="update_and_clobber_occassionally"),
        test=["make", "test"],  # use `make testall`?
    )

    # Then use python_factory as something like so:
    #c['builders'] = [
    #    {'name': "linux-x86",
    #          'slavename': "...",
    #          'builddir': "python",
    #          'factory': python_factory,
    #          },
    #    ...
    #]
    ------------ clipped from the build master's master.cfg -----------------



Cheers,
Trent

-- 
Trent Mick
trentm at activestate.com


More information about the Python-Dev mailing list