Beispiel #1
0
    def sched_builder(self):
        for project in sorted(Projects.get_all(), key=lambda p: p.name):
            if (project.name == ""):
                continue
            try:
                log.msg("checking project: %s" % project.name)
                if project.is_building():
                    log.msg("project %s still building, skip" % project.name)
                    continue
                branch = "master"
                git = Git(project)
                if os.path.isdir(git.workdir):
                    git.checkout_branch(branch)
                    git.pull()
                else:
                    git.clone(branch)

                if (not os.path.isdir(git.workdir)):
                    continue

                for remote_branch in git.branches(remote=True):
                    git.checkout_remote_branch(
                        remote_branch.replace('origin/', ''))

                for release in ('stable', 'testing', 'unstable'):
                    if project.last_tag(release) != git.last_tag(release):
                        try:
                            _, version = git.last_tag(release).split('_')
                            log.msg("new %s tag, building version: %s" %
                                    (release, version))
                            d = threads.deferToThread(self.send_job,
                                                      project.name, branch,
                                                      release, version)
                        except Exception, e:
                            log.msg("tag not parsed: %s:%s" %
                                    (project.name, git.last_tag(release)))

                #if int(project.experimental) == 1:
                #    for branch in project.branches():
                #        git.checkout_remote_branch(branch)
                #        git.checkout_branch(branch)
                #        git.pull()
                #        if project.last_commit(branch) != git.last_commit(branch):
                #            project.last_commit(branch, git.last_commit(branch))
                #            d = threads.deferToThread(self.send_job, project.name, branch, 'experimental', None)
                #
                #        git.checkout_branch("master")

            except Exception, e:
                log.err(e)
Beispiel #2
0
class TestGit:
    def __init__(self):
        self.project = mocker.Mocker()
        self.project.name = 'test_repo'
        self.project.git_url = 'tests/test_repo'
        self.project.version = '1.0'
        self.project.branch = 'master'
        self.project.last_tag = ''
        self.project.last_commit = ''
        self.project.build_cmd = 'python setup.py build'
        self.project.install_cmd = 'python setup.py install --root=BUILDROOT'
        self.project.replay()
        self.git = Git(self.project, workdir=os.path.join(os.path.dirname(__file__), 'workspace'))

        if not os.path.isdir(self.git.workdir):
            self.git.clone(self.project.branch)

    def clone_test(self):
        assert os.path.isdir(self.git.workdir)
        assert os.path.isdir(os.path.join(self.git.workdir, '.git'))

    def checkout_tag_test(self):
        self.git.checkout_tag('testing_0.0.1')
        assert_true(os.path.isfile(os.path.join(self.git.workdir, 'a')))
        assert_false(os.path.isfile(os.path.join(self.git.workdir, 'c')))
        self.git.checkout_tag('testing_0.0.2')
        assert_true(os.path.isfile(os.path.join(self.git.workdir, 'c')))
    
    def last_tag_test(self):
        assert_equal(self.git.last_tag('testing'), 'testing_0.0.2')
Beispiel #3
0
class Git_test:
    def __init__(self):
        self.project = mocker.Mocker()
        self.project.name = 'test_repo'
        self.project.git_url = './test_repo'
        self.project.version = '1.0'
        self.project.branch = 'master'
        self.project.last_tag = ''
        self.project.last_commit = ''
        self.project.build_cmd = 'python setup.py build'
        self.project.install_cmd = 'python setup.py install --root=BUILDROOT'
        self.project.replay()
        self.git = Git(self.project,
                       workdir=os.path.join(os.path.dirname(__file__),
                                            'workspace'))

        if not os.path.isdir(self.git.workdir):
            self.git.clone(self.project.branch)

    def clone_test(self):
        assert os.path.isdir(self.git.workdir)
        assert os.path.isdir(os.path.join(self.git.workdir, '.git'))

    def checkout_tag_test(self):
        self.git.checkout_tag('test_1')
        assert_true(os.path.isfile(os.path.join(self.git.workdir, 'a')))
        assert_false(os.path.isfile(os.path.join(self.git.workdir, 'b')))
        self.git.checkout_tag('test_2')
        assert_true(os.path.isfile(os.path.join(self.git.workdir, 'b')))

    def last_tag_test(self):
        assert_equal(self.git.last_tag('testing'), 'testing_0.0.2')
Beispiel #4
0
    def sched_builder(self):
        for project in sorted(Projects.get_all(), key=lambda p: p.name):
            if (project.name == ""):
                continue
            try:
                log.msg("checking project: %s" % project.name)
                if project.is_building():
                    log.msg("project %s still building, skip" % project.name)
                    continue
                branch = "master"
                git = Git(project)
                if os.path.isdir(git.workdir):
                    git.checkout_branch(branch)
                    git.pull()
                else:
                    git.clone(branch)

                if not os.path.isdir(git.workdir):
                    continue

                for remote_branch in git.branches(remote=True):
                    git.checkout_remote_branch(remote_branch.replace('origin/', ''))

                for release in ('stable', 'testing', 'unstable'):
                    if project.last_tag(release) != git.last_tag(release):
                        try:
                            _, version = git.last_tag(release).split('_')
                            log.msg("new %s tag, building version: %s" % (release, version))
                            d = threads.deferToThread(self.send_job, project.name, branch, release, version)
                        except Exception, e:
                            log.msg("tag not parsed: %s:%s" % (project.name, git.last_tag(release)))
                
                #if int(project.experimental) == 1:
                #    for branch in project.branches():
                #        git.checkout_remote_branch(branch)
                #        git.checkout_branch(branch)
                #        git.pull()
                #        if project.last_commit(branch) != git.last_commit(branch):
                #            project.last_commit(branch, git.last_commit(branch))
                #            d = threads.deferToThread(self.send_job, project.name, branch, 'experimental', None)
                # 
                #        git.checkout_branch("master")

            except Exception, e:
                log.err(e)