OLD | NEW |
| (Empty) |
1 from buildbot.process import base | |
2 from buildbot.status import builder | |
3 from buildbot.process.properties import Properties | |
4 | |
5 | |
6 class BuildSet: | |
7 """I represent a set of potential Builds, all of the same source tree, | |
8 across a specified list of Builders. I can represent a build of a | |
9 specific version of the source tree (named by source.branch and | |
10 source.revision), or a build of a certain set of Changes | |
11 (source.changes=list).""" | |
12 | |
13 def __init__(self, builderNames, source, reason=None, bsid=None, | |
14 properties=None): | |
15 """ | |
16 @param source: a L{buildbot.sourcestamp.SourceStamp} | |
17 """ | |
18 self.builderNames = builderNames | |
19 self.source = source | |
20 self.reason = reason | |
21 | |
22 self.properties = Properties() | |
23 if properties: self.properties.updateFromProperties(properties) | |
24 | |
25 self.stillHopeful = True | |
26 self.status = bss = builder.BuildSetStatus(source, reason, | |
27 builderNames, bsid) | |
28 | |
29 def waitUntilSuccess(self): | |
30 return self.status.waitUntilSuccess() | |
31 def waitUntilFinished(self): | |
32 return self.status.waitUntilFinished() | |
33 | |
34 def getProperties(self): | |
35 return self.properties | |
36 | |
37 def start(self, builders): | |
38 """This is called by the BuildMaster to actually create and submit | |
39 the BuildRequests.""" | |
40 self.requests = [] | |
41 reqs = [] | |
42 | |
43 # create the requests | |
44 for b in builders: | |
45 req = base.BuildRequest(self.reason, self.source, b.name, | |
46 properties=self.properties) | |
47 reqs.append((b, req)) | |
48 self.requests.append(req) | |
49 d = req.waitUntilFinished() | |
50 d.addCallback(self.requestFinished, req) | |
51 | |
52 # tell our status about them | |
53 req_statuses = [req.status for req in self.requests] | |
54 self.status.setBuildRequestStatuses(req_statuses) | |
55 | |
56 # now submit them | |
57 for b,req in reqs: | |
58 b.submitBuildRequest(req) | |
59 | |
60 def requestFinished(self, buildstatus, req): | |
61 # TODO: this is where individual build status results are aggregated | |
62 # into a BuildSet-wide status. Consider making a rule that says one | |
63 # WARNINGS results in the overall status being WARNINGS too. The | |
64 # current rule is that any FAILURE means FAILURE, otherwise you get | |
65 # SUCCESS. | |
66 self.requests.remove(req) | |
67 results = buildstatus.getResults() | |
68 if results == builder.FAILURE: | |
69 self.status.setResults(results) | |
70 if self.stillHopeful: | |
71 # oh, cruel reality cuts deep. no joy for you. This is the | |
72 # first failure. This flunks the overall BuildSet, so we can | |
73 # notify success watchers that they aren't going to be happy. | |
74 self.stillHopeful = False | |
75 self.status.giveUpHope() | |
76 self.status.notifySuccessWatchers() | |
77 if not self.requests: | |
78 # that was the last build, so we can notify finished watchers. If | |
79 # we haven't failed by now, we can claim success. | |
80 if self.stillHopeful: | |
81 self.status.setResults(builder.SUCCESS) | |
82 self.status.notifySuccessWatchers() | |
83 self.status.notifyFinishedWatchers() | |
84 | |
OLD | NEW |