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

Unified Diff: tools/gardening/lib/src/luci_services.dart

Issue 3005723002: Added ability to find builder-groups (Closed)
Patch Set: Created 3 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: tools/gardening/lib/src/luci_services.dart
diff --git a/tools/gardening/lib/src/luci_services.dart b/tools/gardening/lib/src/luci_services.dart
index bf2adbdf57225d169eb730b2d967279aef0eaf2a..d33884c2a65ea89199e8be6039cb5fea040c2cd8 100644
--- a/tools/gardening/lib/src/luci_services.dart
+++ b/tools/gardening/lib/src/luci_services.dart
@@ -8,20 +8,26 @@ import 'logger.dart';
import 'cache_new.dart';
import 'luci_api.dart';
+const UNINTERESTING_BUILDER_SUFFIXES = const [
+ "-dev",
+ "-stable",
+ "-integration"
+];
+
/// Fetches all builds for a given [commit]-hash, by searching the latest
/// [amount] builds.
Future<Try<List<BuildDetail>>> fetchBuildsForCommmit(LuciApi api, Logger logger,
String client, String commit, CreateCacheFunction createCache,
[int amount = 1]) async {
logger.debug("Finding primary bots for client $client");
- var buildBots = await api.getPrimaryBuilders(
- client, createCache(duration: new Duration(minutes: 30)));
+ var buildBots = await getPrimaryBuilders(
+ api, client, createCache(duration: new Duration(minutes: 30)));
var cache = createCache(duration: new Duration(minutes: 30));
- return (await buildBots.bindAsync((List<LuciBuildBot> buildBots) async {
+ return (await buildBots.bindAsync((List<String> buildBots) async {
var buildBotBuilds = new List<List<BuildDetail>>();
for (var buildBot in buildBots) {
- (await api.getBuildBotDetails(client, buildBot.name, cache, amount)).fold(
+ (await api.getBuildBotDetails(client, buildBot, cache, amount)).fold(
(ex, st) {
logger.error("Problem getting results", ex, st);
}, buildBotBuilds.add);
@@ -35,3 +41,63 @@ Future<Try<List<BuildDetail>>> fetchBuildsForCommmit(LuciApi api, Logger logger,
});
});
}
+
+/// [getBuilderGroups] fetches all builder groups not in -dev, -stable and
+/// -integration from CBE.
+Future<Try<List<String>>> getBuilderGroups(
+ LuciApi api, String client, WithCacheFunction withCache) async {
+ var result = await api.getCBEJson(client, withCache);
+ return result.bind((json) {
+ var builders = json["builders"];
+ return builders.keys.fold<Map<String, Object>>({},
+ (Map<String, Object> map, builderKey) {
+ if (UNINTERESTING_BUILDER_SUFFIXES.any((x) => builderKey.contains(x))) {
+ return map;
+ }
+ map[sanitizeCategory(builders[builderKey]["category"])] = true;
+ return map;
+ }).keys;
+ });
+}
+
+/// [getAllBuilders] fetches all builders from CBE.
+Future<Try<List<String>>> getAllBuilders(
+ LuciApi api, String client, WithCacheFunction withCache) async {
+ var result = await api.getCBEJson(client, withCache);
+ return result.bind((json) {
+ return json["builders"].keys;
+ });
+}
+
+/// [getPrimaryBuilders] fetches all primary builders from CBE.
+Future<Try<List<String>>> getPrimaryBuilders(
+ LuciApi api, String client, WithCacheFunction withCache) async {
+ var result = await getAllBuilders(api, client, withCache);
+ return result.bind((builders) {
+ return builders
+ .where((builderKey) =>
+ !UNINTERESTING_BUILDER_SUFFIXES.any((x) => builderKey.contains(x)))
+ .toList();
+ });
+}
+
+/// [getPrimaryBuilders] gets all builders in builder group [builderGroup].
+Future<Try<List<String>>> getBuildersInBuilderGroup(LuciApi api, String client,
+ WithCacheFunction withCache, String builderGroup) async {
+ var result = await api.getCBEJson(client, withCache);
+ return result.bind((json) {
+ var builders = json["builders"];
+ return builders.keys.where((builder) {
+ return sanitizeCategory(builders[builder]["category"]) == builderGroup;
+ });
+ });
+}
+
+/// Strips un-wanted characters from string [category].
+String sanitizeCategory(String category) {
+ // Category name starts with either two or three numbers and
+ // end with |all. Instead of doing any fancy regular-expr,
+ // we just test if third char is a number.
+ return category.substring(
+ category.codeUnitAt(2) <= 64 ? 3 : 2, category.length - 4);
+}

Powered by Google App Engine
This is Rietveld 408576698