Merge lp:~mabac/svammel/re-implement-harvesting-code into lp:svammel

Proposed by Mattias Backman
Status: Superseded
Proposed branch: lp:~mabac/svammel/re-implement-harvesting-code
Merge into: lp:svammel
Diff against target: 324 lines (+63/-158) (has conflicts)
5 files modified
bug_reporting.py (+1/-4)
data_parsing.py (+29/-89)
file-failures.py (+33/-4)
serialization.py (+0/-23)
serialize-packages.py (+0/-38)
Text conflict in file-failures.py
To merge this branch: bzr merge lp:~mabac/svammel/re-implement-harvesting-code
Reviewer Review Type Date Requested Status
James Westby (community) Needs Information
Review via email: mp+52563@code.launchpad.net

This proposal has been superseded by a proposal from 2011-03-09.

Description of the change

Hi,

This branch changes the build log harvesting and filtering into a more straight on approach.

Now the script begins with harvesting all builds with 'Failed to build' status. This step also includes collating all builds by source package. Then we filter out packages which are not interesting (those are packages with no fails on armel and those which failed on armel but also failed on another architecture).

Then we go ahead and file bugs for all the packages left after filtering.

Thanks,

Mattias

To post a comment you must log in.
Revision history for this message
James Westby (james-w) wrote :

Hi,

It looks like this contains your cleanup changes as well.

If you want to do this then submitting the merge proposal with
a "pre-requisite branch" will mean that we can review just the
diff of these changes, without seeing the changes from the other
branch again.

You can do this from the "Extra options" expander when submitting.
If you hit "Resubmit proposal" on this one then you should be able
to add the other branch as a pre-requisite to this merge proposal.

Thanks,

James

review: Needs Information
40. By Mattias Backman

Move magic string into constant.

41. By Mattias Backman

Merge trunk.

42. By Mattias Backman

