Commits

Ralph Bean committed e69e82c

Much simpler.

  • Participants
  • Parent commits 64c5445

Comments (0)

Files changed (5)

File _finalize_report.py

-#!/usr/bin/env python
-
-import mako.template
-from datetime import datetime
-from _repolist import repos
-
-# API Design ANTI-PATTERN.  Don't look at this.  :)
-from tw2.devtools.browser import WbPage as page
-import tw2.core.core
-from tw2.core import make_middleware
-
-tmpl_str = """
-<html>
-<head>
-<link rel='stylesheet' href='threebean.css' type='text/css'>
-<script type="text/javascript" src="http://vis.stanford.edu/protovis/protovis-r3.2.js"></script>
-</head>
-<body>
-<div class="wrapper">
-<h2><code>tw2</code> tests</h2>
-<table>
-<tr>
-    <th>Repo</th>
-    <th>Demo</th>
-    <th>Module</th>
-    <th>Commits</th>
-    <th>Service</th>
-    <th>Account</th>
-    <th>Coverage</th>
-    <th>Tests</th>
-</tr>
-% for r in repos:
-<tr>
-    <td><a href="${r.url}">[repo]</a></td>
-    <td><a href="http://tw2-demos.threebean.org/module?module=${r.name}">[demo]</a></td>
-    <td>${r.name}</td>
-    <td>${sparkwidget(module=r.name).display() |n}</td>
-    <td>${r.service}</td>
-    <td>${r.account}</td>
-    <td><a href="htmlcov-${repr(r)}/index.html">${r.coverage}</a></td>
-    <td><a href="results-${repr(r)}.txt">${r.tests}</a></td>
-</tr>
-% endfor
-</table>
-<div class="push"></div>
-</div>
-    <div class="footer">
-    <p>This is a project of <a href="http://threebean.org">[three]Bean.org</a>.  Tests are
-    run nightly.  Last generated at ${timestamp}.</p>
-    <p>
-    If you'd like to see your widget library listed on this page or the
-    <a href="http://tw2-demos.threebean.org">demo page</a>, please email the
-    <a href="http://groups.google.com/group/toscawidgets-discuss">toscawidgets-discuss</a> mailing list.</p>
-    </div>
-</body>
-</html>
-"""
-
-if __name__ == '__main__':
-    # Ridiculous hack :/
-    rl = tw2.core.core.request_local()
-    rl.clear()
-    rl['middleware'] = make_middleware()
-    page = page.req()
-
-    for r in repos:
-        r.gather_results()
-    template = mako.template.Template(tmpl_str)
-    output = template.render(repos=repos, sparkwidget=page.commits,
-                             timestamp=datetime.now().strftime('%F %T'))
-    with open('htmlcov/index.html', 'w') as f:
-        f.write(output)
-

File _repolist.py

