Mercurial > bitten > bitten-test
annotate bitten/web_ui.py @ 488:9b3d97297201
Fix compatibility problem with Genshi trunk.
author | cmlenz |
---|---|
date | Sun, 27 Apr 2008 22:58:24 +0000 |
parents | 28123a0c14db |
children | f10da0985227 |
rev | line source |
---|---|
379 | 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 | 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 | 7 # This software is licensed as described in the file COPYING, which |
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 | 11 """Implementation of the Bitten web interface.""" |
12 | |
295
5f84af72d17f
* Store executable bit in ZIP archives (from `svn:executable`).
cmlenz
parents:
263
diff
changeset
|
13 from datetime import datetime |
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
|
14 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
|
15 import re |
250 | 16 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
|
17 |
99
efc1eed69ba8
Make Bitten deployable in Trac as a [http://peak.telecommunity.com/DevCenter/PythonEggs Python egg].
cmlenz
parents:
98
diff
changeset
|
18 import pkg_resources |
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
|
19 from trac.core import * |
362 | 20 try: |
21 from trac.timeline import ITimelineEventProvider | |
22 except ImportError: | |
23 from trac.Timeline import ITimelineEventProvider | |
321 | 24 from trac.util import escape, pretty_timedelta, format_datetime, shorten_line, \ |
25 Markup | |
439 | 26 from trac.util.html import html |
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
|
27 from trac.web import IRequestHandler |
74
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
28 from trac.web.chrome import INavigationContributor, ITemplateProvider, \ |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
29 add_link, add_stylesheet |
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
|
30 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
|
31 from bitten.api import ILogFormatter, IReportChartGenerator, IReportSummarizer |
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
|
32 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
|
33 BuildLog, Report |
228
a8c9dd7e3f71
* Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents:
219
diff
changeset
|
34 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
|
35 |
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
|
36 _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
|
37 Build.IN_PROGRESS: 'in progress', |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
38 Build.SUCCESS: 'completed', |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
39 Build.FAILURE: 'failed'} |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
40 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
41 def _build_to_hdf(env, req, build): |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
42 hdf = {'id': build.id, 'name': build.slave, 'rev': build.rev, |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
43 'status': _status_label[build.status], |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
44 'cls': _status_label[build.status].replace(' ', '-'), |
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
|
45 'href': req.href.build(build.config, build.id), |
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
|
46 '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
|
47 if build.started: |
250 | 48 hdf['started'] = format_datetime(build.started) |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
49 hdf['started_delta'] = pretty_timedelta(build.started) |
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
|
50 hdf['duration'] = pretty_timedelta(build.started) |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
51 if build.stopped: |
250 | 52 hdf['stopped'] = format_datetime(build.stopped) |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
53 hdf['stopped_delta'] = pretty_timedelta(build.stopped) |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
54 hdf['duration'] = pretty_timedelta(build.stopped, build.started) |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
55 hdf['slave'] = { |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
56 'name': build.slave, |
250 | 57 'ipnr': build.slave_info.get(Build.IP_ADDRESS), |
58 'os.name': build.slave_info.get(Build.OS_NAME), | |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
59 'os.family': build.slave_info.get(Build.OS_FAMILY), |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
60 'os.version': build.slave_info.get(Build.OS_VERSION), |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
61 '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
|
62 '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
|
63 } |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
64 return hdf |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
65 |
318 | 66 |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
67 class BittenChrome(Component): |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
68 """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
|
69 |
320 | 70 implements(INavigationContributor, ITemplateProvider) |
64 | 71 |
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
|
72 # 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
|
73 |
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
|
74 def get_active_navigation_item(self, req): |
316 | 75 """Called by Trac to determine which navigation item should be marked |
76 as active. | |
77 | |
411
a169d2e96463
Use reStructuredText as the API documentation syntax.
cmlenz
parents:
410
diff
changeset
|
78 :param req: the request object |
316 | 79 """ |
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
|
80 return 'build' |
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 |
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
|
82 def get_navigation_items(self, req): |
316 | 83 """Return the navigation item for access the build status overview from |
84 the Trac navigation bar.""" | |
50
0d5ad32948b7
Restrict access to web interface with custom permission actions.
cmlenz
parents:
47
diff
changeset
|
85 if not req.perm.has_permission('BUILD_VIEW'): |
0d5ad32948b7
Restrict access to web interface with custom permission actions.
cmlenz
parents:
47
diff
changeset
|
86 return |
320 | 87 yield ('mainnav', 'build', \ |
488 | 88 Markup('<a href="%s" accesskey="5">Build Status</a>') % |
89 req.href.build()) | |
320 | 90 |
91 # ITemplatesProvider methods | |
92 | |
93 def get_htdocs_dirs(self): | |
94 """Return the directories containing static resources.""" | |
95 return [('bitten', pkg_resources.resource_filename(__name__, 'htdocs'))] | |
96 | |
97 def get_templates_dirs(self): | |
98 """Return the directories containing templates.""" | |
99 return [pkg_resources.resource_filename(__name__, 'templates')] | |
100 | |
101 | |
102 class BuildConfigController(Component): | |
103 """Implements the web interface for build configurations.""" | |
104 | |
105 implements(IRequestHandler) | |
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
|
106 |
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
|
107 # 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
|
108 |
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
|
109 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
|
110 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
|
111 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
|
112 if match.group(1): |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
113 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
|
114 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
|
115 |
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
|
116 def process_request(self, req): |
50
0d5ad32948b7
Restrict access to web interface with custom permission actions.
cmlenz
parents:
47
diff
changeset
|
117 req.perm.assert_permission('BUILD_VIEW') |
0d5ad32948b7
Restrict access to web interface with custom permission actions.
cmlenz
parents:
47
diff
changeset
|
118 |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
119 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
|
120 view = req.args.get('view') |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
121 config = req.args.get('config') |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
122 |
436
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
423
diff
changeset
|
123 if config: |
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
423
diff
changeset
|
124 self._render_config(req, config) |
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
423
diff
changeset
|
125 elif view == 'inprogress': |
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
423
diff
changeset
|
126 self._render_inprogress(req) |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
127 else: |
436
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
423
diff
changeset
|
128 self._render_overview(req) |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
129 |
164
a9cddfae3c09
Adapt to Trac [http://projects.edgewall.com/trac/changeset/2132 r2132].
cmlenz
parents:
163
diff
changeset
|
130 add_stylesheet(req, 'bitten/bitten.css') |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
131 return 'bitten_config.cs', None |
64 | 132 |
133 # Internal methods | |
134 | |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
135 def _render_overview(self, req): |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
136 req.hdf['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
|
137 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
|
138 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
|
139 show_all = True |
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
|
140 req.hdf['config.show_all'] = 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
|
141 |
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
|
142 configs = BuildConfig.select(self.env, include_inactive=show_all) |
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
|
143 for idx, config in enumerate(configs): |
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
|
144 prefix = 'configs.%d' % idx |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
145 description = config.description |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
146 if description: |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
147 description = wiki_to_html(description, self.env, 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
|
148 req.hdf[prefix] = { |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
149 '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
|
150 '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
|
151 'description': description, |
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
|
152 'href': req.href.build(config.name), |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
153 } |
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
|
154 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
|
155 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
|
156 |
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
|
157 repos = self.env.get_repository(req.authname) |
360
5bc81e597352
Fix incompatibility with a change to the versioncontrol layer in Trac 0.10.3
cmlenz
parents:
328
diff
changeset
|
158 if hasattr(repos, 'sync'): |
5bc81e597352
Fix incompatibility with a change to the versioncontrol layer in Trac 0.10.3
cmlenz
parents:
328
diff
changeset
|
159 repos.sync() |
5bc81e597352
Fix incompatibility with a change to the versioncontrol layer in Trac 0.10.3
cmlenz
parents:
328
diff
changeset
|
160 |
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
|
161 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
|
162 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
|
163 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
|
164 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
|
165 chgset = repos.get_changeset(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
|
166 req.hdf[prefix + '.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
|
167 'id': rev, 'href': req.href.changeset(rev), |
320 | 168 '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
|
169 '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
|
170 'message': wiki_to_oneliner( |
485
28123a0c14db
Unmerge [524] to preserve trac 0.10 compatibility. Those who want 0.11b support should use the head of the experimental/trac-0.11 branch.
wbell
parents:
477
diff
changeset
|
171 shorten_line(chgset.message), self.env) |
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
|
172 } |
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
|
173 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
|
174 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
|
175 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
|
176 if build: |
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
|
177 build_hdf = _build_to_hdf(self.env, req, build) |
320 | 178 build_hdf['platform'] = platform.name |
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
|
179 req.hdf[prefix + '.builds.%d' % platform.id] = build_hdf |
aa942e2c7243
A bit of polishing for [265]: also show build if not yet in the queue, some layout improvements.
cmlenz
parents:
255
diff
changeset
|
180 else: |
aa942e2c7243
A bit of polishing for [265]: also show build if not yet in the queue, some layout improvements.
cmlenz
parents:
255
diff
changeset
|
181 req.hdf[prefix + '.builds.%d' % platform.id] = { |
320 | 182 'platform': platform.name, 'status': 'pending' |
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
|
183 } |
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
|
184 |
123 | 185 req.hdf['page.mode'] = 'overview' |
436
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
423
diff
changeset
|
186 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
|
187 'In Progress Builds') |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
188 |
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
|
189 def _render_inprogress(self, req): |
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
|
190 req.hdf['title'] = 'In Progress Builds' |
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
|
191 |
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
|
192 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
|
193 |
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
|
194 configs = BuildConfig.select(self.env, include_inactive=False) |
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
|
195 for idx, config in enumerate(configs): |
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
|
196 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
|
197 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
|
198 |
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
|
199 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
|
200 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
|
201 |
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
|
202 # sort correctly by revision. |
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
|
203 builds = list(in_progress_builds) |
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
|
204 builds.sort(lambda x, y: int(y.rev) - int(x.rev)) |
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
|
205 prefix = 'configs.%d' % idx |
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
|
206 |
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
|
207 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
|
208 for idx2, build in enumerate(builds): |
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
|
209 prefix2 = '%s.builds.%d' % (prefix, idx2) |
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
|
210 rev = build.rev |
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
|
211 req.hdf[prefix2] = _build_to_hdf(self.env, req, build) |
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
|
212 req.hdf[prefix2 + '.rev'] = rev |
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
|
213 req.hdf[prefix2 + '.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
|
214 platform = TargetPlatform.fetch(self.env, build.platform) |
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
|
215 req.hdf[prefix2 + '.platform'] = platform.name |
437
6d5ac24061dc
Fix build queue population compatiblity with Trac 0.11, where revision timestamps are `datetime` objects.
cmlenz
parents:
436
diff
changeset
|
216 |
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
|
217 for step in BuildStep.select(self.env, build=build.id, db=db): |
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
|
218 req.hdf['%s.steps.%s' % (prefix2, step.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
|
219 'description': step.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
|
220 'duration': datetime.fromtimestamp(step.stopped) - \ |
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
|
221 datetime.fromtimestamp(step.started), |
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
|
222 'failed': not step.successful, |
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
|
223 'errors': step.errors, |
437
6d5ac24061dc
Fix build queue population compatiblity with Trac 0.11, where revision timestamps are `datetime` objects.
cmlenz
parents:
436
diff
changeset
|
224 'href': req.hdf[prefix2 + '.href'] + '#step_' + step.name |
6d5ac24061dc
Fix build queue population compatiblity with Trac 0.11, where revision timestamps are `datetime` objects.
cmlenz
parents:
436
diff
changeset
|
225 } |
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
|
226 |
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
|
227 current_builds = current_builds + 1 |
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
|
228 |
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
|
229 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
|
230 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
|
231 |
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
|
232 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
|
233 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
|
234 description = wiki_to_html(description, self.env, req) |
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
|
235 req.hdf[prefix] = { |
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
|
236 '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
|
237 '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
|
238 '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
|
239 'href': req.href.build(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
|
240 } |
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
|
241 |
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
|
242 req.hdf['page.mode'] = 'view_inprogress' |
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
|
243 |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
244 def _render_config(self, req, config_name): |
250 | 245 db = self.env.get_db_cnx() |
246 | |
247 config = BuildConfig.fetch(self.env, config_name, db=db) | |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
248 req.hdf['title'] = 'Build Configuration "%s"' \ |
320 | 249 % 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
|
250 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
|
251 description = config.description |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
252 if description: |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
253 description = wiki_to_html(description, self.env, req) |
123 | 254 req.hdf['config'] = { |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
255 'name': config.name, 'label': config.label, 'path': config.path, |
250 | 256 '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
|
257 'min_rev_href': req.href.changeset(config.min_rev), |
250 | 258 '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
|
259 '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
|
260 'active': config.active, 'description': description, |
436
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
423
diff
changeset
|
261 'browser_href': req.href.browser(config.path) |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
262 } |
123 | 263 req.hdf['page.mode'] = 'view_config' |
47
083e848088ee
* Improvements to the model classes, and a couple of unit tests.
cmlenz
parents:
45
diff
changeset
|
264 |
250 | 265 platforms = list(TargetPlatform.select(self.env, config=config_name, |
266 db=db)) | |
123 | 267 req.hdf['config.platforms'] = [ |
76
ffa1ffd8c7db
* Implement basic slave selection based on configured target platforms. Closes #15.
cmlenz
parents:
74
diff
changeset
|
268 {'name': platform.name, 'id': platform.id} for platform in platforms |
ffa1ffd8c7db
* Implement basic slave selection based on configured target platforms. Closes #15.
cmlenz
parents:
74
diff
changeset
|
269 ] |
74
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
270 |
197
d72c0587fae9
* Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents:
196
diff
changeset
|
271 has_reports = False |
250 | 272 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
|
273 has_reports = True |
d72c0587fae9
* Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents:
196
diff
changeset
|
274 break |
d72c0587fae9
* Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents:
196
diff
changeset
|
275 |
d72c0587fae9
* Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents:
196
diff
changeset
|
276 if has_reports: |
388
3ba9430a5d87
Fix for hardcoded chart generators in UI. Closes #153.
cmlenz
parents:
382
diff
changeset
|
277 chart_generators = [] |
391
7801dddec1a1
Sign, another follow-up to [438]. One of these days I should get it right :-(
cmlenz
parents:
390
diff
changeset
|
278 for generator in ReportChartController(self.env).generators: |
388
3ba9430a5d87
Fix for hardcoded chart generators in UI. Closes #153.
cmlenz
parents:
382
diff
changeset
|
279 for category in generator.get_supported_categories(): |
3ba9430a5d87
Fix for hardcoded chart generators in UI. Closes #153.
cmlenz
parents:
382
diff
changeset
|
280 chart_generators.append({ |
3ba9430a5d87
Fix for hardcoded chart generators in UI. Closes #153.
cmlenz
parents:
382
diff
changeset
|
281 'href': req.href.build(config.name, 'chart/' + category) |
3ba9430a5d87
Fix for hardcoded chart generators in UI. Closes #153.
cmlenz
parents:
382
diff
changeset
|
282 }) |
3ba9430a5d87
Fix for hardcoded chart generators in UI. Closes #153.
cmlenz
parents:
382
diff
changeset
|
283 req.hdf['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
|
284 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
|
285 if charts_license: |
320 | 286 req.hdf['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
|
287 |
214 | 288 page = max(1, int(req.args.get('page', 1))) |
289 more = False | |
290 req.hdf['page.number'] = page | |
291 | |
360
5bc81e597352
Fix incompatibility with a change to the versioncontrol layer in Trac 0.10.3
cmlenz
parents:
328
diff
changeset
|
292 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
|
293 if hasattr(repos, 'sync'): |
5bc81e597352
Fix incompatibility with a change to the versioncontrol layer in Trac 0.10.3
cmlenz
parents:
328
diff
changeset
|
294 repos.sync() |
5bc81e597352
Fix incompatibility with a change to the versioncontrol layer in Trac 0.10.3
cmlenz
parents:
328
diff
changeset
|
295 |
228
a8c9dd7e3f71
* Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents:
219
diff
changeset
|
296 builds_per_page = 12 * len(platforms) |
a8c9dd7e3f71
* Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents:
219
diff
changeset
|
297 idx = 0 |
a8c9dd7e3f71
* Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents:
219
diff
changeset
|
298 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
|
299 if idx >= page * builds_per_page: |
a8c9dd7e3f71
* Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents:
219
diff
changeset
|
300 more = True |
a8c9dd7e3f71
* Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents:
219
diff
changeset
|
301 break |
232
b6e4896dc026
Fix regression introduced in [239]: first build was being skipped on build configuration page.
cmlenz
parents:
230
diff
changeset
|
302 elif idx >= (page - 1) * builds_per_page: |
438
99d516f75169
Don't assume revisions are integers on build configuration page.
cmlenz
parents:
437
diff
changeset
|
303 prefix = 'config.builds.%s' % 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
|
304 req.hdf[prefix + '.href'] = req.href.changeset(rev) |
230 | 305 if build and build.status != Build.PENDING: |
306 build_hdf = _build_to_hdf(self.env, req, build) | |
307 req.hdf['%s.%s' % (prefix, platform.id)] = build_hdf | |
250 | 308 for step in BuildStep.select(self.env, build=build.id, |
309 db=db): | |
310 req.hdf['%s.%s.steps.%s' % (prefix, platform.id, | |
311 step.name)] = { | |
320 | 312 'description': step.description, |
250 | 313 'duration': datetime.fromtimestamp(step.stopped) - \ |
314 datetime.fromtimestamp(step.started), | |
315 'failed': not step.successful, | |
316 'errors': step.errors, | |
317 'href': build_hdf['href'] + '#step_' + step.name, | |
318 } | |
230 | 319 idx += 1 |
214 | 320 |
228
a8c9dd7e3f71
* Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents:
219
diff
changeset
|
321 if page > 1: |
a8c9dd7e3f71
* Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents:
219
diff
changeset
|
322 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
|
323 prev_href = req.href.build(config.name) |
228
a8c9dd7e3f71
* Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents:
219
diff
changeset
|
324 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
|
325 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
|
326 add_link(req, 'prev', prev_href, 'Previous Page') |
a8c9dd7e3f71
* Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents:
219
diff
changeset
|
327 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
|
328 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
|
329 add_link(req, 'next', next_href, 'Next Page') |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
330 |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
331 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
332 class BuildController(Component): |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
333 """Renders the build page.""" |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
334 implements(INavigationContributor, IRequestHandler, ITimelineEventProvider) |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
335 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
336 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
|
337 report_summarizers = ExtensionPoint(IReportSummarizer) |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
338 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
339 # INavigationContributor methods |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
340 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
341 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
|
342 return 'build' |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
343 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
344 def get_navigation_items(self, req): |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
345 return [] |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
346 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
347 # IRequestHandler methods |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
348 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
349 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
|
350 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
|
351 if match: |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
352 if match.group(1): |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
353 req.args['config'] = match.group(1) |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
354 if match.group(2): |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
355 req.args['id'] = match.group(2) |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
356 return True |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
357 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
358 def process_request(self, req): |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
359 req.perm.assert_permission('BUILD_VIEW') |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
360 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
361 db = self.env.get_db_cnx() |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
362 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
|
363 build = Build.fetch(self.env, build_id, db=db) |
96 | 364 assert build, 'Build %s does not exist' % build_id |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
365 |
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
|
366 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
|
367 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
|
368 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
|
369 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
|
370 |
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
|
371 add_link(req, 'up', req.href.build(build.config), |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
372 'Build Configuration') |
91 | 373 status2title = {Build.SUCCESS: 'Success', Build.FAILURE: 'Failure', |
374 Build.IN_PROGRESS: 'In Progress'} | |
69 | 375 req.hdf['title'] = 'Build %s - %s' % (build_id, |
376 status2title[build.status]) | |
123 | 377 req.hdf['page.mode'] = 'view_build' |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
378 config = BuildConfig.fetch(self.env, build.config, db=db) |
69 | 379 req.hdf['build.config'] = { |
380 'name': config.label, | |
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
|
381 'href': req.href.build(config.name) |
69 | 382 } |
383 | |
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
|
384 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
|
385 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
|
386 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
|
387 |
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
|
388 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
|
389 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
|
390 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
|
391 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
|
392 |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
393 req.hdf['build'] = _build_to_hdf(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
|
394 steps = [] |
112
a38eabd4b6e1
* Store build logs in a structured way, for example to highlight messages on the error stream.
cmlenz
parents:
111
diff
changeset
|
395 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
|
396 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
|
397 'name': step.name, 'description': step.description, |
123 | 398 '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
|
399 'failed': step.status == BuildStep.FAILURE, |
245
a22ec8fce6c9
Store the reason(s) for build step failure in the database.
cmlenz
parents:
232
diff
changeset
|
400 '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
|
401 '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
|
402 '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
|
403 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
|
404 }) |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
405 req.hdf['build.steps'] = steps |
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
|
406 req.hdf['build.can_delete'] = req.perm.has_permission('BUILD_DELETE') |
120
b63ed684c29c
Show the list of reports generated on the build page.
cmlenz
parents:
114
diff
changeset
|
407 |
250 | 408 repos = self.env.get_repository(req.authname) |
409 chgset = repos.get_changeset(build.rev) | |
410 req.hdf['build.chgset_author'] = chgset.author | |
411 | |
164
a9cddfae3c09
Adapt to Trac [http://projects.edgewall.com/trac/changeset/2132 r2132].
cmlenz
parents:
163
diff
changeset
|
412 add_stylesheet(req, 'bitten/bitten.css') |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
413 return 'bitten_build.cs', 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
|
414 |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
415 # ITimelineEventProvider methods |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
416 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
417 def get_timeline_filters(self, req): |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
418 if req.perm.has_permission('BUILD_VIEW'): |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
419 yield ('build', 'Builds') |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
420 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
421 def get_timeline_events(self, req, start, stop, filters): |
311 | 422 if 'build' not in filters: |
423 return | |
250 | 424 |
382
2078b20186cf
Trac 0.11 compatibility fix in timeline event provider.
cmlenz
parents:
381
diff
changeset
|
425 if isinstance(start, datetime): # Trac>=0.11 |
2078b20186cf
Trac 0.11 compatibility fix in timeline event provider.
cmlenz
parents:
381
diff
changeset
|
426 from trac.util.datefmt import to_timestamp |
2078b20186cf
Trac 0.11 compatibility fix in timeline event provider.
cmlenz
parents:
381
diff
changeset
|
427 start = to_timestamp(start) |
2078b20186cf
Trac 0.11 compatibility fix in timeline event provider.
cmlenz
parents:
381
diff
changeset
|
428 stop = to_timestamp(stop) |
2078b20186cf
Trac 0.11 compatibility fix in timeline event provider.
cmlenz
parents:
381
diff
changeset
|
429 |
311 | 430 add_stylesheet(req, 'bitten/bitten.css') |
431 | |
432 db = self.env.get_db_cnx() | |
433 cursor = db.cursor() | |
434 cursor.execute("SELECT b.id,b.config,c.label,b.rev,p.name," | |
435 "b.stopped,b.status FROM bitten_build AS b" | |
436 " INNER JOIN bitten_config AS c ON (c.name=b.config) " | |
437 " INNER JOIN bitten_platform AS p ON (p.id=b.platform) " | |
438 "WHERE b.stopped>=%s AND b.stopped<=%s " | |
439 "AND b.status IN (%s, %s) ORDER BY b.stopped", | |
440 (start, stop, Build.SUCCESS, Build.FAILURE)) | |
441 | |
442 event_kinds = {Build.SUCCESS: 'successbuild', | |
443 Build.FAILURE: 'failedbuild'} | |
444 for id, config, label, rev, platform, stopped, status in cursor: | |
445 | |
446 errors = [] | |
447 if status == Build.FAILURE: | |
448 for step in BuildStep.select(self.env, build=id, | |
449 status=BuildStep.FAILURE, | |
450 db=db): | |
320 | 451 errors += [(step.name, error) for error |
311 | 452 in step.errors] |
453 | |
488 | 454 title = Markup('Build of <em>%s [%s]</em> on %s %s') % ( |
455 label, rev, platform, _status_label[status] | |
456 ) | |
311 | 457 message = '' |
458 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
|
459 href = req.abs_href.build(config, id) |
311 | 460 if errors: |
461 buf = StringIO() | |
462 prev_step = None | |
463 for step, error in errors: | |
464 if step != prev_step: | |
465 if prev_step is not None: | |
466 buf.write('</ul>') | |
321 | 467 buf.write('<p>Step %s failed:</p><ul>' \ |
468 % escape(step)) | |
311 | 469 prev_step = step |
321 | 470 buf.write('<li>%s</li>' % escape(error)) |
311 | 471 buf.write('</ul>') |
320 | 472 message = Markup(buf.getvalue()) |
311 | 473 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
|
474 href = req.href.build(config, id) |
311 | 475 if errors: |
476 steps = [] | |
477 for step, error in errors: | |
478 if step not in steps: | |
479 steps.append(step) | |
488 | 480 steps = [Markup('<em>%s</em>') % step for step in steps] |
311 | 481 if len(steps) < 2: |
482 message = steps[0] | |
483 elif len(steps) == 2: | |
320 | 484 message = Markup(' and ').join(steps) |
311 | 485 elif len(steps) > 2: |
320 | 486 message = Markup(', ').join(steps[:-1]) + ', and ' + \ |
311 | 487 steps[-1] |
488 | 488 message = Markup('Step%s %s failed') % ( |
489 len(steps) != 1 and 's' or '', message | |
490 ) | |
311 | 491 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
|
492 |
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
|
493 # 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
|
494 |
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
|
495 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
|
496 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
|
497 |
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
|
498 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
|
499 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
|
500 |
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 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
|
502 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
|
503 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
|
504 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
|
505 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
|
506 |
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
|
507 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
|
508 |
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
|
509 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
|
510 |
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
|
511 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
|
512 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
|
513 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
|
514 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
|
515 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
|
516 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
|
517 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
|
518 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
|
519 |
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
|
520 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
|
521 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
|
522 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
|
523 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
|
524 if summarizer: |
213
25f84dd9f159
* Refactoring of build recipes, the file format has changed slightly:
cmlenz
parents:
209
diff
changeset
|
525 summary = summarizer.render_summary(req, config, build, step, |
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
|
526 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
|
527 else: |
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
|
528 summary = None |
320 | 529 reports.append({'category': report.category, |
530 'summary': Markup(summary)}) | |
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
|
531 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
|
532 |
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
|
533 |
409
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
534 class ReportChartController(Component): |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
535 implements(IRequestHandler) |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
536 |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
537 generators = ExtensionPoint(IReportChartGenerator) |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
538 |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
539 # IRequestHandler methods |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
540 |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
541 def match_request(self, req): |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
542 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
|
543 if match: |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
544 req.args['config'] = match.group(1) |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
545 req.args['category'] = match.group(2) |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
546 return True |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
547 |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
548 def process_request(self, req): |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
549 category = req.args.get('category') |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
550 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
|
551 |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
552 for generator in self.generators: |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
553 if category in generator.get_supported_categories(): |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
554 template = generator.generate_chart_data(req, config, |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
555 category) |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
556 break |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
557 else: |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
558 raise TracError('Unknown report category "%s"' % category) |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
559 |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
560 return template, 'text/xml' |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
561 |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
562 |
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
|
563 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
|
564 """Detects references to files in the build log and renders them as links |
439 | 565 to the repository browser. |
566 """ | |
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
|
567 |
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
|
568 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
|
569 |
439 | 570 _fileref_re = re.compile('(?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
|
571 |
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
|
572 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
|
573 """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
|
574 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
|
575 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
|
576 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
|
577 cache = {} |
439 | 578 |
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
|
579 def _replace(m): |
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
|
580 filepath = posixpath.normpath(m.group('path').replace('\\', '/')) |
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
|
581 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
|
582 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
|
583 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
|
584 for part in parts: |
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
|
585 path = posixpath.join(path, part) |
439 | 586 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
|
587 try: |
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
|
588 repos.get_node(posixpath.join(config.path, 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
|
589 build.rev) |
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
|
590 cache[path] = 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
|
591 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
|
592 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
|
593 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
|
594 return m.group(0) |
439 | 595 link = href(config.path, filepath) |
596 if m.group('line'): | |
597 link += '#L' + m.group('line')[1:] | |
598 return Markup(html.A(m.group(0), href=link)) | |
599 | |
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
|
600 def _formatter(step, type, level, message): |
439 | 601 buf = [] |
602 offset = 0 | |
603 for mo in self._fileref_re.finditer(message): | |
604 start, end = mo.span() | |
605 if start > offset: | |
606 buf.append(message[offset:start]) | |
607 buf.append(_replace(mo)) | |
608 offset = end | |
440
e660687ac89c
Follow-up fix to [486]: trailing chars in auto-linked log messages was getting removed.
cmlenz
parents:
439
diff
changeset
|
609 if offset < len(message): |
439 | 610 buf.append(message[offset:]) |
611 return Markup("").join(buf) | |
612 | |
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
|
613 return _formatter |