OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import 'package:args/args.dart'; | 5 import 'package:args/args.dart'; |
6 import 'package:gardening/src/bot.dart'; | 6 import 'package:gardening/src/bot.dart'; |
| 7 import 'package:gardening/src/buildbot_data.dart'; |
| 8 import 'package:gardening/src/buildbot_structures.dart'; |
7 import 'package:gardening/src/util.dart'; | 9 import 'package:gardening/src/util.dart'; |
8 | 10 |
9 void help(ArgParser argParser) { | 11 void help(ArgParser argParser) { |
10 print('Summarizes the current status of the build bot.'); | 12 print('Summarizes the current status of the build bot.'); |
11 print('Usage: summary [options]'); | 13 print('Usage: summary [options] (<group> ...)'); |
12 print(' where options are:'); | 14 print(" where <group> is (part of) a build bot group, like 'vm-kernel', "); |
| 15 print(" and options are:"); |
13 print(argParser.usage); | 16 print(argParser.usage); |
14 } | 17 } |
15 | 18 |
16 main(List<String> args) async { | 19 main(List<String> args) async { |
17 ArgParser argParser = createArgParser(); | 20 ArgParser argParser = createArgParser(); |
18 ArgResults argResults = argParser.parse(args); | 21 ArgResults argResults = argParser.parse(args); |
19 processArgResults(argResults); | 22 processArgResults(argResults); |
20 if (argResults['help']) { | 23 if (argResults['help']) { |
21 help(argParser); | 24 help(argParser); |
22 return; | 25 return; |
23 } | 26 } |
24 | 27 |
25 var bot = new Bot(logdog: argResults['logdog']); | 28 Bot bot = new Bot(logdog: argResults['logdog']); |
26 var recentUris = bot.mostRecentUris; | 29 List<BuildResult> buildResultsWithoutFailures = <BuildResult>[]; |
27 var results = await bot.readResults(recentUris); | 30 List<BuildResult> buildResultsWithFailures = <BuildResult>[]; |
28 results.forEach((result) { | 31 for (BuildGroup group in buildGroups) { |
29 if (result != null && result.hasFailures) { | 32 if (argResults.rest.isNotEmpty) { |
30 print("${result.buildUri.toUri()} has failures."); | 33 if (!argResults.rest |
| 34 .any((arg) => containsIgnoreCase(group.groupName, arg))) { |
| 35 log('Skipping group $group'); |
| 36 continue; |
| 37 } |
31 } | 38 } |
32 }); | 39 // TODO(johnniwinther): Support reading a partially completed shard from |
| 40 // http, i.e. always use build number `-1`. |
| 41 List<BuildUri> uriList = group.createUris(bot.mostRecentBuildNumber); |
| 42 if (uriList.isEmpty) continue; |
| 43 print('Fetching "${uriList.first}" + ${uriList.length - 1} more ...'); |
| 44 List<BuildResult> results = await bot.readResults(uriList); |
| 45 results.forEach((result) { |
| 46 if (result != null) { |
| 47 if (result.hasFailures) { |
| 48 buildResultsWithFailures.add(result); |
| 49 } else { |
| 50 buildResultsWithoutFailures.add(result); |
| 51 } |
| 52 } |
| 53 }); |
| 54 } |
| 55 print(''); |
| 56 if (buildResultsWithFailures.isEmpty && buildResultsWithoutFailures.isEmpty) { |
| 57 if (argResults.rest.isEmpty) { |
| 58 print('No test steps found.'); |
| 59 } else { |
| 60 print("No test steps found for '${argResults.rest.join("', '")}'."); |
| 61 } |
| 62 } else { |
| 63 int totalCount = |
| 64 buildResultsWithFailures.length + buildResultsWithoutFailures.length; |
| 65 if (argResults.rest.isEmpty) { |
| 66 print('${totalCount} test steps analyzed.'); |
| 67 } else { |
| 68 print("${totalCount} test steps analyzed for build bot groups matching " |
| 69 "'${argResults.rest.join("', '")}'."); |
| 70 } |
| 71 if (LOG) { |
| 72 print(' Found ${buildResultsWithoutFailures.length} ' |
| 73 'test steps without failures:'); |
| 74 for (BuildResult result in buildResultsWithoutFailures) { |
| 75 print(' ${result.buildUri.toUri()}'); |
| 76 } |
| 77 } else { |
| 78 print(' Found ${buildResultsWithoutFailures.length} ' |
| 79 'test steps without failures.'); |
| 80 } |
| 81 if (buildResultsWithFailures.isNotEmpty) { |
| 82 print(' Found ${buildResultsWithFailures.length} ' |
| 83 'test steps with failures:'); |
| 84 for (BuildResult result in buildResultsWithFailures) { |
| 85 print(' ${result.buildUri.toUri()}'); |
| 86 } |
| 87 } |
| 88 } |
| 89 |
33 bot.close(); | 90 bot.close(); |
34 } | 91 } |
OLD | NEW |