Merge trunk.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bug_reporting.py'
2--- bug_reporting.py 2011-03-02 09:18:43 +0000
3+++ bug_reporting.py 2011-03-09 08:06:52 +0000
4@@ -63,7 +63,4 @@
5 # duplicate if the bug is an ftbfs and it is in the arm-porting-queue.
6 dupe_bugs = project.searchTasks(tags=dupe_tags, tags_combinator='All')
7
8- # Collection size is not available, so iterate to see if there are items.
9- for bug in dupe_bugs:
10- return True
11- return False
12+ return len(dupe_bugs[:1]) > 0
13
14=== modified file 'data_parsing.py'
15--- data_parsing.py 2011-03-02 09:18:03 +0000
16+++ data_parsing.py 2011-03-09 08:06:52 +0000
17@@ -30,8 +30,8 @@
18 all_packages = dict()
19 all_spph = dict()
20
21-all_packages_file = 'tests/serial/all_packages.dump'
22-all_spph_file = 'tests/serial/all_spph.dump'
23+
24+FAILED_BUILD_STATE = 'Failed to build'
25
26
27 class InvalidArchiveError(Exception):
28@@ -55,57 +55,13 @@
29 return tags
30
31
32-# Copied from build_status.py
33-# Copyright (c) 2007-2010 Michael Bienia <geser@ubuntu.com>
34-# Modified by Mattias Backman <mattias.backman@linaro.org>
35-class SourcePackage(object):
36- class VersionList(list):
37- def append(self, item):
38- super(SourcePackage.VersionList, self).append(item)
39- self.sort(key=lambda x: x.version, cmp=apt_pkg.VersionCompare)
40-
41- def __init__(self, srcpkg):
42- self.name = srcpkg.source_package_name
43- self.component = srcpkg.component_name
44- self.url = get_base_url() + '+source/%s' % self.name
45- self.apiurl = get_base_api_url() + '+source/%s' % self.name
46- self.versions = self.VersionList()
47- all_packages[self.name] = self
48-
49- def is_ftbfs(self, arch_list, current=True):
50- ''' Returns True if at least one FTBFS exists. '''
51- for ver in self.versions:
52- if ver.current != current:
53- continue
54- for arch in arch_list:
55- log = ver.get_arch(arch)
56- if log and log.buildstate != 'Needs building':
57- return True
58- return False
59-
60- def get_ftbfs_logs(self, arch):
61- ''' Returns logs for failed builds on arch. '''
62- fail_logs = []
63- for ver in self.versions:
64- buildlog = ver.get_arch(arch)
65- if buildlog and buildlog.buildstate == 'Failed to build':
66- fail_logs.append((ver.version, buildlog))
67- return fail_logs
68-
69-
70-# Copied from build_status.py
71-# Copyright (c) 2007-2010 Michael Bienia <geser@ubuntu.com>
72-# Modified by Mattias Backman <mattias.backman@linaro.org>
73 class SPPH(object):
74 def __init__(self, spph_link):
75 self.spph = get_launchpad().load(spph_link)
76 self.logs = dict()
77 self.version = self.spph.source_package_version
78- self.pocket = self.spph.pocket
79- self.srcpkg = all_packages.get(self.spph.source_package_name)
80- if not self.srcpkg:
81- self.srcpkg = SourcePackage(self.spph)
82- self.srcpkg.versions.append(self)
83+ self.package_name = self.spph.source_package_name
84+ self.url = get_base_api_url() + '+source/%s' % self.package_name
85 self.current = None
86
87 def add_build_log(self, buildlog):
88@@ -115,19 +71,16 @@
89 return self.logs.get(arch)
90
91
92-# Copied from build_status.py
93-# Copyright (c) 2007-2010 Michael Bienia <geser@ubuntu.com>
94-# Modified by Mattias Backman <mattias.backman@linaro.org>
95 def fetch_pkg_list(archive, series, main_archive=None):
96- state = 'Failed to build'
97 print_message('The following packages have failed to build.')
98
99 # XXX wgrant 2009-09-19: This is an awful hack. We should really
100 # just let IArchive.getBuildRecords take a series argument.
101+ # https://bugs.launchpad.net/launchpad/+bug/558907
102 if archive.name == 'primary':
103- buildlist = series.getBuildRecords(build_state=state)
104+ buildlist = series.getBuildRecords(build_state=FAILED_BUILD_STATE)
105 else:
106- buildlist = archive.getBuildRecords(build_state=state)
107+ buildlist = archive.getBuildRecords(build_state=FAILED_BUILD_STATE)
108
109 for build in buildlist:
110 csp_link = build.current_source_publication_link
111@@ -135,53 +88,40 @@
112 # Build log for an older version
113 continue
114
115- print_message(" %s" % build.title)
116+ print_message(" Found build '%s'" % build.title)
117
118 spph = all_spph.get(csp_link)
119 if not spph:
120 spph = all_spph[csp_link] = SPPH(csp_link)
121
122- if spph.current is None:
123- # If a main archive is specified, we check if the current source
124- # is still published there. If it isn't, then it's out of date.
125- # We should make this obvious.
126- # The main archive will normally be the primary archive, and
127- # probably only makes sense if the target archive is a rebuild.
128- if main_archive:
129- main_publications = main_archive.getPublishedSources(
130- distro_series=series,
131- exact_match=True,
132- source_name=spph.spph.source_package_name,
133- version=spph.spph.source_package_version,
134- status='Published')
135- spph.current = len(main_publications[:1]) > 0
136- else:
137- spph.current = True
138-
139- if not spph.current:
140- print_message(" superseded")
141 spph.add_build_log(build)
142
143- print_message("Done processing '%s'" % state)
144- return all_packages, all_spph
145-
146-
147-def get_selective_platform_fail(source_package, fail_platforms, ok_platforms):
148- """Determine if the build fail occurs only on certain platforms.
149+ return all_spph
150+
151+
152+def filter_spph(all_spph_list, fail_arch, ok_archs):
153+ """Filter out the build failures that are unique to the target arch.
154
155 Arguments:
156- source_package -- The source package to investigate.
157- fail_platforms -- A list of platforms for which we search for build fails.
158- ok_plaforms -- A list of platforms that should have built OK.
159+ all_spph_list -- List of all spphs to investigate.
160+ fail_arch -- The arch on which the builds should have failed.
161+ ok_archs -- A list of archs on which the builds have not failed.
162
163 Returns:
164- True if any of fail_platforms have failed to build and
165- there are no failures in ok_platforms.
166+ A subset of all_spph_list which represents the interesting packages.
167 """
168- if source_package.is_ftbfs(arch_list=fail_platforms, current=True):
169- return not source_package.is_ftbfs(arch_list=ok_platforms,
170- current=True)
171- return False
172+ filtered_list = []
173+ for spph in all_spph_list.values():
174+ if spph.get_arch(fail_arch) is None:
175+ # Drop this spph since it did not fail on target arch.
176+ continue
177+ if next((arch for arch in ok_archs if spph.get_arch(arch)),
178+ None) is not None:
179+ # Drop this spph since it did fail on other arch.
180+ continue
181+ filtered_list.append(spph)
182+
183+ return filtered_list
184
185
186 def get_build_status(archive_name, series_name):
187
188=== modified file 'file-failures.py'
189--- file-failures.py 2011-03-07 09:57:11 +0000
190+++ file-failures.py 2011-03-09 08:06:52 +0000
191@@ -13,7 +13,7 @@
192 from data_parsing import (
193 get_tags_for_fail,
194 get_build_status,
195- get_selective_platform_fail,
196+ filter_spph,
197 )
198 from bug_reporting import (
199 file_bug_by_url,
200@@ -44,12 +44,20 @@
201 set_verbose_messages(args.verbose)
202
203 init(args.serviceroot, 'testing', '~/.launchpadlib/cache/')
204+
205+# We are interested in build failures for this platform:
206+fail_platform = 'armel'
207+# unless there's a failed build for any of these:
208+ok_platforms = ['i386', 'amd64']
209+
210 try:
211- all_packages, all_spph = get_build_status(args.archive, args.series)
212+ interesting_spph = filter_spph(get_build_status(args.archive, args.series),
213+ fail_platform, ok_platforms)
214 except:
215 print 'Error: Could not get build status'
216 raise
217
218+<<<<<<< TREE
219 # We are interested in build failures for these platforms:
220 fail_platforms = ['armel']
221 # unless there's a failed build for any of these:
222@@ -79,6 +87,27 @@
223 (sp.name, bug_description[0:220], bug_title, bug_tags))
224 file_bug_by_url(sp.apiurl, bug_description, bug_title,
225 bug_tags, get_launchpad())
226+=======
227+for spph in interesting_spph:
228+
229+ log = spph.get_arch(fail_platform)
230+ if log is not None:
231+ build_log = get_file_contents(log.build_log_url)
232+>>>>>>> MERGE-SOURCE
233 else:
234- print_message("No reason to file a bug for %s." % sp.name)
235- print_message('\n--')
236+ print "%s build log not available for %s version %s." % \
237+ (fail_platform, spph.package_name, spph.version)
238+ build_log = ''
239+ bug_tags = get_tags_for_fail(build_log)
240+ interesting_log_part = get_interesting_part(build_log)
241+
242+ bug_title = '%s version %s failed to build on %s' % \
243+ (spph.package_name, spph.version, log.arch_tag)
244+ bug_description = '%s\n%s\n\n%s' % \
245+ (bug_title, log.web_link, interesting_log_part)
246+
247+ print_message(
248+ "Will file bug for %s\n desc: %s\n title: %s\n tags: %s" %
249+ (spph.package_name, bug_description[0:220], bug_title, bug_tags))
250+ file_bug_by_url(spph.url, bug_description, bug_title,
251+ bug_tags, get_launchpad())
252
253=== removed file 'serialization.py'
254--- serialization.py 2011-02-28 14:51:09 +0000
255+++ serialization.py 1970-01-01 00:00:00 +0000
256@@ -1,23 +0,0 @@
257-###############################################################################
258-# Copyright (c) 2011, 2011 Linaro
259-# All rights reserved. This program and the accompanying materials
260-# are made available under the terms of the Eclipse Public License v1.0
261-# which accompanies this distribution, and is available at
262-# http://www.eclipse.org/legal/epl-v10.html
263-#
264-# Contributors:
265-# Linaro Infrastructure Team - initial implementation
266-###############################################################################
267-import pickle
268-
269-
270-def dump_object(obj, f):
271- """Dump obj to f. """
272- with open(f, 'wb') as pickle_file:
273- pickle.dump(obj, pickle_file)
274-
275-
276-def load_object(f):
277- """Load from f and return the object."""
278- with open(f, 'rb') as from_file:
279- return pickle.load(from_file)
280
281=== removed file 'serialize-packages.py'
282--- serialize-packages.py 2011-02-28 14:51:09 +0000
283+++ serialize-packages.py 1970-01-01 00:00:00 +0000
284@@ -1,38 +0,0 @@
285-###############################################################################
286-# Copyright (c) 2011, 2011 Linaro
287-# All rights reserved. This program and the accompanying materials
288-# are made available under the terms of the Eclipse Public License v1.0
289-# which accompanies this distribution, and is available at
290-# http://www.eclipse.org/legal/epl-v10.html
291-#
292-# Contributors:
293-# Linaro Infrastructure Team - initial implementation
294-###############################################################################
295-from serialization import (
296- dump_object,
297- )
298-from data_parsing import (
299- get_build_status,
300- all_packages,
301- all_spph,
302- all_packages_file,
303- all_spph_file,
304- )
305-
306-
307-def dump_build_status():
308- dump_object(all_spph, all_spph_file)
309- dump_object(all_packages, all_packages_file)
310-
311- print """
312- Done serializing build data:
313- all_packages -> %s
314- all_spph -> %s
315- """ % (all_packages_file, all_spph_file)
316-
317-
318-print """Downloading build data"""
319-get_build_status()
320-
321-print """Serializing objects"""
322-dump_build_status()
323
324=== removed directory 'tests/serial'

Subscribers

People subscribed via source and target branches