-#!/usr/bin/env python
-
-import sys
-import os
-import shutil
-import hashlib
-
-NONE = '__none__'
-
-bitbucket_repos = {
-}
-github_repos = {
-    'toscawidgets': [
-        'tw2.jit',
-        'tw2.jqplugins.jqgrid',
-        'tw2.jqplugins.jqplot',
-        'tw2.jqplugins.ui',
-        'tw2.jqplugins.fg',
-        'tw2.jqplugins.portlets',
-        'tw2.jqplugins.cookies',
-        'tw2.jqplugins.elfinder',
-        'tw2.jqplugins.elrte',
-        'tw2.jqplugins.gritter',
-        'tw2.jqplugins.tagify',
-        'tw2.protovis.core',
-        'tw2.protovis.conventional',
-        'tw2.protovis.custom',
-        'tw2.protovis.hierarchies',
-        'tw2.tipster',
-        'tw2.polymaps',
-        'tw2.jqplugins.dynatree',
-        'tw2.etc',
-        'tw2.excanvas',
-        'tw2.jqplugins.flot',
-        'tw2.slideymenu',
-        'tw2.rrd',
-        'tw2.qrcode',
-        'tw2.tinymce',
-        'tw2.dyntext',
-        'tw2.d3',
-        'tw2.captcha',
-        'tw2.core',
-        'tw2.dynforms',
-        'tw2.forms',
-        'tw2.devtools',
-        'tw2.sqla',
-        'tw2.yui',
-        'tw2.jquery',
-        'tw2.lesscss',
-        'tw2.util.html5shim',
-    ],
-}
-
-# This is for repos hosted neither on github nor bitbucket.  One-offs.
-custom_repos = {
-# Syntax should look something like:
-#    'tw2.forms' : [
-#        {
-#            'url' : 'https://bitbucket.org/toscawidgets/tw2.forms',
-#            'vcs' : 'mercurial',
-#            'clone_url' : 'https://bitbucket.org/toscawidgets/tw2.forms',
-#        }
-#    ],
-}
-
-class Repo(object):
-    def __init__(self, service, project, account, url, vcs, clone_url):
-        self.service = service
-        if project[3] != '.':
-            project = project[:3] + '.' + project[3:]
-        self.project = project
-        self.account = account
-        self.url = url
-        self.vcs = vcs
-        self.clone_url = clone_url
-        command_lookup = {
-            'mercurial' : 'hg clone',
-            'git' : 'git clone',
-        }
-        self.command = command_lookup[self.vcs]
-        self.tests = 'undefined'
-        self.coverage = 'undefined'
-
-    def gather_results(self):
-        """ Should only be called after _run-tests.sh is called. """
-        # Not very robust.
-        try:
-            with open('htmlcov/results-%s' % repr(self)) as f:
-                lines = f.readlines()
-                maybe_lines = [l for l in lines if 'Ran' in l]
-                self.tests = " <br/> ".join(lines)
-                try:
-                    self.tests = lines[-3].strip()
-                    self.tests = maybe_lines[0]
-                except IndexError as e:
-                    # Just for debugging this script.  This should never happen.
-                    pass
-        except IOError as e:
-            pass
-
-        with open('htmlcov/summary.data') as f:
-            lines = f.readlines()
-
-        for line in lines:
-            try:
-                name, coverage = line.strip().split()
-            except ValueError as e:
-                continue
-            if name == repr(self):
-                self.coverage = coverage
-
-
-    def __repr__(self):
-        return '-'.join([
-            self.name,
-            self.account,
-            self.service,
-            hashlib.md5(self.clone_url).hexdigest()
-        ])
-
-    @property
-    def name(self):
-        return self.project
-
-    @property
-    def clone_command(self):
-        return self.command + " " + self.clone_url + " " + repr(self)
-
-    @property
-    def test_command(self):
-        commands = [
-            "cd /home/threebean/tw2-tests",
-            "cd %s" % repr(self),
-            "rm -rf ~/.virtualenvs/%s-venv" % repr(self),
-            "virtualenv --no-site-packages ~/.virtualenvs/%s-venv" % repr(self),
-            "source ~/.virtualenvs/%s-venv/bin/activate" % repr(self),
-            "python setup.py test -q 2>> ../htmlcov/results-%s" % repr(self),
-            "pip install coverage",
-            "coverage run --source=tw2/ setup.py test",
-            "COV=$(coverage report --omit=*.kid --omit=*samples* | tail -1 | awk ' { print $4 } ')",
-            "coverage html --omit=*.kid --omit=*samples*",
-            "mv htmlcov ../htmlcov/htmlcov-%s" % repr(self),
-            "deactivate",
-            "cd /home/threebean/tw2-tests",
-            "echo \"%s $COV\" >> htmlcov/summary.data" % repr(self),
-        ]
-        return " ;\n".join(commands)
-
-repos = []
-
-for username, projects in bitbucket_repos.iteritems():
-    for project in projects:
-        repos.append(Repo(
-            service='bitbucket',
-            project=project,
-            account=username,
-            url='http://bitbucket.org/{v}/{k}'.format(
-                v=username, k=project),
-            vcs='mercurial',
-            clone_url='http://bitbucket.org/{v}/{k}'.format(
-                v=username, k=project),
-        ))
-
-for username, projects in github_repos.iteritems():
-    for project in projects:
-        repos.append(Repo(
-            service='github',
-            project=project,
-            account=username,
-            url='http://github.com/{v}/{k}'.format(
-                v=username, k=project),
-            vcs='git',
-            clone_url='https://github.com/{v}/{k}.git'.format(
-                v=username, k=project),
-        ))
-
-for project, paramsets in custom_repos.iteritems():
-    for paramset in paramsets:
-        repos.append(Repo(
-            service=NONE,
-            project=project,
-            account=NONE,
-            url=paramset['url'],
-            vcs=paramset['vcs'],
-            clone_url=paramset['clone_url'],
-        ))
-
-repos.sort(lambda r1, r2: cmp(r1.name, r2.name))
-
-def destroy():
-    """ rm -rf tw2* """
-    print "#----"
-    print "#Destroying."
-    current_dir = '/'.join(__file__.split('/')[:-1])
-    d, dirs, files = list(os.walk(current_dir))[0]
-    for d in dirs:
-        if not d.startswith('tw2'):
-            print "# Ignoring directory", d
-            continue
-        print "# Removing", d
-        shutil.rmtree(d)
-    d, dirs, files = list(os.walk(current_dir+"/htmlcov/"))[0]
-    for d in dirs:
-        if not d.startswith('htmlcov'):
-            print "# Ignoring directory", d
-            continue
-        d = 'htmlcov/'+d
-        print "# Removing", d
-        shutil.rmtree(d)
-    for f in files:
-        if f.startswith('results'):
-            print "# Removing", f
-            os.remove('htmlcov/'+f)
-    try:
-        os.remove('htmlcov/summary.data')
-    except Exception as e:
-        pass
-    print "#Destroyed!"
-    print "#----"
-
-def clone():
-    for repo in repos:
-        print "# Clone", repr(repo)
-        print repo.clone_command
-
-def test():
-    for repo in repos:
-        print
-        print "# Tests for", repr(repo)
-        print repo.test_command
-
-
-if __name__ == '__main__':
-    print "#!/bin/bash"
-    print "source ~/.bashrc"
-    print
-
-    destroy()
-    clone()
-    test()
-

