blob: 1543258242bcdd992044d27468388bb0609275fe [file] [log] [blame]
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:async';
import 'dart:convert';
import 'package:gcloud/storage.dart';
import 'package:googleapis_auth/auth_io.dart';
/// Fetches la(st )test results from the dart-test-results GCS bucket.
class ResultsBucket {
AuthClient client;
Bucket bucket;
Future<void> initialize() async {
client = await clientViaApplicationDefaultCredentials(scopes: [
final storage = Storage(client, 'dart-ci');
bucket = storage.bucket('dart-test-results');
Future<List<String>> configurationDirectories() => bucket
.list(prefix: 'configuration/master/')
.where((entry) => entry.isDirectory)
.map((entry) =>
Future<List<String>> latestResults(String configurationDirectory) async {
try {
final revision = await bucket
final results = await bucket
return results;
} catch (e) {
print('Error reading results from $configurationDirectory:');
return [];