Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: tools/gardening/lib/src/bot.dart

Issue 2944653002: Add summary command to bot. (Closed)
Patch Set: Close bot. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/gardening/bin/summary.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 import 'dart:async';
6
7 import 'buildbot_data.dart';
8 import 'buildbot_structures.dart';
9 import 'client.dart';
10 import 'util.dart';
11
12 class Bot {
13 final bool usesLogdog;
14 final BuildbotClient _client;
15
16 /// Instantiates a Bot.
17 ///
18 /// Bots must be [close]d when they aren't needed anymore.
19 Bot({bool logdog = false})
20 : usesLogdog = logdog,
21 _client =
22 logdog ? new LogdogBuildbotClient() : new HttpBuildbotClient();
23
24 /// Reads the build result of [buildUri] and the [previousCount] earlier
25 /// builds.
26 Future<List<BuildResult>> readHistoricResults(BuildUri buildUri,
27 {int previousCount = 0}) {
28 log("Fetching $buildUri and $previousCount previous builds in parallel");
29 var uris = [buildUri];
30 for (int i = 0; i < previousCount; i++) {
31 buildUri = buildUri.prev();
32 uris.add(buildUri);
33 }
34 return readResults(uris);
35 }
36
37 Future<BuildResult> readResult(BuildUri buildUri) {
38 return _client.readResult(buildUri);
39 }
40
41 Future<List<BuildResult>> readResults(List<BuildUri> buildUris) async {
42 var result = <BuildResult>[];
43 int i = 0;
44 const maxParallel = 20;
45 while (i < buildUris.length) {
46 var end = i + maxParallel;
47 if (end > buildUris.length) end = buildUris.length;
48 var parallelChunk = buildUris.sublist(i, end);
49 log("Fetching ${end - i} uris in parallel");
50 result.addAll(await Future.wait(parallelChunk.map(_client.readResult)));
51 i = end + 1;
52 }
53 return result;
54 }
55
56 /// Returns uris for the most recent build of all build groups.
57 List<BuildUri> get mostRecentUris {
58 List<BuildUri> result = [];
59 for (BuildGroup group in buildGroups) {
60 result.addAll(group.createUris(_client.mostRecentBuildNumber));
61 }
62 return result;
63 }
64
65 /// Closes the bot.
66 void close() => _client.close();
67 }
OLDNEW
« no previous file with comments | « tools/gardening/bin/summary.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698