File cron-wrapper.sh

 #!/bin/bash
 
 source /home/threebean/.bashrc
-
-LOG=/home/threebean/tw2-tests/nightly.log
-pushd /home/threebean/tw2-tests
-echo "************************"  > $LOG
-echo "Starting up at   $(date)" >> $LOG
-echo $(pwd) >> $LOG
-/bin/bash generate-report.sh >> $LOG 2>&1
-echo "Finishing up at  $(date)" >> $LOG
-echo "************************" >> $LOG
-pushd -
+python list-travis.py > htmlcov/index.html

File generate-report.sh

-#!/bin/bash -e
-source ~/.bashrc
-
-if [ ! -f ~/finalize_report/bin/activate ] ; then
-    virtualenv --no-site-packages ~/finalize_report
-fi
-source ~/finalize_report/bin/activate
-
-pip install mako genshi mercurial formencode
-
-./_repolist.py > _run-tests.sh
-chmod +x _run-tests.sh
-
-./_run-tests.sh
-
-hg clone https://bitbucket.org/ralphbean/tw2.devtools || echo "Not cloning."
-cd tw2.devtools ; python setup.py install ; cd -
-./_finalize_report.py
-deactivate
-rm -rf ~/webapps/tw2_tests/*
-cp htmlcov/index.html ~/webapps/tw2_tests/.
-cp htmlcov/threebean.css ~/webapps/tw2_tests/.
-mv htmlcov/htmlcov* ~/webapps/tw2_tests/.
-mv htmlcov/results* ~/webapps/tw2_tests/.
-find ~/webapps/tw2_tests/results* -exec mv {} {}.txt \;

File list-travis.py

+#!/usr/bin/env python
+
+import datetime
+import mako.template
+import github2.client
+
+ghc = github2.client.Github()
+
+username = 'toscawidgets'
+
+all_repos, page = [], 1
+while True:
+    new_repos = ghc.repos.list(username, page)
+    if not new_repos:
+        break
+    all_repos += new_repos
+    page += 1
+
+link_tmpl = """
+<img src="https://secure.travis-ci.org/{username}/{name}.png?branch={branch}">
+</img>
+"""
+
+data = sorted([dict(
+    repo=repo.name,
+    master=link_tmpl.format(
+        username=username,
+        name=repo.name,
+        branch='master'),
+    develop=link_tmpl.format(
+        username=username,
+        name=repo.name,
+        branch='develop'),
+) for repo in all_repos
+    if '-' not in repo.name],
+    lambda a, b: cmp(a['repo'], b['repo']))
+
+tmpl = """
+<html>
+<head>
+<link rel='stylesheet' href='threebean.css' type='text/css'>
+</head>
+<body>
+<div class="wrapper">
+<h2><code>tw2</code> tests</h2>
+<table>
+<tr>
+<th>github</th>
+<th>pypi</th>
+<th>demos</th>
+<th>master</th>
+<th>develop</th>
+</tr>
+
+% for row in data:
+<tr>
+<td><a href="http://github.com/${username}/${row['repo']}">${row['repo']}</a></td>
+<td><a href="http://pypi.python.org/pypi/${row['repo']}">${row['repo']}</a></td>
+<td><a href="http://tw2-demos.threebean.org/module?module=${row['repo']}">${row['repo']}</a></td>
+<td>${row['master']}</td>
+<td>${row['develop']}</td>
+</tr>
+% endfor
+</table>
+<div class="push"></div>
+</div>
+    <div class="footer">
+    <p>This is a project of <a href="http://threebean.org">[three]Bean.org</a>.  Tests are
+    run nightly.  Last generated at ${timestamp}.</p>
+    <p>
+    If you'd like to see your widget library listed on this page or the
+    <a href="http://tw2-demos.threebean.org">demo page</a>, please email the
+    <a href="http://groups.google.com/group/toscawidgets-discuss">toscawidgets-discuss</a> mailing list.</p>
+    </div>
+
+</body>
+</html>
+"""
+
+template = mako.template.Template(tmpl)
+print template.render(
+    data=data,
+    username=username,
+    timestamp=datetime.datetime.isoformat(datetime.datetime.now())
+)
+