annotate bitten/web_ui.py @ 637:988f2b3e585c

0.6dev: Fixing layout of builds (config overview) when using long revision markers (as for instance used by Git). Also makes the table generally wider and the page more efficient visually. Thanks to pacopablo for patch! Closes #430.
author osimons
date Mon, 17 Aug 2009 23:58:37 +0000
parents 21902b481ee7
children 74237f60f8a9
rev   line source
379
0df178e07fdb Use UTF-8 as encoding of source files.
cmlenz
parents: 376
diff changeset
1 # -*- coding: utf-8 -*-
35
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
2 #
408
933105ab516b Update file headers and other stuff pointing to the old home.
cmlenz
parents: 391
diff changeset
3 # Copyright (C) 2005-2007 Christopher Lenz <cmlenz@gmx.de>
933105ab516b Update file headers and other stuff pointing to the old home.
cmlenz
parents: 391
diff changeset
4 # Copyright (C) 2007 Edgewall Software
163
634be6cbb808 Flip the switch: Bitten is now BSD-licensed.
cmlenz
parents: 161
diff changeset
5 # All rights reserved.
35
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
6 #
163
634be6cbb808 Flip the switch: Bitten is now BSD-licensed.
cmlenz
parents: 161
diff changeset
7 # This software is licensed as described in the file COPYING, which
634be6cbb808 Flip the switch: Bitten is now BSD-licensed.
cmlenz
parents: 161
diff changeset
8 # you should have received as part of this distribution. The terms
408
933105ab516b Update file headers and other stuff pointing to the old home.
cmlenz
parents: 391
diff changeset
9 # are also available at http://bitten.edgewall.org/wiki/License.
35
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
10
316
87c9b1e8f086 More docstring improvements.
cmlenz
parents: 311
diff changeset
11 """Implementation of the Bitten web interface."""
87c9b1e8f086 More docstring improvements.
cmlenz
parents: 311
diff changeset
12
605
c94481bc4646 0.6dev: Reverting [677] as many of these paths are also used for URLs, and hadn't considered this change enough. No major point in changing code that already works well, so simply reverting seems the best idea...
osimons
parents: 603
diff changeset
13 import posixpath
35
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
14 import re
250
0271a2b1fc23 Improvements to the web interface:
cmlenz
parents: 247
diff changeset
15 from StringIO import StringIO
35
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
16
99
efc1eed69ba8 Make Bitten deployable in Trac as a [http://peak.telecommunity.com/DevCenter/PythonEggs Python egg].
cmlenz
parents: 98
diff changeset
17 import pkg_resources
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
18 from genshi.builder import tag
629
f3bb52da9e3c 0.6dev: Adding support for attachments to configurations and build - full web implementation that mirrors what is available in Ticket and Wiki. Also added a new generic `<attach/>` command that enables attaching files to be part of a recipe and uploaded by slaves as part of build.
osimons
parents: 605
diff changeset
19 from trac.attachment import AttachmentModule
35
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
20 from trac.core import *
629
f3bb52da9e3c 0.6dev: Adding support for attachments to configurations and build - full web implementation that mirrors what is available in Ticket and Wiki. Also added a new generic `<attach/>` command that enables attaching files to be part of a recipe and uploaded by slaves as part of build.
osimons
parents: 605
diff changeset
21 from trac.mimeview.api import Context
f3bb52da9e3c 0.6dev: Adding support for attachments to configurations and build - full web implementation that mirrors what is available in Ticket and Wiki. Also added a new generic `<attach/>` command that enables attaching files to be part of a recipe and uploaded by slaves as part of build.
osimons
parents: 605
diff changeset
22 from trac.resource import Resource
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
23 from trac.timeline import ITimelineEventProvider
321
8e8d40d50001 Removed too much of the escaping in [333].
cmlenz
parents: 320
diff changeset
24 from trac.util import escape, pretty_timedelta, format_datetime, shorten_line, \
8e8d40d50001 Removed too much of the escaping in [333].
cmlenz
parents: 320
diff changeset
25 Markup
585
87de4513bfdd 0.6dev: Cleaning remaining 'frontend' datetime code - at least down to all code that interface with the various `model` classes that still only works with timestamps for input and output. See #85.
osimons
parents: 583
diff changeset
26 from trac.util.datefmt import to_timestamp, to_datetime, utc
439
20ddfbb8e879 Fix for #154, added unit tests.
cmlenz
parents: 438
diff changeset
27 from trac.util.html import html
571
bed75f6c3e57 0.6dev: Raise regular `HTTPNotFound` (404) if build or configuration is not found (instead of raising ?ttributeError` error with traceback).
osimons
parents: 562
diff changeset
28 from trac.web import IRequestHandler, IRequestFilter, HTTPNotFound
74
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
29 from trac.web.chrome import INavigationContributor, ITemplateProvider, \
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
30 add_link, add_stylesheet, add_ctxtnav, \
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
31 prevnext_nav, add_script
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
32 from trac.wiki import wiki_to_html, wiki_to_oneliner
410
7930cdd83d13 More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents: 409
diff changeset
33 from bitten.api import ILogFormatter, IReportChartGenerator, IReportSummarizer
557
b4d3d9cbf200 Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents: 528
diff changeset
34 from bitten.master import BuildMaster
203
e6ddca1e5712 Huge refactoring to remove dependency on BDB XML. Report data is now stored in the Trac database (SQLite/PostgreSQL).
cmlenz
parents: 200
diff changeset
35 from bitten.model import BuildConfig, TargetPlatform, Build, BuildStep, \
e6ddca1e5712 Huge refactoring to remove dependency on BDB XML. Report data is now stored in the Trac database (SQLite/PostgreSQL).
cmlenz
parents: 200
diff changeset
36 BuildLog, Report
228
a8c9dd7e3f71 * Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents: 219
diff changeset
37 from bitten.queue import collect_changes
114
ecc062d4fd55 Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents: 112
diff changeset
38
255
42f555e1d648 Show the build status for the latest changeset for every build configuration on the main build status page. Closes #21.
cmlenz
parents: 250
diff changeset
39 _status_label = {Build.PENDING: 'pending',
42f555e1d648 Show the build status for the latest changeset for every build configuration on the main build status page. Closes #21.
cmlenz
parents: 250
diff changeset
40 Build.IN_PROGRESS: 'in progress',
141
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
41 Build.SUCCESS: 'completed',
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
42 Build.FAILURE: 'failed'}
506
be811cb659b7 * Renamed `status2title` to `_status_title` and made it a global variable alongside `_status_label`
dfraser
parents: 504
diff changeset
43 _status_title = {Build.PENDING: 'Pending',
be811cb659b7 * Renamed `status2title` to `_status_title` and made it a global variable alongside `_status_label`
dfraser
parents: 504
diff changeset
44 Build.IN_PROGRESS: 'In Progress',
be811cb659b7 * Renamed `status2title` to `_status_title` and made it a global variable alongside `_status_label`
dfraser
parents: 504
diff changeset
45 Build.SUCCESS: 'Success',
be811cb659b7 * Renamed `status2title` to `_status_title` and made it a global variable alongside `_status_label`
dfraser
parents: 504
diff changeset
46 Build.FAILURE: 'Failure'}
141
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
47
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
48 def _get_build_data(env, req, build):
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
49 data = {'id': build.id, 'name': build.slave, 'rev': build.rev,
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
50 'status': _status_label[build.status],
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
51 'cls': _status_label[build.status].replace(' ', '-'),
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
52 'href': req.href.build(build.config, build.id),
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
53 'chgset_href': req.href.changeset(build.rev)}
141
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
54 if build.started:
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
55 data['started'] = format_datetime(build.started)
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
56 data['started_delta'] = pretty_timedelta(build.started)
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
57 data['duration'] = pretty_timedelta(build.started)
141
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
58 if build.stopped:
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
59 data['stopped'] = format_datetime(build.stopped)
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
60 data['stopped_delta'] = pretty_timedelta(build.stopped)
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
61 data['duration'] = pretty_timedelta(build.stopped, build.started)
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
62 data['slave'] = {
141
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
63 'name': build.slave,
250
0271a2b1fc23 Improvements to the web interface:
cmlenz
parents: 247
diff changeset
64 'ipnr': build.slave_info.get(Build.IP_ADDRESS),
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
65 'os_name': build.slave_info.get(Build.OS_NAME),
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
66 'os_family': build.slave_info.get(Build.OS_FAMILY),
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
67 'os_version': build.slave_info.get(Build.OS_VERSION),
141
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
68 'machine': build.slave_info.get(Build.MACHINE),
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
69 'processor': build.slave_info.get(Build.PROCESSOR)
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
70 }
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
71 return data
141
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
72
318
c042e2c7048c Minor cleanup.
cmlenz
parents: 316
diff changeset
73
141
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
74 class BittenChrome(Component):
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
75 """Provides the Bitten templates and static resources."""
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
76
320
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
77 implements(INavigationContributor, ITemplateProvider)
64
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
78
35
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
79 # INavigationContributor methods
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
80
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
81 def get_active_navigation_item(self, req):
590
1e01ab1acd60 0.6dev: Fix highlighting for active navigation. Closes #343.
osimons
parents: 585
diff changeset
82 pass
35
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
83
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
84 def get_navigation_items(self, req):
316
87c9b1e8f086 More docstring improvements.
cmlenz
parents: 311
diff changeset
85 """Return the navigation item for access the build status overview from
87c9b1e8f086 More docstring improvements.
cmlenz
parents: 311
diff changeset
86 the Trac navigation bar."""
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
87 if 'BUILD_VIEW' in req.perm:
557
b4d3d9cbf200 Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents: 528
diff changeset
88 status = ''
b4d3d9cbf200 Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents: 528
diff changeset
89 if BuildMaster(self.env).quick_status:
b4d3d9cbf200 Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents: 528
diff changeset
90 repos = self.env.get_repository(req.authname)
b4d3d9cbf200 Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents: 528
diff changeset
91 if hasattr(repos, 'sync'):
b4d3d9cbf200 Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents: 528
diff changeset
92 repos.sync()
b4d3d9cbf200 Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents: 528
diff changeset
93 for config in BuildConfig.select(self.env,
b4d3d9cbf200 Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents: 528
diff changeset
94 include_inactive=False):
b4d3d9cbf200 Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents: 528
diff changeset
95 prev_rev = None
b4d3d9cbf200 Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents: 528
diff changeset
96 for platform, rev, build in collect_changes(repos, config):
b4d3d9cbf200 Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents: 528
diff changeset
97 if rev != prev_rev:
b4d3d9cbf200 Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents: 528
diff changeset
98 if prev_rev is not None:
b4d3d9cbf200 Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents: 528
diff changeset
99 break
b4d3d9cbf200 Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents: 528
diff changeset
100 prev_rev = rev
b4d3d9cbf200 Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents: 528
diff changeset
101 if build:
b4d3d9cbf200 Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents: 528
diff changeset
102 build_data = _get_build_data(self.env, req, build)
b4d3d9cbf200 Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents: 528
diff changeset
103 if build_data['status'] == 'failed':
b4d3d9cbf200 Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents: 528
diff changeset
104 status='bittenfailed'
b4d3d9cbf200 Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents: 528
diff changeset
105 break
b4d3d9cbf200 Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents: 528
diff changeset
106 if build_data['status'] == 'in progress':
b4d3d9cbf200 Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents: 528
diff changeset
107 status='bitteninprogress'
b4d3d9cbf200 Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents: 528
diff changeset
108 elif not status:
b4d3d9cbf200 Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents: 528
diff changeset
109 if (build_data['status'] == 'completed'):
b4d3d9cbf200 Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents: 528
diff changeset
110 status='bittencompleted'
b4d3d9cbf200 Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents: 528
diff changeset
111 if not status:
b4d3d9cbf200 Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents: 528
diff changeset
112 status='bittenpending'
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
113 yield ('mainnav', 'build',
557
b4d3d9cbf200 Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents: 528
diff changeset
114 tag.a('Builds Status', href=req.href.build(), accesskey=5,
b4d3d9cbf200 Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents: 528
diff changeset
115 class_=status))
320
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
116
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
117 # ITemplatesProvider methods
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
118
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
119 def get_htdocs_dirs(self):
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
120 """Return the directories containing static resources."""
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
121 return [('bitten', pkg_resources.resource_filename(__name__, 'htdocs'))]
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
122
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
123 def get_templates_dirs(self):
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
124 """Return the directories containing templates."""
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
125 return [pkg_resources.resource_filename(__name__, 'templates')]
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
126
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
127
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
128 class BuildConfigController(Component):
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
129 """Implements the web interface for build configurations."""
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
130
590
1e01ab1acd60 0.6dev: Fix highlighting for active navigation. Closes #343.
osimons
parents: 585
diff changeset
131 implements(IRequestHandler, IRequestFilter, INavigationContributor)
1e01ab1acd60 0.6dev: Fix highlighting for active navigation. Closes #343.
osimons
parents: 585
diff changeset
132
1e01ab1acd60 0.6dev: Fix highlighting for active navigation. Closes #343.
osimons
parents: 585
diff changeset
133 # INavigationContributor methods
1e01ab1acd60 0.6dev: Fix highlighting for active navigation. Closes #343.
osimons
parents: 585
diff changeset
134
1e01ab1acd60 0.6dev: Fix highlighting for active navigation. Closes #343.
osimons
parents: 585
diff changeset
135 def get_active_navigation_item(self, req):
1e01ab1acd60 0.6dev: Fix highlighting for active navigation. Closes #343.
osimons
parents: 585
diff changeset
136 return 'build'
1e01ab1acd60 0.6dev: Fix highlighting for active navigation. Closes #343.
osimons
parents: 585
diff changeset
137
1e01ab1acd60 0.6dev: Fix highlighting for active navigation. Closes #343.
osimons
parents: 585
diff changeset
138 def get_navigation_items(self, req):
1e01ab1acd60 0.6dev: Fix highlighting for active navigation. Closes #343.
osimons
parents: 585
diff changeset
139 return []
35
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
140
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
141 # IRequestHandler methods
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
142
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
143 def match_request(self, req):
184
fbf949f4c706 Allow invalidation of builds from the web interface. This results in the build being reset to ''PENDING'' status, and all build logs, slave information and reports deleted. Basically initiates a rebuild for a specific revision and target platform.
cmlenz
parents: 182
diff changeset
144 match = re.match(r'/build(?:/([\w.-]+))?/?$', req.path_info)
35
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
145 if match:
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
146 if match.group(1):
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
147 req.args['config'] = match.group(1)
35
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
148 return True
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
149
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
150 def process_request(self, req):
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
151 req.perm.require('BUILD_VIEW')
50
0d5ad32948b7 Restrict access to web interface with custom permission actions.
cmlenz
parents: 47
diff changeset
152
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
153 action = req.args.get('action')
381
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
154 view = req.args.get('view')
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
155 config = req.args.get('config')
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
156
436
cfbc9ee622d5 Finish the move of build configuration management into the admin interface.
cmlenz
parents: 423
diff changeset
157 if config:
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
158 data = self._render_config(req, config)
436
cfbc9ee622d5 Finish the move of build configuration management into the admin interface.
cmlenz
parents: 423
diff changeset
159 elif view == 'inprogress':
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
160 data = self._render_inprogress(req)
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
161 else:
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
162 data = self._render_overview(req)
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
163
164
a9cddfae3c09 Adapt to Trac [http://projects.edgewall.com/trac/changeset/2132 r2132].
cmlenz
parents: 163
diff changeset
164 add_stylesheet(req, 'bitten/bitten.css')
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
165 return 'bitten_config.html', data, None
64
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
166
557
b4d3d9cbf200 Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents: 528
diff changeset
167 # IRequestHandler methods
b4d3d9cbf200 Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents: 528
diff changeset
168
b4d3d9cbf200 Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents: 528
diff changeset
169 def pre_process_request(self, req, handler):
b4d3d9cbf200 Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents: 528
diff changeset
170 return handler
b4d3d9cbf200 Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents: 528
diff changeset
171
b4d3d9cbf200 Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents: 528
diff changeset
172 def post_process_request(self, req, template, data, content_type):
b4d3d9cbf200 Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents: 528
diff changeset
173 if template:
b4d3d9cbf200 Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents: 528
diff changeset
174 add_stylesheet(req, 'bitten/bitten.css')
b4d3d9cbf200 Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents: 528
diff changeset
175
b4d3d9cbf200 Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents: 528
diff changeset
176 return template, data, content_type
b4d3d9cbf200 Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents: 528
diff changeset
177
64
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
178 # Internal methods
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
179
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
180 def _render_overview(self, req):
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
181 data = {'title': 'Build Status'}
209
d2b9c72e9643 Hide deactivated build configurations on the build status page by default, and provide an option panel to make them visible.
cmlenz
parents: 203
diff changeset
182 show_all = False
d2b9c72e9643 Hide deactivated build configurations on the build status page by default, and provide an option panel to make them visible.
cmlenz
parents: 203
diff changeset
183 if req.args.get('show') == 'all':
d2b9c72e9643 Hide deactivated build configurations on the build status page by default, and provide an option panel to make them visible.
cmlenz
parents: 203
diff changeset
184 show_all = True
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
185 data['show_all'] = show_all
209
d2b9c72e9643 Hide deactivated build configurations on the build status page by default, and provide an option panel to make them visible.
cmlenz
parents: 203
diff changeset
186
562
a8c84285e67a Complete rights restrictions for build configs etc - see #384. Also enhance tests to work with this code (but don't yet check that rights are restricted properly)
dfraser
parents: 561
diff changeset
187 repos = self.env.get_repository(req.authname)
a8c84285e67a Complete rights restrictions for build configs etc - see #384. Also enhance tests to work with this code (but don't yet check that rights are restricted properly)
dfraser
parents: 561
diff changeset
188 if hasattr(repos, 'sync'):
a8c84285e67a Complete rights restrictions for build configs etc - see #384. Also enhance tests to work with this code (but don't yet check that rights are restricted properly)
dfraser
parents: 561
diff changeset
189 repos.sync()
a8c84285e67a Complete rights restrictions for build configs etc - see #384. Also enhance tests to work with this code (but don't yet check that rights are restricted properly)
dfraser
parents: 561
diff changeset
190
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
191 configs = []
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
192 for config in BuildConfig.select(self.env, include_inactive=show_all):
561
8ffe90404a8c hide build configurations that user does not have rights to access in repository (silk) - fixes #384
dfraser
parents: 557
diff changeset
193 if not repos.authz.has_permission(config.path):
8ffe90404a8c hide build configurations that user does not have rights to access in repository (silk) - fixes #384
dfraser
parents: 557
diff changeset
194 continue
8ffe90404a8c hide build configurations that user does not have rights to access in repository (silk) - fixes #384
dfraser
parents: 557
diff changeset
195
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
196 description = config.description
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
197 if description:
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
198 description = wiki_to_html(description, self.env, req)
504
e2eef154f1af Add pending/inprogress build counts to web ui.
wbell
parents: 503
diff changeset
199
e2eef154f1af Add pending/inprogress build counts to web ui.
wbell
parents: 503
diff changeset
200 platforms_data = []
e2eef154f1af Add pending/inprogress build counts to web ui.
wbell
parents: 503
diff changeset
201 for platform in TargetPlatform.select(self.env, config=config.name):
e2eef154f1af Add pending/inprogress build counts to web ui.
wbell
parents: 503
diff changeset
202 pd = { 'name': platform.name,
e2eef154f1af Add pending/inprogress build counts to web ui.
wbell
parents: 503
diff changeset
203 'id': platform.id,
591
87f87c756dca 0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents: 590
diff changeset
204 'builds_pending': len(list(Build.select(self.env,
87f87c756dca 0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents: 590
diff changeset
205 config=config.name, status=Build.PENDING,
87f87c756dca 0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents: 590
diff changeset
206 platform=platform.id))),
87f87c756dca 0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents: 590
diff changeset
207 'builds_inprogress': len(list(Build.select(self.env,
87f87c756dca 0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents: 590
diff changeset
208 config=config.name, status=Build.IN_PROGRESS,
87f87c756dca 0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents: 590
diff changeset
209 platform=platform.id)))
504
e2eef154f1af Add pending/inprogress build counts to web ui.
wbell
parents: 503
diff changeset
210 }
e2eef154f1af Add pending/inprogress build counts to web ui.
wbell
parents: 503
diff changeset
211 platforms_data.append(pd)
591
87f87c756dca 0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents: 590
diff changeset
212
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
213 config_data = {
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
214 'name': config.name, 'label': config.label or config.name,
209
d2b9c72e9643 Hide deactivated build configurations on the build status page by default, and provide an option panel to make them visible.
cmlenz
parents: 203
diff changeset
215 'active': config.active, 'path': config.path,
d2b9c72e9643 Hide deactivated build configurations on the build status page by default, and provide an option panel to make them visible.
cmlenz
parents: 203
diff changeset
216 'description': description,
591
87f87c756dca 0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents: 590
diff changeset
217 'builds_pending' : len(list(Build.select(self.env,
87f87c756dca 0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents: 590
diff changeset
218 config=config.name,
87f87c756dca 0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents: 590
diff changeset
219 status=Build.PENDING))),
87f87c756dca 0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents: 590
diff changeset
220 'builds_inprogress' : len(list(Build.select(self.env,
87f87c756dca 0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents: 590
diff changeset
221 config=config.name,
87f87c756dca 0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents: 590
diff changeset
222 status=Build.IN_PROGRESS))),
376
05c684ceb8c6 Use `req.href` instead of `env.href` as that works much better in Trac>=0.10. That also means Trac 0.9 is no longer supported.
cmlenz
parents: 362
diff changeset
223 'href': req.href.build(config.name),
504
e2eef154f1af Add pending/inprogress build counts to web ui.
wbell
parents: 503
diff changeset
224 'builds': [],
e2eef154f1af Add pending/inprogress build counts to web ui.
wbell
parents: 503
diff changeset
225 'platforms': platforms_data
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
226 }
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
227 configs.append(config_data)
255
42f555e1d648 Show the build status for the latest changeset for every build configuration on the main build status page. Closes #21.
cmlenz
parents: 250
diff changeset
228 if not config.active:
42f555e1d648 Show the build status for the latest changeset for every build configuration on the main build status page. Closes #21.
cmlenz
parents: 250
diff changeset
229 continue
42f555e1d648 Show the build status for the latest changeset for every build configuration on the main build status page. Closes #21.
cmlenz
parents: 250
diff changeset
230
42f555e1d648 Show the build status for the latest changeset for every build configuration on the main build status page. Closes #21.
cmlenz
parents: 250
diff changeset
231 prev_rev = None
42f555e1d648 Show the build status for the latest changeset for every build configuration on the main build status page. Closes #21.
cmlenz
parents: 250
diff changeset
232 for platform, rev, build in collect_changes(repos, config):
42f555e1d648 Show the build status for the latest changeset for every build configuration on the main build status page. Closes #21.
cmlenz
parents: 250
diff changeset
233 if rev != prev_rev:
42f555e1d648 Show the build status for the latest changeset for every build configuration on the main build status page. Closes #21.
cmlenz
parents: 250
diff changeset
234 if prev_rev is None:
42f555e1d648 Show the build status for the latest changeset for every build configuration on the main build status page. Closes #21.
cmlenz
parents: 250
diff changeset
235 chgset = repos.get_changeset(rev)
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
236 config_data['youngest_rev'] = {
376
05c684ceb8c6 Use `req.href` instead of `env.href` as that works much better in Trac>=0.10. That also means Trac 0.9 is no longer supported.
cmlenz
parents: 362
diff changeset
237 'id': rev, 'href': req.href.changeset(rev),
320
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
238 'author': chgset.author or 'anonymous',
255
42f555e1d648 Show the build status for the latest changeset for every build configuration on the main build status page. Closes #21.
cmlenz
parents: 250
diff changeset
239 'date': format_datetime(chgset.date),
42f555e1d648 Show the build status for the latest changeset for every build configuration on the main build status page. Closes #21.
cmlenz
parents: 250
diff changeset
240 'message': wiki_to_oneliner(
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
241 shorten_line(chgset.message), self.env, req=req)
255
42f555e1d648 Show the build status for the latest changeset for every build configuration on the main build status page. Closes #21.
cmlenz
parents: 250
diff changeset
242 }
42f555e1d648 Show the build status for the latest changeset for every build configuration on the main build status page. Closes #21.
cmlenz
parents: 250
diff changeset
243 else:
42f555e1d648 Show the build status for the latest changeset for every build configuration on the main build status page. Closes #21.
cmlenz
parents: 250
diff changeset
244 break
42f555e1d648 Show the build status for the latest changeset for every build configuration on the main build status page. Closes #21.
cmlenz
parents: 250
diff changeset
245 prev_rev = rev
42f555e1d648 Show the build status for the latest changeset for every build configuration on the main build status page. Closes #21.
cmlenz
parents: 250
diff changeset
246 if build:
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
247 build_data = _get_build_data(self.env, req, build)
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
248 build_data['platform'] = platform.name
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
249 config_data['builds'].append(build_data)
256
aa942e2c7243 A bit of polishing for [265]: also show build if not yet in the queue, some layout improvements.
cmlenz
parents: 255
diff changeset
250 else:
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
251 config_data['builds'].append({
320
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
252 'platform': platform.name, 'status': 'pending'
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
253 })
255
42f555e1d648 Show the build status for the latest changeset for every build configuration on the main build status page. Closes #21.
cmlenz
parents: 250
diff changeset
254
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
255 data['configs'] = configs
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
256 data['page_mode'] = 'overview'
504
e2eef154f1af Add pending/inprogress build counts to web ui.
wbell
parents: 503
diff changeset
257
e2eef154f1af Add pending/inprogress build counts to web ui.
wbell
parents: 503
diff changeset
258 in_progress_builds = Build.select(self.env, status=Build.IN_PROGRESS)
e2eef154f1af Add pending/inprogress build counts to web ui.
wbell
parents: 503
diff changeset
259 pending_builds = Build.select(self.env, status=Build.PENDING)
e2eef154f1af Add pending/inprogress build counts to web ui.
wbell
parents: 503
diff changeset
260
591
87f87c756dca 0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents: 590
diff changeset
261 data['builds_pending'] = len(list(pending_builds))
87f87c756dca 0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents: 590
diff changeset
262 data['builds_inprogress'] = len(list(in_progress_builds))
504
e2eef154f1af Add pending/inprogress build counts to web ui.
wbell
parents: 503
diff changeset
263
436
cfbc9ee622d5 Finish the move of build configuration management into the admin interface.
cmlenz
parents: 423
diff changeset
264 add_link(req, 'views', req.href.build(view='inprogress'),
cfbc9ee622d5 Finish the move of build configuration management into the admin interface.
cmlenz
parents: 423
diff changeset
265 'In Progress Builds')
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
266 add_ctxtnav(req, 'In Progress Builds',
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
267 req.href.build(view='inprogress'))
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
268 return data
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
269
381
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
270 def _render_inprogress(self, req):
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
271 data = {'title': 'In Progress Builds',
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
272 'page_mode': 'view-inprogress'}
381
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
273
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
274 db = self.env.get_db_cnx()
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
275
562
a8c84285e67a Complete rights restrictions for build configs etc - see #384. Also enhance tests to work with this code (but don't yet check that rights are restricted properly)
dfraser
parents: 561
diff changeset
276 repos = self.env.get_repository(req.authname)
a8c84285e67a Complete rights restrictions for build configs etc - see #384. Also enhance tests to work with this code (but don't yet check that rights are restricted properly)
dfraser
parents: 561
diff changeset
277 if hasattr(repos, 'sync'):
a8c84285e67a Complete rights restrictions for build configs etc - see #384. Also enhance tests to work with this code (but don't yet check that rights are restricted properly)
dfraser
parents: 561
diff changeset
278 repos.sync()
a8c84285e67a Complete rights restrictions for build configs etc - see #384. Also enhance tests to work with this code (but don't yet check that rights are restricted properly)
dfraser
parents: 561
diff changeset
279
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
280 configs = []
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
281 for config in BuildConfig.select(self.env, include_inactive=False):
562
a8c84285e67a Complete rights restrictions for build configs etc - see #384. Also enhance tests to work with this code (but don't yet check that rights are restricted properly)
dfraser
parents: 561
diff changeset
282 if not repos.authz.has_permission(config.path):
a8c84285e67a Complete rights restrictions for build configs etc - see #384. Also enhance tests to work with this code (but don't yet check that rights are restricted properly)
dfraser
parents: 561
diff changeset
283 continue
a8c84285e67a Complete rights restrictions for build configs etc - see #384. Also enhance tests to work with this code (but don't yet check that rights are restricted properly)
dfraser
parents: 561
diff changeset
284
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
285 self.log.debug(config.name)
381
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
286 if not config.active:
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
287 continue
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
288
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
289 in_progress_builds = Build.select(self.env, config=config.name,
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
290 status=Build.IN_PROGRESS, db=db)
437
6d5ac24061dc Fix build queue population compatiblity with Trac 0.11, where revision timestamps are `datetime` objects.
cmlenz
parents: 436
diff changeset
291
381
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
292 current_builds = 0
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
293 builds = []
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
294 # sort correctly by revision.
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
295 for build in sorted(in_progress_builds,
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
296 cmp=lambda x, y: int(y.rev) - int(x.rev)):
381
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
297 rev = build.rev
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
298 build_data = _get_build_data(self.env, req, build)
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
299 build_data['rev'] = rev
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
300 build_data['rev_href'] = req.href.changeset(rev)
381
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
301 platform = TargetPlatform.fetch(self.env, build.platform)
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
302 build_data['platform'] = platform.name
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
303 build_data['steps'] = []
437
6d5ac24061dc Fix build queue population compatiblity with Trac 0.11, where revision timestamps are `datetime` objects.
cmlenz
parents: 436
diff changeset
304
381
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
305 for step in BuildStep.select(self.env, build=build.id, db=db):
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
306 build_data['steps'].append({
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
307 'name': step.name,
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
308 'description': step.description,
585
87de4513bfdd 0.6dev: Cleaning remaining 'frontend' datetime code - at least down to all code that interface with the various `model` classes that still only works with timestamps for input and output. See #85.
osimons
parents: 583
diff changeset
309 'duration': to_datetime(step.stopped, utc) - \
87de4513bfdd 0.6dev: Cleaning remaining 'frontend' datetime code - at least down to all code that interface with the various `model` classes that still only works with timestamps for input and output. See #85.
osimons
parents: 583
diff changeset
310 to_datetime(step.started, utc),
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
311 'failed': not step.successful,
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
312 'errors': step.errors,
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
313 'href': build_data['href'] + '#step_' + step.name
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
314 })
381
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
315
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
316 builds.append(build_data)
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
317 current_builds += 1
381
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
318
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
319 if current_builds == 0:
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
320 continue
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
321
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
322 description = config.description
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
323 if description:
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
324 description = wiki_to_html(description, self.env, req)
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
325 configs.append({
381
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
326 'name': config.name, 'label': config.label or config.name,
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
327 'active': config.active, 'path': config.path,
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
328 'description': description,
460
32b61f031df0 Fix a couple of left-over instances of using `env.href` instead of `req.href`. Closes #186. Thanks to Markus Heberling for reporting the issue and providing a patch.
cmlenz
parents: 440
diff changeset
329 'href': req.href.build(config.name),
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
330 'builds': builds
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
331 })
381
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
332
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
333 data['configs'] = configs
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
334 return data
381
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
335
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
336 def _render_config(self, req, config_name):
250
0271a2b1fc23 Improvements to the web interface:
cmlenz
parents: 247
diff changeset
337 db = self.env.get_db_cnx()
0271a2b1fc23 Improvements to the web interface:
cmlenz
parents: 247
diff changeset
338
0271a2b1fc23 Improvements to the web interface:
cmlenz
parents: 247
diff changeset
339 config = BuildConfig.fetch(self.env, config_name, db=db)
571
bed75f6c3e57 0.6dev: Raise regular `HTTPNotFound` (404) if build or configuration is not found (instead of raising ?ttributeError` error with traceback).
osimons
parents: 562
diff changeset
340 if not config:
bed75f6c3e57 0.6dev: Raise regular `HTTPNotFound` (404) if build or configuration is not found (instead of raising ?ttributeError` error with traceback).
osimons
parents: 562
diff changeset
341 raise HTTPNotFound("Build configuration '%s' does not exist." \
bed75f6c3e57 0.6dev: Raise regular `HTTPNotFound` (404) if build or configuration is not found (instead of raising ?ttributeError` error with traceback).
osimons
parents: 562
diff changeset
342 % config_name)
562
a8c84285e67a Complete rights restrictions for build configs etc - see #384. Also enhance tests to work with this code (but don't yet check that rights are restricted properly)
dfraser
parents: 561
diff changeset
343
a8c84285e67a Complete rights restrictions for build configs etc - see #384. Also enhance tests to work with this code (but don't yet check that rights are restricted properly)
dfraser
parents: 561
diff changeset
344 repos = self.env.get_repository(req.authname)
a8c84285e67a Complete rights restrictions for build configs etc - see #384. Also enhance tests to work with this code (but don't yet check that rights are restricted properly)
dfraser
parents: 561
diff changeset
345 if hasattr(repos, 'sync'):
a8c84285e67a Complete rights restrictions for build configs etc - see #384. Also enhance tests to work with this code (but don't yet check that rights are restricted properly)
dfraser
parents: 561
diff changeset
346 repos.sync()
a8c84285e67a Complete rights restrictions for build configs etc - see #384. Also enhance tests to work with this code (but don't yet check that rights are restricted properly)
dfraser
parents: 561
diff changeset
347 repos.authz.assert_permission(config.path)
a8c84285e67a Complete rights restrictions for build configs etc - see #384. Also enhance tests to work with this code (but don't yet check that rights are restricted properly)
dfraser
parents: 561
diff changeset
348
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
349 data = {'title': 'Build Configuration "%s"' \
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
350 % config.label or config.name,
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
351 'page_mode': 'view_config'}
376
05c684ceb8c6 Use `req.href` instead of `env.href` as that works much better in Trac>=0.10. That also means Trac 0.9 is no longer supported.
cmlenz
parents: 362
diff changeset
352 add_link(req, 'up', req.href.build(), 'Build Status')
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
353 description = config.description
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
354 if description:
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
355 description = wiki_to_html(description, self.env, req)
504
e2eef154f1af Add pending/inprogress build counts to web ui.
wbell
parents: 503
diff changeset
356
591
87f87c756dca 0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents: 590
diff changeset
357 pending_builds = list(Build.select(self.env,
87f87c756dca 0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents: 590
diff changeset
358 config=config.name, status=Build.PENDING))
87f87c756dca 0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents: 590
diff changeset
359 inprogress_builds = list(Build.select(self.env,
87f87c756dca 0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents: 590
diff changeset
360 config=config.name, status=Build.IN_PROGRESS))
504
e2eef154f1af Add pending/inprogress build counts to web ui.
wbell
parents: 503
diff changeset
361
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
362 data['config'] = {
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
363 'name': config.name, 'label': config.label, 'path': config.path,
250
0271a2b1fc23 Improvements to the web interface:
cmlenz
parents: 247
diff changeset
364 'min_rev': config.min_rev,
376
05c684ceb8c6 Use `req.href` instead of `env.href` as that works much better in Trac>=0.10. That also means Trac 0.9 is no longer supported.
cmlenz
parents: 362
diff changeset
365 'min_rev_href': req.href.changeset(config.min_rev),
250
0271a2b1fc23 Improvements to the web interface:
cmlenz
parents: 247
diff changeset
366 'max_rev': config.max_rev,
376
05c684ceb8c6 Use `req.href` instead of `env.href` as that works much better in Trac>=0.10. That also means Trac 0.9 is no longer supported.
cmlenz
parents: 362
diff changeset
367 'max_rev_href': req.href.changeset(config.max_rev),
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
368 'active': config.active, 'description': description,
504
e2eef154f1af Add pending/inprogress build counts to web ui.
wbell
parents: 503
diff changeset
369 'browser_href': req.href.browser(config.path),
e2eef154f1af Add pending/inprogress build counts to web ui.
wbell
parents: 503
diff changeset
370 'builds_pending' : len(pending_builds),
637
988f2b3e585c 0.6dev: Fixing layout of builds (config overview) when using long revision markers (as for instance used by Git). Also makes the table generally wider and the page more efficient visually.
osimons
parents: 636
diff changeset
371 'builds_inprogress' : len(inprogress_builds),
988f2b3e585c 0.6dev: Fixing layout of builds (config overview) when using long revision markers (as for instance used by Git). Also makes the table generally wider and the page more efficient visually.
osimons
parents: 636
diff changeset
372 'revsize' : None,
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
373 }
47
083e848088ee * Improvements to the model classes, and a couple of unit tests.
cmlenz
parents: 45
diff changeset
374
629
f3bb52da9e3c 0.6dev: Adding support for attachments to configurations and build - full web implementation that mirrors what is available in Ticket and Wiki. Also added a new generic `<attach/>` command that enables attaching files to be part of a recipe and uploaded by slaves as part of build.
osimons
parents: 605
diff changeset
375 context = Context.from_request(req, config.resource)
f3bb52da9e3c 0.6dev: Adding support for attachments to configurations and build - full web implementation that mirrors what is available in Ticket and Wiki. Also added a new generic `<attach/>` command that enables attaching files to be part of a recipe and uploaded by slaves as part of build.
osimons
parents: 605
diff changeset
376 data['context'] = context
f3bb52da9e3c 0.6dev: Adding support for attachments to configurations and build - full web implementation that mirrors what is available in Ticket and Wiki. Also added a new generic `<attach/>` command that enables attaching files to be part of a recipe and uploaded by slaves as part of build.
osimons
parents: 605
diff changeset
377 data['config']['attachments'] = AttachmentModule(self.env).attachment_data(context)
f3bb52da9e3c 0.6dev: Adding support for attachments to configurations and build - full web implementation that mirrors what is available in Ticket and Wiki. Also added a new generic `<attach/>` command that enables attaching files to be part of a recipe and uploaded by slaves as part of build.
osimons
parents: 605
diff changeset
378
250
0271a2b1fc23 Improvements to the web interface:
cmlenz
parents: 247
diff changeset
379 platforms = list(TargetPlatform.select(self.env, config=config_name,
0271a2b1fc23 Improvements to the web interface:
cmlenz
parents: 247
diff changeset
380 db=db))
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
381 data['config']['platforms'] = [
504
e2eef154f1af Add pending/inprogress build counts to web ui.
wbell
parents: 503
diff changeset
382 { 'name': platform.name,
e2eef154f1af Add pending/inprogress build counts to web ui.
wbell
parents: 503
diff changeset
383 'id': platform.id,
591
87f87c756dca 0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents: 590
diff changeset
384 'builds_pending': len(list(Build.select(self.env,
87f87c756dca 0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents: 590
diff changeset
385 config=config.name,
87f87c756dca 0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents: 590
diff changeset
386 status=Build.PENDING,
87f87c756dca 0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents: 590
diff changeset
387 platform=platform.id))),
87f87c756dca 0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents: 590
diff changeset
388 'builds_inprogress': len(list(Build.select(self.env,
87f87c756dca 0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents: 590
diff changeset
389 config=config.name,
87f87c756dca 0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents: 590
diff changeset
390 status=Build.IN_PROGRESS,
87f87c756dca 0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents: 590
diff changeset
391 platform=platform.id)))
504
e2eef154f1af Add pending/inprogress build counts to web ui.
wbell
parents: 503
diff changeset
392 }
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
393 for platform in platforms
76
ffa1ffd8c7db * Implement basic slave selection based on configured target platforms. Closes #15.
cmlenz
parents: 74
diff changeset
394 ]
74
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
395
197
d72c0587fae9 * Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents: 196
diff changeset
396 has_reports = False
250
0271a2b1fc23 Improvements to the web interface:
cmlenz
parents: 247
diff changeset
397 for report in Report.select(self.env, config=config.name, db=db):
197
d72c0587fae9 * Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents: 196
diff changeset
398 has_reports = True
d72c0587fae9 * Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents: 196
diff changeset
399 break
d72c0587fae9 * Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents: 196
diff changeset
400
d72c0587fae9 * Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents: 196
diff changeset
401 if has_reports:
388
3ba9430a5d87 Fix for hardcoded chart generators in UI. Closes #153.
cmlenz
parents: 382
diff changeset
402 chart_generators = []
391
7801dddec1a1 Sign, another follow-up to [438]. One of these days I should get it right :-(
cmlenz
parents: 390
diff changeset
403 for generator in ReportChartController(self.env).generators:
388
3ba9430a5d87 Fix for hardcoded chart generators in UI. Closes #153.
cmlenz
parents: 382
diff changeset
404 for category in generator.get_supported_categories():
3ba9430a5d87 Fix for hardcoded chart generators in UI. Closes #153.
cmlenz
parents: 382
diff changeset
405 chart_generators.append({
3ba9430a5d87 Fix for hardcoded chart generators in UI. Closes #153.
cmlenz
parents: 382
diff changeset
406 'href': req.href.build(config.name, 'chart/' + category)
3ba9430a5d87 Fix for hardcoded chart generators in UI. Closes #153.
cmlenz
parents: 382
diff changeset
407 })
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
408 data['config']['charts'] = chart_generators
197
d72c0587fae9 * Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents: 196
diff changeset
409 charts_license = self.config.get('bitten', 'charts_license')
d72c0587fae9 * Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents: 196
diff changeset
410 if charts_license:
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
411 data['config']['charts_license'] = charts_license
178
fcbe107ca755 Add some basic charts to the build status page, based on [http://www.maani.us/xml_charts/index.php XML/SWF Charts]:
cmlenz
parents: 174
diff changeset
412
214
f0e37bee64c5 Paging on build configuration page. Closes #24.
cmlenz
parents: 213
diff changeset
413 page = max(1, int(req.args.get('page', 1)))
f0e37bee64c5 Paging on build configuration page. Closes #24.
cmlenz
parents: 213
diff changeset
414 more = False
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
415 data['page_number'] = page
214
f0e37bee64c5 Paging on build configuration page. Closes #24.
cmlenz
parents: 213
diff changeset
416
360
5bc81e597352 Fix incompatibility with a change to the versioncontrol layer in Trac 0.10.3
cmlenz
parents: 328
diff changeset
417 repos = self.env.get_repository(req.authname)
5bc81e597352 Fix incompatibility with a change to the versioncontrol layer in Trac 0.10.3
cmlenz
parents: 328
diff changeset
418 if hasattr(repos, 'sync'):
5bc81e597352 Fix incompatibility with a change to the versioncontrol layer in Trac 0.10.3
cmlenz
parents: 328
diff changeset
419 repos.sync()
5bc81e597352 Fix incompatibility with a change to the versioncontrol layer in Trac 0.10.3
cmlenz
parents: 328
diff changeset
420
228
a8c9dd7e3f71 * Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents: 219
diff changeset
421 builds_per_page = 12 * len(platforms)
a8c9dd7e3f71 * Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents: 219
diff changeset
422 idx = 0
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
423 builds = {}
228
a8c9dd7e3f71 * Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents: 219
diff changeset
424 for platform, rev, build in collect_changes(repos, config):
a8c9dd7e3f71 * Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents: 219
diff changeset
425 if idx >= page * builds_per_page:
a8c9dd7e3f71 * Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents: 219
diff changeset
426 more = True
a8c9dd7e3f71 * Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents: 219
diff changeset
427 break
232
b6e4896dc026 Fix regression introduced in [239]: first build was being skipped on build configuration page.
cmlenz
parents: 230
diff changeset
428 elif idx >= (page - 1) * builds_per_page:
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
429 builds.setdefault(rev, {})
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
430 builds[rev].setdefault('href', req.href.changeset(rev))
637
988f2b3e585c 0.6dev: Fixing layout of builds (config overview) when using long revision markers (as for instance used by Git). Also makes the table generally wider and the page more efficient visually.
osimons
parents: 636
diff changeset
431 data['config']['revsize'] = len(str(rev)) > 10 \
988f2b3e585c 0.6dev: Fixing layout of builds (config overview) when using long revision markers (as for instance used by Git). Also makes the table generally wider and the page more efficient visually.
osimons
parents: 636
diff changeset
432 and 'longrevchgset' or 'shortrevchgset'
230
c7ff953ebb07 Fix paging on build configuration page. Closes #55.
cmlenz
parents: 228
diff changeset
433 if build and build.status != Build.PENDING:
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
434 build_data = _get_build_data(self.env, req, build)
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
435 build_data['steps'] = []
250
0271a2b1fc23 Improvements to the web interface:
cmlenz
parents: 247
diff changeset
436 for step in BuildStep.select(self.env, build=build.id,
0271a2b1fc23 Improvements to the web interface:
cmlenz
parents: 247
diff changeset
437 db=db):
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
438 build_data['steps'].append({
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
439 'name': step.name,
320
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
440 'description': step.description,
585
87de4513bfdd 0.6dev: Cleaning remaining 'frontend' datetime code - at least down to all code that interface with the various `model` classes that still only works with timestamps for input and output. See #85.
osimons
parents: 583
diff changeset
441 'duration': to_datetime(step.stopped, utc) - \
87de4513bfdd 0.6dev: Cleaning remaining 'frontend' datetime code - at least down to all code that interface with the various `model` classes that still only works with timestamps for input and output. See #85.
osimons
parents: 583
diff changeset
442 to_datetime(step.started, utc),
250
0271a2b1fc23 Improvements to the web interface:
cmlenz
parents: 247
diff changeset
443 'failed': not step.successful,
0271a2b1fc23 Improvements to the web interface:
cmlenz
parents: 247
diff changeset
444 'errors': step.errors,
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
445 'href': build_data['href'] + '#step_' + step.name
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
446 })
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
447 builds[rev][platform.id] = build_data
230
c7ff953ebb07 Fix paging on build configuration page. Closes #55.
cmlenz
parents: 228
diff changeset
448 idx += 1
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
449 data['config']['builds'] = builds
214
f0e37bee64c5 Paging on build configuration page. Closes #24.
cmlenz
parents: 213
diff changeset
450
228
a8c9dd7e3f71 * Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents: 219
diff changeset
451 if page > 1:
a8c9dd7e3f71 * Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents: 219
diff changeset
452 if page == 2:
376
05c684ceb8c6 Use `req.href` instead of `env.href` as that works much better in Trac>=0.10. That also means Trac 0.9 is no longer supported.
cmlenz
parents: 362
diff changeset
453 prev_href = req.href.build(config.name)
228
a8c9dd7e3f71 * Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents: 219
diff changeset
454 else:
376
05c684ceb8c6 Use `req.href` instead of `env.href` as that works much better in Trac>=0.10. That also means Trac 0.9 is no longer supported.
cmlenz
parents: 362
diff changeset
455 prev_href = req.href.build(config.name, page=page - 1)
228
a8c9dd7e3f71 * Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents: 219
diff changeset
456 add_link(req, 'prev', prev_href, 'Previous Page')
a8c9dd7e3f71 * Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents: 219
diff changeset
457 if more:
376
05c684ceb8c6 Use `req.href` instead of `env.href` as that works much better in Trac>=0.10. That also means Trac 0.9 is no longer supported.
cmlenz
parents: 362
diff changeset
458 next_href = req.href.build(config.name, page=page + 1)
228
a8c9dd7e3f71 * Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents: 219
diff changeset
459 add_link(req, 'next', next_href, 'Next Page')
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
460 prevnext_nav(req, 'Page')
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
461 return data
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
462
141
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
463
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
464 class BuildController(Component):
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
465 """Renders the build page."""
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
466 implements(INavigationContributor, IRequestHandler, ITimelineEventProvider)
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
467
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
468 log_formatters = ExtensionPoint(ILogFormatter)
161
4677161d2ae9 Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents: 147
diff changeset
469 report_summarizers = ExtensionPoint(IReportSummarizer)
141
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
470
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
471 # INavigationContributor methods
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
472
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
473 def get_active_navigation_item(self, req):
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
474 return 'build'
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
475
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
476 def get_navigation_items(self, req):
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
477 return []
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
478
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
479 # IRequestHandler methods
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
480
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
481 def match_request(self, req):
174
79c61c26a4e1 * Changed the `IReportStore` interface to allow querying with [http://www.w3.org/XML/Query/ XQuery]. This should make it possible to efficiently query the report store for any existing metrics.
cmlenz
parents: 168
diff changeset
482 match = re.match(r'/build/([\w.-]+)/(\d+)', req.path_info)
141
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
483 if match:
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
484 if match.group(1):
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
485 req.args['config'] = match.group(1)
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
486 if match.group(2):
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
487 req.args['id'] = match.group(2)
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
488 return True
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
489
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
490 def process_request(self, req):
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
491 req.perm.require('BUILD_VIEW')
141
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
492
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
493 db = self.env.get_db_cnx()
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
494 build_id = int(req.args.get('id'))
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
495 build = Build.fetch(self.env, build_id, db=db)
571
bed75f6c3e57 0.6dev: Raise regular `HTTPNotFound` (404) if build or configuration is not found (instead of raising ?ttributeError` error with traceback).
osimons
parents: 562
diff changeset
496 if not build:
bed75f6c3e57 0.6dev: Raise regular `HTTPNotFound` (404) if build or configuration is not found (instead of raising ?ttributeError` error with traceback).
osimons
parents: 562
diff changeset
497 raise HTTPNotFound("Build '%s' does not exist." \
bed75f6c3e57 0.6dev: Raise regular `HTTPNotFound` (404) if build or configuration is not found (instead of raising ?ttributeError` error with traceback).
osimons
parents: 562
diff changeset
498 % build_id)
141
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
499
184
fbf949f4c706 Allow invalidation of builds from the web interface. This results in the build being reset to ''PENDING'' status, and all build logs, slave information and reports deleted. Basically initiates a rebuild for a specific revision and target platform.
cmlenz
parents: 182
diff changeset
500 if req.method == 'POST':
fbf949f4c706 Allow invalidation of builds from the web interface. This results in the build being reset to ''PENDING'' status, and all build logs, slave information and reports deleted. Basically initiates a rebuild for a specific revision and target platform.
cmlenz
parents: 182
diff changeset
501 if req.args.get('action') == 'invalidate':
fbf949f4c706 Allow invalidation of builds from the web interface. This results in the build being reset to ''PENDING'' status, and all build logs, slave information and reports deleted. Basically initiates a rebuild for a specific revision and target platform.
cmlenz
parents: 182
diff changeset
502 self._do_invalidate(req, build, db)
376
05c684ceb8c6 Use `req.href` instead of `env.href` as that works much better in Trac>=0.10. That also means Trac 0.9 is no longer supported.
cmlenz
parents: 362
diff changeset
503 req.redirect(req.href.build(build.config, build.id))
184
fbf949f4c706 Allow invalidation of builds from the web interface. This results in the build being reset to ''PENDING'' status, and all build logs, slave information and reports deleted. Basically initiates a rebuild for a specific revision and target platform.
cmlenz
parents: 182
diff changeset
504
376
05c684ceb8c6 Use `req.href` instead of `env.href` as that works much better in Trac>=0.10. That also means Trac 0.9 is no longer supported.
cmlenz
parents: 362
diff changeset
505 add_link(req, 'up', req.href.build(build.config),
73
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
506 'Build Configuration')
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
507 data = {'title': 'Build %s - %s' % (build_id,
506
be811cb659b7 * Renamed `status2title` to `_status_title` and made it a global variable alongside `_status_label`
dfraser
parents: 504
diff changeset
508 _status_title[build.status]),
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
509 'page_mode': 'view_build',
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
510 'build': {}}
141
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
511 config = BuildConfig.fetch(self.env, build.config, db=db)
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
512 data['build']['config'] = {
583
f916b88926f5 0.6dev: If configuration display label is deleted, no name would show and the build UI would fold across a couple of lines. This should see to it that the configuration always has a name available.
osimons
parents: 571
diff changeset
513 'name': config.label or config.name,
376
05c684ceb8c6 Use `req.href` instead of `env.href` as that works much better in Trac>=0.10. That also means Trac 0.9 is no longer supported.
cmlenz
parents: 362
diff changeset
514 'href': req.href.build(config.name)
69
b92d7c7d70fd Record build slave properties in database.
cmlenz
parents: 67
diff changeset
515 }
b92d7c7d70fd Record build slave properties in database.
cmlenz
parents: 67
diff changeset
516
629
f3bb52da9e3c 0.6dev: Adding support for attachments to configurations and build - full web implementation that mirrors what is available in Ticket and Wiki. Also added a new generic `<attach/>` command that enables attaching files to be part of a recipe and uploaded by slaves as part of build.
osimons
parents: 605
diff changeset
517 context = Context.from_request(req, build.resource)
f3bb52da9e3c 0.6dev: Adding support for attachments to configurations and build - full web implementation that mirrors what is available in Ticket and Wiki. Also added a new generic `<attach/>` command that enables attaching files to be part of a recipe and uploaded by slaves as part of build.
osimons
parents: 605
diff changeset
518 data['context'] = context
f3bb52da9e3c 0.6dev: Adding support for attachments to configurations and build - full web implementation that mirrors what is available in Ticket and Wiki. Also added a new generic `<attach/>` command that enables attaching files to be part of a recipe and uploaded by slaves as part of build.
osimons
parents: 605
diff changeset
519 data['build']['attachments'] = AttachmentModule(self.env).attachment_data(context)
f3bb52da9e3c 0.6dev: Adding support for attachments to configurations and build - full web implementation that mirrors what is available in Ticket and Wiki. Also added a new generic `<attach/>` command that enables attaching files to be part of a recipe and uploaded by slaves as part of build.
osimons
parents: 605
diff changeset
520
258
77cdef044d48 * Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents: 256
diff changeset
521 formatters = []
77cdef044d48 * Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents: 256
diff changeset
522 for formatter in self.log_formatters:
77cdef044d48 * Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents: 256
diff changeset
523 formatters.append(formatter.get_formatter(req, build))
77cdef044d48 * Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents: 256
diff changeset
524
77cdef044d48 * Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents: 256
diff changeset
525 summarizers = {} # keyed by report type
77cdef044d48 * Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents: 256
diff changeset
526 for summarizer in self.report_summarizers:
77cdef044d48 * Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents: 256
diff changeset
527 categories = summarizer.get_supported_categories()
423
8864b3917221 Fix for Python 2.3 incompatibility in display for report summaries. Closes #164.
cmlenz
parents: 411
diff changeset
528 summarizers.update(dict([(cat, summarizer) for cat in categories]))
258
77cdef044d48 * Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents: 256
diff changeset
529
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
530 data['build'].update(_get_build_data(self.env, req, build))
80
dc1c7fc9b915 Record the output of build steps in the database. See #12. Still need to get better granularity in transmitting the log output from slave to master before #12 can be closed.
cmlenz
parents: 79
diff changeset
531 steps = []
112
a38eabd4b6e1 * Store build logs in a structured way, for example to highlight messages on the error stream.
cmlenz
parents: 111
diff changeset
532 for step in BuildStep.select(self.env, build=build.id, db=db):
80
dc1c7fc9b915 Record the output of build steps in the database. See #12. Still need to get better granularity in transmitting the log output from slave to master before #12 can be closed.
cmlenz
parents: 79
diff changeset
533 steps.append({
dc1c7fc9b915 Record the output of build steps in the database. See #12. Still need to get better granularity in transmitting the log output from slave to master before #12 can be closed.
cmlenz
parents: 79
diff changeset
534 'name': step.name, 'description': step.description,
123
cccfa117e344 Template cleanup
cmlenz
parents: 120
diff changeset
535 'duration': pretty_timedelta(step.started, step.stopped),
161
4677161d2ae9 Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents: 147
diff changeset
536 'failed': step.status == BuildStep.FAILURE,
245
a22ec8fce6c9 Store the reason(s) for build step failure in the database.
cmlenz
parents: 232
diff changeset
537 'errors': step.errors,
258
77cdef044d48 * Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents: 256
diff changeset
538 'log': self._render_log(req, build, formatters, step),
77cdef044d48 * Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents: 256
diff changeset
539 'reports': self._render_reports(req, config, build, summarizers,
77cdef044d48 * Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents: 256
diff changeset
540 step)
80
dc1c7fc9b915 Record the output of build steps in the database. See #12. Still need to get better granularity in transmitting the log output from slave to master before #12 can be closed.
cmlenz
parents: 79
diff changeset
541 })
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
542 data['build']['steps'] = steps
592
4848d9b7a3e5 0.6dev: Removing 'Invalidate build' button when the build is 'pending' (and nothing further to really invalidate). See #332.
osimons
parents: 591
diff changeset
543 data['build']['can_delete'] = ('BUILD_DELETE' in req.perm \
4848d9b7a3e5 0.6dev: Removing 'Invalidate build' button when the build is 'pending' (and nothing further to really invalidate). See #332.
osimons
parents: 591
diff changeset
544 and build.status != build.PENDING)
120
b63ed684c29c Show the list of reports generated on the build page.
cmlenz
parents: 114
diff changeset
545
250
0271a2b1fc23 Improvements to the web interface:
cmlenz
parents: 247
diff changeset
546 repos = self.env.get_repository(req.authname)
562
a8c84285e67a Complete rights restrictions for build configs etc - see #384. Also enhance tests to work with this code (but don't yet check that rights are restricted properly)
dfraser
parents: 561
diff changeset
547 repos.authz.assert_permission(config.path)
250
0271a2b1fc23 Improvements to the web interface:
cmlenz
parents: 247
diff changeset
548 chgset = repos.get_changeset(build.rev)
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
549 data['build']['chgset_author'] = chgset.author
250
0271a2b1fc23 Improvements to the web interface:
cmlenz
parents: 247
diff changeset
550
636
21902b481ee7 0.6dev: Inline display of error and failure details in 'Test Results' summary table.
osimons
parents: 629
diff changeset
551 add_script(req, 'common/js/folding.js')
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
552 add_script(req, 'bitten/tabset.js')
164
a9cddfae3c09 Adapt to Trac [http://projects.edgewall.com/trac/changeset/2132 r2132].
cmlenz
parents: 163
diff changeset
553 add_stylesheet(req, 'bitten/bitten.css')
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
554 return 'bitten_build.html', data, None
80
dc1c7fc9b915 Record the output of build steps in the database. See #12. Still need to get better granularity in transmitting the log output from slave to master before #12 can be closed.
cmlenz
parents: 79
diff changeset
555
141
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
556 # ITimelineEventProvider methods
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
557
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
558 def get_timeline_filters(self, req):
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
559 if 'BUILD_VIEW' in req.perm:
141
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
560 yield ('build', 'Builds')
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
561
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
562 def get_timeline_events(self, req, start, stop, filters):
311
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
563 if 'build' not in filters:
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
564 return
250
0271a2b1fc23 Improvements to the web interface:
cmlenz
parents: 247
diff changeset
565
629
f3bb52da9e3c 0.6dev: Adding support for attachments to configurations and build - full web implementation that mirrors what is available in Ticket and Wiki. Also added a new generic `<attach/>` command that enables attaching files to be part of a recipe and uploaded by slaves as part of build.
osimons
parents: 605
diff changeset
566 # Attachments (will be rendered by attachment module)
f3bb52da9e3c 0.6dev: Adding support for attachments to configurations and build - full web implementation that mirrors what is available in Ticket and Wiki. Also added a new generic `<attach/>` command that enables attaching files to be part of a recipe and uploaded by slaves as part of build.
osimons
parents: 605
diff changeset
567 for event in AttachmentModule(self.env).get_timeline_events(
f3bb52da9e3c 0.6dev: Adding support for attachments to configurations and build - full web implementation that mirrors what is available in Ticket and Wiki. Also added a new generic `<attach/>` command that enables attaching files to be part of a recipe and uploaded by slaves as part of build.
osimons
parents: 605
diff changeset
568 req, Resource('build'), start, stop):
f3bb52da9e3c 0.6dev: Adding support for attachments to configurations and build - full web implementation that mirrors what is available in Ticket and Wiki. Also added a new generic `<attach/>` command that enables attaching files to be part of a recipe and uploaded by slaves as part of build.
osimons
parents: 605
diff changeset
569 yield event
f3bb52da9e3c 0.6dev: Adding support for attachments to configurations and build - full web implementation that mirrors what is available in Ticket and Wiki. Also added a new generic `<attach/>` command that enables attaching files to be part of a recipe and uploaded by slaves as part of build.
osimons
parents: 605
diff changeset
570
585
87de4513bfdd 0.6dev: Cleaning remaining 'frontend' datetime code - at least down to all code that interface with the various `model` classes that still only works with timestamps for input and output. See #85.
osimons
parents: 583
diff changeset
571 start = to_timestamp(start)
87de4513bfdd 0.6dev: Cleaning remaining 'frontend' datetime code - at least down to all code that interface with the various `model` classes that still only works with timestamps for input and output. See #85.
osimons
parents: 583
diff changeset
572 stop = to_timestamp(stop)
382
2078b20186cf Trac 0.11 compatibility fix in timeline event provider.
cmlenz
parents: 381
diff changeset
573
311
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
574 add_stylesheet(req, 'bitten/bitten.css')
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
575
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
576 db = self.env.get_db_cnx()
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
577 cursor = db.cursor()
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
578 cursor.execute("SELECT b.id,b.config,c.label,b.rev,p.name,"
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
579 "b.stopped,b.status FROM bitten_build AS b"
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
580 " INNER JOIN bitten_config AS c ON (c.name=b.config) "
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
581 " INNER JOIN bitten_platform AS p ON (p.id=b.platform) "
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
582 "WHERE b.stopped>=%s AND b.stopped<=%s "
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
583 "AND b.status IN (%s, %s) ORDER BY b.stopped",
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
584 (start, stop, Build.SUCCESS, Build.FAILURE))
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
585
562
a8c84285e67a Complete rights restrictions for build configs etc - see #384. Also enhance tests to work with this code (but don't yet check that rights are restricted properly)
dfraser
parents: 561
diff changeset
586 repos = self.env.get_repository(req.authname)
a8c84285e67a Complete rights restrictions for build configs etc - see #384. Also enhance tests to work with this code (but don't yet check that rights are restricted properly)
dfraser
parents: 561
diff changeset
587 if hasattr(repos, 'sync'):
a8c84285e67a Complete rights restrictions for build configs etc - see #384. Also enhance tests to work with this code (but don't yet check that rights are restricted properly)
dfraser
parents: 561
diff changeset
588 repos.sync()
a8c84285e67a Complete rights restrictions for build configs etc - see #384. Also enhance tests to work with this code (but don't yet check that rights are restricted properly)
dfraser
parents: 561
diff changeset
589
311
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
590 event_kinds = {Build.SUCCESS: 'successbuild',
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
591 Build.FAILURE: 'failedbuild'}
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
592 for id, config, label, rev, platform, stopped, status in cursor:
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
593
562
a8c84285e67a Complete rights restrictions for build configs etc - see #384. Also enhance tests to work with this code (but don't yet check that rights are restricted properly)
dfraser
parents: 561
diff changeset
594 config_object = BuildConfig.fetch(self.env, config, db=db)
a8c84285e67a Complete rights restrictions for build configs etc - see #384. Also enhance tests to work with this code (but don't yet check that rights are restricted properly)
dfraser
parents: 561
diff changeset
595 if not repos.authz.has_permission(config_object.path):
a8c84285e67a Complete rights restrictions for build configs etc - see #384. Also enhance tests to work with this code (but don't yet check that rights are restricted properly)
dfraser
parents: 561
diff changeset
596 continue
a8c84285e67a Complete rights restrictions for build configs etc - see #384. Also enhance tests to work with this code (but don't yet check that rights are restricted properly)
dfraser
parents: 561
diff changeset
597
311
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
598 errors = []
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
599 if status == Build.FAILURE:
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
600 for step in BuildStep.select(self.env, build=id,
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
601 status=BuildStep.FAILURE,
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
602 db=db):
320
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
603 errors += [(step.name, error) for error
311
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
604 in step.errors]
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
605
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
606 title = tag('Build of ', tag.em('%s [%s]' % (label, rev)),
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
607 ' on %s %s' % (platform, _status_label[status]))
311
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
608 message = ''
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
609 if req.args.get('format') == 'rss':
460
32b61f031df0 Fix a couple of left-over instances of using `env.href` instead of `req.href`. Closes #186. Thanks to Markus Heberling for reporting the issue and providing a patch.
cmlenz
parents: 440
diff changeset
610 href = req.abs_href.build(config, id)
311
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
611 if errors:
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
612 buf = StringIO()
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
613 prev_step = None
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
614 for step, error in errors:
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
615 if step != prev_step:
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
616 if prev_step is not None:
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
617 buf.write('</ul>')
321
8e8d40d50001 Removed too much of the escaping in [333].
cmlenz
parents: 320
diff changeset
618 buf.write('<p>Step %s failed:</p><ul>' \
8e8d40d50001 Removed too much of the escaping in [333].
cmlenz
parents: 320
diff changeset
619 % escape(step))
311
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
620 prev_step = step
321
8e8d40d50001 Removed too much of the escaping in [333].
cmlenz
parents: 320
diff changeset
621 buf.write('<li>%s</li>' % escape(error))
311
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
622 buf.write('</ul>')
320
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
623 message = Markup(buf.getvalue())
311
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
624 else:
376
05c684ceb8c6 Use `req.href` instead of `env.href` as that works much better in Trac>=0.10. That also means Trac 0.9 is no longer supported.
cmlenz
parents: 362
diff changeset
625 href = req.href.build(config, id)
311
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
626 if errors:
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
627 steps = []
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
628 for step, error in errors:
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
629 if step not in steps:
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
630 steps.append(step)
488
9b3d97297201 Fix compatibility problem with Genshi trunk.
cmlenz
parents: 485
diff changeset
631 steps = [Markup('<em>%s</em>') % step for step in steps]
311
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
632 if len(steps) < 2:
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
633 message = steps[0]
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
634 elif len(steps) == 2:
320
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
635 message = Markup(' and ').join(steps)
311
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
636 elif len(steps) > 2:
320
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
637 message = Markup(', ').join(steps[:-1]) + ', and ' + \
311
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
638 steps[-1]
488
9b3d97297201 Fix compatibility problem with Genshi trunk.
cmlenz
parents: 485
diff changeset
639 message = Markup('Step%s %s failed') % (
9b3d97297201 Fix compatibility problem with Genshi trunk.
cmlenz
parents: 485
diff changeset
640 len(steps) != 1 and 's' or '', message
9b3d97297201 Fix compatibility problem with Genshi trunk.
cmlenz
parents: 485
diff changeset
641 )
311
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
642 yield event_kinds[status], href, title, stopped, None, message
114
ecc062d4fd55 Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents: 112
diff changeset
643
161
4677161d2ae9 Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents: 147
diff changeset
644 # Internal methods
4677161d2ae9 Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents: 147
diff changeset
645
184
fbf949f4c706 Allow invalidation of builds from the web interface. This results in the build being reset to ''PENDING'' status, and all build logs, slave information and reports deleted. Basically initiates a rebuild for a specific revision and target platform.
cmlenz
parents: 182
diff changeset
646 def _do_invalidate(self, req, build, db):
fbf949f4c706 Allow invalidation of builds from the web interface. This results in the build being reset to ''PENDING'' status, and all build logs, slave information and reports deleted. Basically initiates a rebuild for a specific revision and target platform.
cmlenz
parents: 182
diff changeset
647 self.log.info('Invalidating build %d', build.id)
fbf949f4c706 Allow invalidation of builds from the web interface. This results in the build being reset to ''PENDING'' status, and all build logs, slave information and reports deleted. Basically initiates a rebuild for a specific revision and target platform.
cmlenz
parents: 182
diff changeset
648
fbf949f4c706 Allow invalidation of builds from the web interface. This results in the build being reset to ''PENDING'' status, and all build logs, slave information and reports deleted. Basically initiates a rebuild for a specific revision and target platform.
cmlenz
parents: 182
diff changeset
649 for step in BuildStep.select(self.env, build=build.id, db=db):
fbf949f4c706 Allow invalidation of builds from the web interface. This results in the build being reset to ''PENDING'' status, and all build logs, slave information and reports deleted. Basically initiates a rebuild for a specific revision and target platform.
cmlenz
parents: 182
diff changeset
650 step.delete(db=db)
fbf949f4c706 Allow invalidation of builds from the web interface. This results in the build being reset to ''PENDING'' status, and all build logs, slave information and reports deleted. Basically initiates a rebuild for a specific revision and target platform.
cmlenz
parents: 182
diff changeset
651
fbf949f4c706 Allow invalidation of builds from the web interface. This results in the build being reset to ''PENDING'' status, and all build logs, slave information and reports deleted. Basically initiates a rebuild for a specific revision and target platform.
cmlenz
parents: 182
diff changeset
652 build.slave = None
fbf949f4c706 Allow invalidation of builds from the web interface. This results in the build being reset to ''PENDING'' status, and all build logs, slave information and reports deleted. Basically initiates a rebuild for a specific revision and target platform.
cmlenz
parents: 182
diff changeset
653 build.started = build.stopped = 0
fbf949f4c706 Allow invalidation of builds from the web interface. This results in the build being reset to ''PENDING'' status, and all build logs, slave information and reports deleted. Basically initiates a rebuild for a specific revision and target platform.
cmlenz
parents: 182
diff changeset
654 build.status = Build.PENDING
fbf949f4c706 Allow invalidation of builds from the web interface. This results in the build being reset to ''PENDING'' status, and all build logs, slave information and reports deleted. Basically initiates a rebuild for a specific revision and target platform.
cmlenz
parents: 182
diff changeset
655 build.slave_info = {}
fbf949f4c706 Allow invalidation of builds from the web interface. This results in the build being reset to ''PENDING'' status, and all build logs, slave information and reports deleted. Basically initiates a rebuild for a specific revision and target platform.
cmlenz
parents: 182
diff changeset
656 build.update()
fbf949f4c706 Allow invalidation of builds from the web interface. This results in the build being reset to ''PENDING'' status, and all build logs, slave information and reports deleted. Basically initiates a rebuild for a specific revision and target platform.
cmlenz
parents: 182
diff changeset
657
fbf949f4c706 Allow invalidation of builds from the web interface. This results in the build being reset to ''PENDING'' status, and all build logs, slave information and reports deleted. Basically initiates a rebuild for a specific revision and target platform.
cmlenz
parents: 182
diff changeset
658 db.commit()
fbf949f4c706 Allow invalidation of builds from the web interface. This results in the build being reset to ''PENDING'' status, and all build logs, slave information and reports deleted. Basically initiates a rebuild for a specific revision and target platform.
cmlenz
parents: 182
diff changeset
659
376
05c684ceb8c6 Use `req.href` instead of `env.href` as that works much better in Trac>=0.10. That also means Trac 0.9 is no longer supported.
cmlenz
parents: 362
diff changeset
660 req.redirect(req.href.build(build.config))
184
fbf949f4c706 Allow invalidation of builds from the web interface. This results in the build being reset to ''PENDING'' status, and all build logs, slave information and reports deleted. Basically initiates a rebuild for a specific revision and target platform.
cmlenz
parents: 182
diff changeset
661
258
77cdef044d48 * Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents: 256
diff changeset
662 def _render_log(self, req, build, formatters, step):
161
4677161d2ae9 Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents: 147
diff changeset
663 items = []
4677161d2ae9 Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents: 147
diff changeset
664 for log in BuildLog.select(self.env, build=build.id, step=step.name):
4677161d2ae9 Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents: 147
diff changeset
665 for level, message in log.messages:
4677161d2ae9 Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents: 147
diff changeset
666 for format in formatters:
258
77cdef044d48 * Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents: 256
diff changeset
667 message = format(step, log.generator, level, message)
161
4677161d2ae9 Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents: 147
diff changeset
668 items.append({'level': level, 'message': message})
4677161d2ae9 Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents: 147
diff changeset
669 return items
4677161d2ae9 Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents: 147
diff changeset
670
258
77cdef044d48 * Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents: 256
diff changeset
671 def _render_reports(self, req, config, build, summarizers, step):
161
4677161d2ae9 Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents: 147
diff changeset
672 reports = []
203
e6ddca1e5712 Huge refactoring to remove dependency on BDB XML. Report data is now stored in the Trac database (SQLite/PostgreSQL).
cmlenz
parents: 200
diff changeset
673 for report in Report.select(self.env, build=build.id, step=step.name):
e6ddca1e5712 Huge refactoring to remove dependency on BDB XML. Report data is now stored in the Trac database (SQLite/PostgreSQL).
cmlenz
parents: 200
diff changeset
674 summarizer = summarizers.get(report.category)
161
4677161d2ae9 Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents: 147
diff changeset
675 if summarizer:
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
676 tmpl, data = summarizer.render_summary(req, config, build,
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
677 step, report.category)
161
4677161d2ae9 Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents: 147
diff changeset
678 else:
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
679 tmpl = data = None
320
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
680 reports.append({'category': report.category,
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
681 'template': tmpl, 'data': data})
161
4677161d2ae9 Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents: 147
diff changeset
682 return reports
4677161d2ae9 Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents: 147
diff changeset
683
114
ecc062d4fd55 Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents: 112
diff changeset
684
409
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
685 class ReportChartController(Component):
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
686 implements(IRequestHandler)
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
687
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
688 generators = ExtensionPoint(IReportChartGenerator)
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
689
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
690 # IRequestHandler methods
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
691
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
692 def match_request(self, req):
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
693 match = re.match(r'/build/([\w.-]+)/chart/(\w+)', req.path_info)
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
694 if match:
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
695 req.args['config'] = match.group(1)
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
696 req.args['category'] = match.group(2)
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
697 return True
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
698
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
699 def process_request(self, req):
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
700 category = req.args.get('category')
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
701 config = BuildConfig.fetch(self.env, name=req.args.get('config'))
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
702
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
703 for generator in self.generators:
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
704 if category in generator.get_supported_categories():
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
705 tmpl, data = generator.generate_chart_data(req, config,
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
706 category)
409
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
707 break
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
708 else:
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
709 raise TracError('Unknown report category "%s"' % category)
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
710
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
711 return tmpl, data, 'text/xml'
409
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
712
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
713
114
ecc062d4fd55 Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents: 112
diff changeset
714 class SourceFileLinkFormatter(Component):
258
77cdef044d48 * Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents: 256
diff changeset
715 """Detects references to files in the build log and renders them as links
439
20ddfbb8e879 Fix for #154, added unit tests.
cmlenz
parents: 438
diff changeset
716 to the repository browser.
20ddfbb8e879 Fix for #154, added unit tests.
cmlenz
parents: 438
diff changeset
717 """
203
e6ddca1e5712 Huge refactoring to remove dependency on BDB XML. Report data is now stored in the Trac database (SQLite/PostgreSQL).
cmlenz
parents: 200
diff changeset
718
114
ecc062d4fd55 Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents: 112
diff changeset
719 implements(ILogFormatter)
ecc062d4fd55 Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents: 112
diff changeset
720
593
99831ab37fd3 0.6dev: Making source-linking work also for Windows-style file references (as output by Windows slaves). Thanks to Doug Patterson for updated regexp.
osimons
parents: 592
diff changeset
721 _fileref_re = re.compile(r'(?P<prefix>-[A-Za-z])?(?P<path>[\w.-]+(?:[\\/][\w.-]+)+)(?P<line>:\d+)?')
258
77cdef044d48 * Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents: 256
diff changeset
722
77cdef044d48 * Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents: 256
diff changeset
723 def get_formatter(self, req, build):
77cdef044d48 * Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents: 256
diff changeset
724 """Return the log message formatter function."""
77cdef044d48 * Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents: 256
diff changeset
725 config = BuildConfig.fetch(self.env, name=build.config)
114
ecc062d4fd55 Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents: 112
diff changeset
726 repos = self.env.get_repository(req.authname)
376
05c684ceb8c6 Use `req.href` instead of `env.href` as that works much better in Trac>=0.10. That also means Trac 0.9 is no longer supported.
cmlenz
parents: 362
diff changeset
727 href = req.href.browser
258
77cdef044d48 * Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents: 256
diff changeset
728 cache = {}
439
20ddfbb8e879 Fix for #154, added unit tests.
cmlenz
parents: 438
diff changeset
729
258
77cdef044d48 * Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents: 256
diff changeset
730 def _replace(m):
605
c94481bc4646 0.6dev: Reverting [677] as many of these paths are also used for URLs, and hadn't considered this change enough. No major point in changing code that already works well, so simply reverting seems the best idea...
osimons
parents: 603
diff changeset
731 filepath = posixpath.normpath(m.group('path').replace('\\', '/'))
258
77cdef044d48 * Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents: 256
diff changeset
732 if not cache.get(filepath) is True:
77cdef044d48 * Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents: 256
diff changeset
733 parts = filepath.split('/')
77cdef044d48 * Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents: 256
diff changeset
734 path = ''
77cdef044d48 * Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents: 256
diff changeset
735 for part in parts:
605
c94481bc4646 0.6dev: Reverting [677] as many of these paths are also used for URLs, and hadn't considered this change enough. No major point in changing code that already works well, so simply reverting seems the best idea...
osimons
parents: 603
diff changeset
736 path = posixpath.join(path, part)
439
20ddfbb8e879 Fix for #154, added unit tests.
cmlenz
parents: 438
diff changeset
737 if path not in cache:
258
77cdef044d48 * Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents: 256
diff changeset
738 try:
605
c94481bc4646 0.6dev: Reverting [677] as many of these paths are also used for URLs, and hadn't considered this change enough. No major point in changing code that already works well, so simply reverting seems the best idea...
osimons
parents: 603
diff changeset
739 full_path = posixpath.join(config.path, path)
c94481bc4646 0.6dev: Reverting [677] as many of these paths are also used for URLs, and hadn't considered this change enough. No major point in changing code that already works well, so simply reverting seems the best idea...
osimons
parents: 603
diff changeset
740 full_path = posixpath.normpath(full_path)
591
87f87c756dca 0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents: 590
diff changeset
741 if full_path.startswith(config.path + "/") \
87f87c756dca 0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents: 590
diff changeset
742 or full_path == config.path:
528
f3bf55de8a34 Prevent path highlighting from passing non-canonical paths to svn:
dfraser
parents: 506
diff changeset
743 repos.get_node(full_path,
f3bf55de8a34 Prevent path highlighting from passing non-canonical paths to svn:
dfraser
parents: 506
diff changeset
744 build.rev)
f3bf55de8a34 Prevent path highlighting from passing non-canonical paths to svn:
dfraser
parents: 506
diff changeset
745 cache[path] = True
f3bf55de8a34 Prevent path highlighting from passing non-canonical paths to svn:
dfraser
parents: 506
diff changeset
746 else:
f3bf55de8a34 Prevent path highlighting from passing non-canonical paths to svn:
dfraser
parents: 506
diff changeset
747 cache[path] = False
258
77cdef044d48 * Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents: 256
diff changeset
748 except TracError:
77cdef044d48 * Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents: 256
diff changeset
749 cache[path] = False
77cdef044d48 * Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents: 256
diff changeset
750 if cache[path] is False:
77cdef044d48 * Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents: 256
diff changeset
751 return m.group(0)
439
20ddfbb8e879 Fix for #154, added unit tests.
cmlenz
parents: 438
diff changeset
752 link = href(config.path, filepath)
20ddfbb8e879 Fix for #154, added unit tests.
cmlenz
parents: 438
diff changeset
753 if m.group('line'):
20ddfbb8e879 Fix for #154, added unit tests.
cmlenz
parents: 438
diff changeset
754 link += '#L' + m.group('line')[1:]
503
a7c795920c4a Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents: 493
diff changeset
755 return Markup(tag.a(m.group(0), href=link))
439
20ddfbb8e879 Fix for #154, added unit tests.
cmlenz
parents: 438
diff changeset
756
258
77cdef044d48 * Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents: 256
diff changeset
757 def _formatter(step, type, level, message):
439
20ddfbb8e879 Fix for #154, added unit tests.
cmlenz
parents: 438
diff changeset
758 buf = []
20ddfbb8e879 Fix for #154, added unit tests.
cmlenz
parents: 438
diff changeset
759 offset = 0
20ddfbb8e879 Fix for #154, added unit tests.
cmlenz
parents: 438
diff changeset
760 for mo in self._fileref_re.finditer(message):
20ddfbb8e879 Fix for #154, added unit tests.
cmlenz
parents: 438
diff changeset
761 start, end = mo.span()
20ddfbb8e879 Fix for #154, added unit tests.
cmlenz
parents: 438
diff changeset
762 if start > offset:
20ddfbb8e879 Fix for #154, added unit tests.
cmlenz
parents: 438
diff changeset
763 buf.append(message[offset:start])
20ddfbb8e879 Fix for #154, added unit tests.
cmlenz
parents: 438
diff changeset
764 buf.append(_replace(mo))
20ddfbb8e879 Fix for #154, added unit tests.
cmlenz
parents: 438
diff changeset
765 offset = end
440
e660687ac89c Follow-up fix to [486]: trailing chars in auto-linked log messages was getting removed.
cmlenz
parents: 439
diff changeset
766 if offset < len(message):
439
20ddfbb8e879 Fix for #154, added unit tests.
cmlenz
parents: 438
diff changeset
767 buf.append(message[offset:])
20ddfbb8e879 Fix for #154, added unit tests.
cmlenz
parents: 438
diff changeset
768 return Markup("").join(buf)
20ddfbb8e879 Fix for #154, added unit tests.
cmlenz
parents: 438
diff changeset
769
114
ecc062d4fd55 Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents: 112
diff changeset
770 return _formatter
Copyright (C) 2012-2017 Edgewall Software