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

Side by Side Diff: tools/gardening/bin/luci_api.dart

Issue 3005723002: Added ability to find builder-groups (Closed)
Patch Set: Created 3 years, 3 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
OLDNEW
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 'dart:async'; 5 import 'dart:async';
6 6
7 import 'package:gardening/src/luci_api.dart'; 7 import 'package:gardening/src/luci_api.dart';
8 import 'package:gardening/src/luci_services.dart'; 8 import 'package:gardening/src/luci_services.dart';
9 import 'package:gardening/src/logger.dart'; 9 import 'package:gardening/src/logger.dart';
10 import 'package:gardening/src/cache_new.dart'; 10 import 'package:gardening/src/cache_new.dart';
(...skipping 11 matching lines...) Expand all
22 help: "Use this flag to bypass caching. This may be slower.") 22 help: "Use this flag to bypass caching. This may be slower.")
23 ..addFlag("help", 23 ..addFlag("help",
24 negatable: false, 24 negatable: false,
25 help: "Shows information on how to use the luci_api tool.") 25 help: "Shows information on how to use the luci_api tool.")
26 ..addFlag("build-bots", 26 ..addFlag("build-bots",
27 negatable: false, 27 negatable: false,
28 help: "Use this flag to see the primary build bots for --client.") 28 help: "Use this flag to see the primary build bots for --client.")
29 ..addFlag("build-bots-all", 29 ..addFlag("build-bots-all",
30 negatable: false, 30 negatable: false,
31 help: "Use this flag to see all build bots for --client.") 31 help: "Use this flag to see all build bots for --client.")
32 ..addFlag("master",
33 negatable: false,
34 help: "Use this flag to see information about master for --client.")
35 ..addFlag("build-groups",
36 negatable: false,
37 help: "Use this flag to see all builder-groups not -dev, -stable "
38 "or -integration for --client.")
39 ..addFlag("builders-in-group",
40 negatable: false,
41 help: "Use this flag as `--build-bot-details <group>` to see all "
42 "builders (incl. shards) for a build group <group>.")
32 ..addFlag("build-bot-details", 43 ..addFlag("build-bot-details",
33 negatable: false, 44 negatable: false,
34 help: "Use this flag as `--build-bot-details <name>` where " 45 help: "Use this flag as `--build-bot-details <name>` where "
35 "<name> is the name of the build bot, to see details of " 46 "<name> is the name of the build bot, to see details of "
36 "a specific build bot.") 47 "a specific build bot.")
37 ..addFlag("build-details", 48 ..addFlag("build-details",
38 negatable: false, 49 negatable: false,
39 help: "use this option as `--build-details <name> <buildNo>` where " 50 help: "use this option as `--build-details <name> <buildNo>` where "
40 "<name> is the name of the bot and " 51 "<name> is the name of the bot and "
41 "<buildNo> is the number of the build.") 52 "<buildNo> is the number of the build.")
42 ..addFlag("commit-builds", 53 ..addFlag("builds-with-commit",
43 negatable: false, 54 negatable: false,
44 help: "Fetches all builds for a specific commit. Use this flag as " 55 help: "Fetches all builds with a specific commit. Use this flag as "
45 "`--commit-builds <commit-hash>` where the <commit-hash> is the " 56 "`--builds-with-commit <commit-hash>` where the <commit-hash> is "
46 "hash of the commit"); 57 "the hash of the commit");
47 } 58 }
48 59
49 void printHelp(ArgParser parser) { 60 void printHelp(ArgParser parser) {
50 print("This tool calls different pages on Luci and aggregate the information " 61 print("This tool calls different pages on Luci and aggregate the information "
51 "found. Below is stated information about flags and options:"); 62 "found. Below is stated information about flags and options:");
52 print(""); 63 print("");
53 print(parser.usage); 64 print(parser.usage);
54 } 65 }
55 66
56 main(List<String> args) async { 67 main(List<String> args) async {
57 var parser = setupArgs(); 68 var parser = setupArgs();
58 var results = parser.parse(args); 69 var results = parser.parse(args);
59 70
60 if (results["help"]) { 71 if (results["help"]) {
61 printHelp(parser); 72 printHelp(parser);
62 return; 73 return;
63 } 74 }
64 75
65 var luciApi = new LuciApi(); 76 var luciApi = new LuciApi();
66 Logger logger = 77 Logger logger =
67 new StdOutLogger(results['verbose'] ? Level.debug : Level.info); 78 new StdOutLogger(results['verbose'] ? Level.debug : Level.info);
68 CreateCacheFunction createCache = results['no-cache'] 79 CreateCacheFunction createCache = results['no-cache']
69 ? noCache() 80 ? noCache()
70 : initCache(Uri.base.resolve('temp/gardening-cache/'), logger); 81 : initCache(Uri.base.resolve('temp/gardening-cache/'), logger);
71 82
72 if (results["build-bots"]) { 83 if (results["build-bots"]) {
73 await performBuildBotsPrimary(luciApi, createCache, results); 84 await performBuildBotsPrimary(luciApi, createCache, results);
74 } else if (results["build-bots-all"]) { 85 } else if (results["build-bots-all"]) {
75 await performBuildBotsAll(luciApi, createCache, results); 86 await performBuildBotsAll(luciApi, createCache, results);
87 } else if (results["master"]) {
88 await performMaster(luciApi, createCache, results);
89 } else if (results["build-groups"]) {
90 await performBuilderGroups(luciApi, createCache, results);
91 } else if (results["builders-in-group"]) {
92 await performBuildersInGroup(luciApi, createCache, results);
76 } else if (results["build-bot-details"]) { 93 } else if (results["build-bot-details"]) {
77 await performBuildBotDetails(luciApi, createCache, results); 94 await performBuildBotDetails(luciApi, createCache, results);
78 } else if (results["build-details"]) { 95 } else if (results["build-details"]) {
79 await performBuildDetails(luciApi, createCache, results); 96 await performBuildDetails(luciApi, createCache, results);
80 } else if (results["commit-builds"]) { 97 } else if (results["builds-with-commit"]) {
81 await performFindBuildsForCommit(luciApi, createCache, logger, results); 98 await performFindBuildsForCommit(luciApi, createCache, logger, results);
82 } else { 99 } else {
83 printHelp(parser); 100 printHelp(parser);
84 } 101 }
85 102
86 luciApi.close(); 103 luciApi.close();
87 } 104 }
88 105
89 Future performBuildBotsPrimary( 106 Future performBuildBotsPrimary(
90 LuciApi api, CreateCacheFunction createCache, ArgResults results) async { 107 LuciApi api, CreateCacheFunction createCache, ArgResults results) async {
91 var res = await api.getPrimaryBuilders( 108 var res = await getPrimaryBuilders(
92 results['client'], createCache(duration: new Duration(hours: 1))); 109 api, results['client'], createCache(duration: new Duration(hours: 1)));
93 res.fold((ex, stackTrace) { 110 res.fold((ex, stackTrace) {
94 print(ex); 111 print(ex);
95 print(stackTrace); 112 print(stackTrace);
96 }, (bots) => bots.forEach(print)); 113 }, (bots) => bots.forEach(print));
97 } 114 }
98 115
99 Future performBuildBotsAll( 116 Future performBuildBotsAll(
100 LuciApi api, CreateCacheFunction cache, ArgResults results) async { 117 LuciApi api, CreateCacheFunction cache, ArgResults results) async {
101 var res = await api.getAllBuildBots( 118 var res = await getAllBuilders(
102 results['client'], cache(duration: new Duration(hours: 1))); 119 api, results['client'], cache(duration: new Duration(hours: 1)));
103 res.fold((ex, stackTrace) { 120 res.fold((ex, stackTrace) {
104 print(ex); 121 print(ex);
105 print(stackTrace); 122 print(stackTrace);
106 }, (bots) => bots.forEach(print)); 123 }, (bots) => bots.forEach(print));
107 } 124 }
108 125
126 Future performMaster(
127 LuciApi api, CreateCacheFunction cache, ArgResults results) async {
128 var res = await api.getMaster(
129 results['client'], cache(duration: new Duration(minutes: 15)));
130 res.fold((ex, stackTrace) {
131 print(ex);
132 print(stackTrace);
133 }, (res) => print(res));
134 }
135
136 Future performBuilderGroups(
137 LuciApi api, CreateCacheFunction cache, ArgResults results) async {
138 var res = await getBuilderGroups(
139 api, results['client'], cache(duration: new Duration(minutes: 15)));
140 res.fold((ex, stackTrace) {
141 print(ex);
142 print(stackTrace);
143 }, (res) => res.forEach(print));
144 }
145
146 Future performBuildersInGroup(
147 LuciApi api, CreateCacheFunction cache, ArgResults results) async {
148 if (results.rest.length == 0) {
149 print("No argument given for <group>. To see help, use --help");
150 return;
151 }
152
153 var res = await getBuildersInBuilderGroup(api, results['client'],
154 cache(duration: new Duration(minutes: 15)), results.rest[0]);
155 res.fold((ex, stackTrace) {
156 print(ex);
157 print(stackTrace);
158 }, (res) => res.forEach(print));
159 }
160
109 Future performBuildBotDetails( 161 Future performBuildBotDetails(
110 LuciApi api, CreateCacheFunction cache, ArgResults results) async { 162 LuciApi api, CreateCacheFunction cache, ArgResults results) async {
111 if (results.rest.length == 0) { 163 if (results.rest.length == 0) {
112 print("No argument given for <name>. To see help, use --help"); 164 print("No argument given for <name>. To see help, use --help");
113 return; 165 return;
114 } 166 }
115 var result = await api.getBuildBotDetails(results['client'], results.rest[0], 167 var result = await api.getBuildBotDetails(results['client'], results.rest[0],
116 cache(duration: new Duration(minutes: 15))); 168 cache(duration: new Duration(minutes: 15)));
117 result.fold((ex, stackTrace) { 169 result.fold((ex, stackTrace) {
118 print(ex); 170 print(ex);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 print(st); 216 print(st);
165 }, (List<BuildDetail> details) { 217 }, (List<BuildDetail> details) {
166 print("The commit '${results.rest[0]} is used in the following builds:"); 218 print("The commit '${results.rest[0]} is used in the following builds:");
167 details.forEach((detail) { 219 details.forEach((detail) {
168 String url = "https://luci-milo.appspot.com/buildbot/" 220 String url = "https://luci-milo.appspot.com/buildbot/"
169 "${detail.client}/${detail.botName}/${detail.buildNumber}"; 221 "${detail.client}/${detail.botName}/${detail.buildNumber}";
170 print("${detail.botName}: #${detail.buildNumber}\t$url"); 222 print("${detail.botName}: #${detail.buildNumber}\t$url");
171 }); 223 });
172 }); 224 });
173 } 225 }
OLDNEW
« no previous file with comments | « no previous file | tools/gardening/lib/src/luci_api.dart » ('j') | tools/gardening/lib/src/luci_api.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698