Author: Matti Picus <matti.pi...@gmail.com> Branch: numpy-tests Changeset: r902:fedbf76c4d87 Date: 2013-11-25 21:32 +0200 http://bitbucket.org/pypy/buildbot/changeset/fedbf76c4d87/
Log: replace git's parseGotRevision to add something like a revision number diff --git a/bot2/pypybuildbot/builds.py b/bot2/pypybuildbot/builds.py --- a/bot2/pypybuildbot/builds.py +++ b/bot2/pypybuildbot/builds.py @@ -1,6 +1,6 @@ from buildbot.steps.source.mercurial import Mercurial from buildbot.steps.source.git import Git -from buildbot.process.buildstep import BuildStep +from buildbot.process.buildstep import BuildStep, BuildStepFailed from buildbot.process import factory from buildbot.steps import shell, transfer from buildbot.steps.trigger import Trigger @@ -8,6 +8,8 @@ from buildbot import locks from pypybuildbot.util import symlink_force from buildbot.status.results import SKIPPED, SUCCESS +from twisted.python import log +from twisted.internet import defer import os # buildbot supports SlaveLocks, which can be used to limit the amout of builds @@ -187,30 +189,6 @@ # changeset-id for got_revision and final_file_name and sorting the builds # chronologically -class UpdateGitCheckout(ShellCmd): - description = 'git checkout' - command = 'UNKNOWN' - - def __init__(self, workdir=None, haltOnFailure=True, force_branch=None, - **kwargs): - ShellCmd.__init__(self, workdir=workdir, haltOnFailure=haltOnFailure, - **kwargs) - self.force_branch = force_branch - self.addFactoryArguments(force_branch=force_branch) - - def start(self): - if self.force_branch is not None: - branch = self.force_branch - # Note: We could add a warning to the output if we - # ignore the branch set by the user. - else: - properties = self.build.getProperties() - branch = properties['branch'] or 'default' - command = ["git", "checkout", "-f", branch] - self.setCommand(command) - ShellCmd.start(self) - - class CheckGotRevision(ShellCmd): description = 'got_revision' command = ['hg', 'parents', '--template', 'got_revision:{rev}:{node}'] @@ -326,14 +304,23 @@ workdir=workdir, logEnviron=False)) +class PyPyGit(Git): + @defer.inlineCallbacks + def parseGotRevision(self, _=None): + stdout = yield self._dovccmd(['describe', '--tags', 'HEAD'], collectStdout=True) + revision = ':'.join(stdout.strip().split('-')[-2:]) + log.msg("Got Git revision %s" % (revision, )) + self.updateSourceProperty('got_revision', revision) + defer.returnValue(0) + def update_git(platform, factory, repourl, workdir, use_branch, - force_branch=None): - factory.addStep( - Git( + force_branch='HEAD'): + factory.addStep( PyPyGit( repourl=repourl, mode='full', method='fresh', workdir=workdir, + branch=force_branch, logEnviron=False)) def setup_steps(platform, factory, workdir=None, diff --git a/bot2/pypybuildbot/test/test_builds.py b/bot2/pypybuildbot/test/test_builds.py --- a/bot2/pypybuildbot/test/test_builds.py +++ b/bot2/pypybuildbot/test/test_builds.py @@ -77,11 +77,11 @@ translateInst = builds.Translate(['-O0'], ['--no-allworkingmodules']) assert translateInst.command[-len(expected):] == expected - + translateFactory = translateInst._getStepFactory().factory args = translateInst._getStepFactory().args rebuiltTranslate = translateFactory(*args) - + assert rebuiltTranslate.command[-len(expected):] == expected rebuiltTranslate.build = FakeBuild() @@ -108,7 +108,7 @@ 'base-latest')) class TestPytestCmd(object): - + class Fake(object): def __init__(self, **kwds): self.__dict__.update(kwds) @@ -154,7 +154,7 @@ summary = builder.summary_by_branch_and_revision[('trunk', '123')] assert summary.to_tuple() == (1, 1, 2, 0) - def test_branch_is_None(self): + def test_branch_is_None(self): step, cmd, builder = self._create(log='', rev='123', branch=None) step.commandComplete(cmd) assert ('trunk', '123') in builder.summary_by_branch_and_revision @@ -163,7 +163,7 @@ step, cmd, builder = self._create(log='', rev='123', branch='branch/foo/') step.commandComplete(cmd) assert ('branch/foo', '123') in builder.summary_by_branch_and_revision - + def test_multiple_logs(self): log = """F a/b.py:test_one . a/b.py:test_two _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit