Skip to content

Commit 92a6b78

Browse files
authored
Add an optional id to results and update protobuf (#186)
* Add an optional id to results and update protobuf * Update SDK constraints * dart format
1 parent cb84814 commit 92a6b78

File tree

14 files changed

+318
-452
lines changed

14 files changed

+318
-452
lines changed

.github/workflows/current_results.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
fail-fast: false
2727
matrix:
2828
sdk:
29-
- 3.7.0 # min pubspec SDK
29+
- 3.9.0 # min pubspec SDK
3030
- stable
3131
os:
3232
- ubuntu-latest

current_results/bin/client.dart

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,9 @@ abstract class GrpcCommand extends Command<void> {
3535
final channel = ClientChannel(
3636
globalResults!['host'],
3737
port: int.parse(globalResults!['port']),
38-
options:
39-
globalResults!['insecure'] == true
40-
? const ChannelOptions(credentials: ChannelCredentials.insecure())
41-
: const ChannelOptions(credentials: ChannelCredentials.secure()),
38+
options: globalResults!['insecure'] == true
39+
? const ChannelOptions(credentials: ChannelCredentials.insecure())
40+
: const ChannelOptions(credentials: ChannelCredentials.secure()),
4241
);
4342

4443
final client = QueryClient(channel);
@@ -108,10 +107,9 @@ class ListTestsCommand extends GrpcCommand {
108107

109108
@override
110109
Future<void> runWithClient(QueryClient client) async {
111-
final query =
112-
ListTestsRequest()
113-
..prefix = argResults!['prefix']
114-
..limit = int.parse(argResults!['limit']);
110+
final query = ListTestsRequest()
111+
..prefix = argResults!['prefix']
112+
..limit = int.parse(argResults!['limit']);
115113
final result = await client.listTests(query);
116114
print(jsonEncode(result.toProto3Json()));
117115
}

current_results/lib/protos/query.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ message Result {
8585
int32 time_ms = 6;
8686
repeated string experiments = 7;
8787
string revision = 8;
88+
optional string id = 9;
8889
}
8990

9091
message ListTestsRequest {

current_results/lib/src/bucket.dart

Lines changed: 25 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,23 @@ class ResultsBucket {
1414
ResultsBucket(this._bucket);
1515

1616
Future<List<String>> configurationDirectories() async {
17-
final mainDirectories =
18-
await _bucket
19-
.list(prefix: 'configuration/main/')
20-
.where((entry) => entry.isDirectory)
21-
.map((entry) => entry.name)
22-
.toSet();
17+
final mainDirectories = await _bucket
18+
.list(prefix: 'configuration/main/')
19+
.where((entry) => entry.isDirectory)
20+
.map((entry) => entry.name)
21+
.toSet();
2322
// Once all builders have run once on the main branch, this search
2423
// for results from the master branch can be removed.
25-
final masterDirectories =
26-
await _bucket
27-
.list(prefix: 'configuration/master/')
28-
.where((entry) => entry.isDirectory)
29-
.map((entry) => entry.name)
30-
.where(
31-
(name) =>
32-
!mainDirectories.contains(
33-
name.replaceFirst(
34-
'configuration/master/',
35-
'configuration/main/',
36-
),
37-
),
38-
)
39-
.toList();
24+
final masterDirectories = await _bucket
25+
.list(prefix: 'configuration/master/')
26+
.where((entry) => entry.isDirectory)
27+
.map((entry) => entry.name)
28+
.where(
29+
(name) => !mainDirectories.contains(
30+
name.replaceFirst('configuration/master/', 'configuration/main/'),
31+
),
32+
)
33+
.toList();
4034
return [...mainDirectories, ...masterDirectories];
4135
}
4236

@@ -47,18 +41,16 @@ class ResultsBucket {
4741

4842
Future<List<String>> latestResults(String configurationDirectory) async {
4943
try {
50-
final revision =
51-
await _bucket
52-
.read('${configurationDirectory}latest')
53-
.transform(ascii.decoder)
54-
.transform(LineSplitter())
55-
.single;
56-
final results =
57-
await _bucket
58-
.read('$configurationDirectory$revision/results.json')
59-
.transform(utf8.decoder)
60-
.transform(LineSplitter())
61-
.toList();
44+
final revision = await _bucket
45+
.read('${configurationDirectory}latest')
46+
.transform(ascii.decoder)
47+
.transform(LineSplitter())
48+
.single;
49+
final results = await _bucket
50+
.read('$configurationDirectory$revision/results.json')
51+
.transform(utf8.decoder)
52+
.transform(LineSplitter())
53+
.toList();
6254
return results;
6355
} catch (e) {
6456
print('Error reading results from $configurationDirectory:');

current_results/lib/src/result.dart

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,15 @@ class Result {
4949
uniqueStrings.lookup(string) ??
5050
(uniqueStrings.add(string) ? string : string);
5151

52-
query_api.Result toQueryResult() =>
53-
query_api.Result()
54-
..name = name
55-
..configuration = configuration
56-
..result = result
57-
..timeMs = time.inMilliseconds
58-
..expected = expected
59-
..flaky = flaky
60-
..experiments.addAll(experiments)
61-
..revision = commitHash;
52+
query_api.Result toQueryResult() => query_api.Result()
53+
..name = name
54+
..configuration = configuration
55+
..result = result
56+
..timeMs = time.inMilliseconds
57+
..expected = expected
58+
..flaky = flaky
59+
..experiments.addAll(experiments)
60+
..revision = commitHash;
6261

6362
static query_api.Result toApi(Result result) => result.toQueryResult();
6463

current_results/lib/src/slice.dart

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,9 @@ class Slice {
157157

158158
query_api.GetResultsResponse results(query_api.GetResultsRequest query) {
159159
final limit = min(100000, query.pageSize == 0 ? 100000 : query.pageSize);
160-
final pageStart =
161-
query.pageToken.isEmpty ? null : PageStart.parse(query.pageToken);
160+
final pageStart = query.pageToken.isEmpty
161+
? null
162+
: PageStart.parse(query.pageToken);
162163
final filterTerms = query.filter
163164
.split(',')
164165
.map((s) => s.trim())
@@ -198,14 +199,12 @@ class Slice {
198199
} else {
199200
// Try to find a matching experiment or configuration, or default
200201
// to treating the term as a test prefix.
201-
final matchingExperiments =
202-
_experimentNames
203-
.where((experiment) => experiment.startsWith(filter))
204-
.toSet();
205-
final matchingConfigurations =
206-
_stored.keys
207-
.where((configuration) => configuration.startsWith(filter))
208-
.toSet();
202+
final matchingExperiments = _experimentNames
203+
.where((experiment) => experiment.startsWith(filter))
204+
.toSet();
205+
final matchingConfigurations = _stored.keys
206+
.where((configuration) => configuration.startsWith(filter))
207+
.toSet();
209208
if (matchingExperiments.isNotEmpty) {
210209
experimentNames.addAll(matchingExperiments);
211210
hasExperimentFilter = true;
@@ -248,11 +247,10 @@ class Slice {
248247
);
249248
response.results.addAll(sortedResults.map(Result.toApi));
250249
if (response.results.length == limit) {
251-
response.nextPageToken =
252-
PageStart(
253-
response.results.last.name,
254-
response.results.last.configuration,
255-
).encode();
250+
response.nextPageToken = PageStart(
251+
response.results.last.name,
252+
response.results.last.configuration,
253+
).encode();
256254
break;
257255
}
258256
}
@@ -305,12 +303,11 @@ class Slice {
305303
// Optimization
306304
results.addAll(configurationRange.take(needed - results.length));
307305
} else {
308-
results =
309-
merge(
310-
results,
311-
configurationRange,
312-
(Result result) => result.name,
313-
).take(needed).toList();
306+
results = merge(
307+
results,
308+
configurationRange,
309+
(Result result) => result.name,
310+
).take(needed).toList();
314311
}
315312
}
316313
return results;

current_results/pubspec.lock

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,14 @@ packages:
9797
url: "https://pub.dev"
9898
source: hosted
9999
version: "3.0.6"
100+
dart_style:
101+
dependency: transitive
102+
description:
103+
name: dart_style
104+
sha256: "5b236382b47ee411741447c1f1e111459c941ea1b3f2b540dde54c210a3662af"
105+
url: "https://pub.dev"
106+
source: hosted
107+
version: "3.1.0"
100108
file:
101109
dependency: transitive
102110
description:
@@ -157,18 +165,18 @@ packages:
157165
dependency: "direct main"
158166
description:
159167
name: googleapis_auth
160-
sha256: befd71383a955535060acde8792e7efc11d2fccd03dd1d3ec434e85b68775938
168+
sha256: b81fe352cc4a330b3710d2b7ad258d9bcef6f909bb759b306bf42973a7d046db
161169
url: "https://pub.dev"
162170
source: hosted
163-
version: "1.6.0"
171+
version: "2.0.0"
164172
grpc:
165173
dependency: "direct main"
166174
description:
167175
name: grpc
168-
sha256: "2dde469ddd8bbd7a33a0765da417abe1ad2142813efce3a86c512041294e2b26"
176+
sha256: "807a4da90fc1ba94dccc3a44653d3ff7bcf26818f030259d6a8f9fab405cb880"
169177
url: "https://pub.dev"
170178
source: hosted
171-
version: "4.1.0"
179+
version: "4.3.1"
172180
http:
173181
dependency: transitive
174182
description:
@@ -293,18 +301,18 @@ packages:
293301
dependency: "direct main"
294302
description:
295303
name: protobuf
296-
sha256: "579fe5557eae58e3adca2e999e38f02441d8aa908703854a9e0a0f47fa857731"
304+
sha256: "2fcc8a202ca7ec17dab7c97d6b6d91cf03aa07fe6f65f8afbb6dfa52cc5bd902"
297305
url: "https://pub.dev"
298306
source: hosted
299-
version: "4.1.0"
307+
version: "5.1.0"
300308
protoc_plugin:
301309
dependency: "direct dev"
302310
description:
303311
name: protoc_plugin
304-
sha256: "32fbf4ac1b1a7263440898c9011209c3a13c9063f326ef78da83734e6f992ff3"
312+
sha256: d43d92eeec74bf1da8e790570c1ef7cf00cdc47566ad62e2455f1deaab03a22b
305313
url: "https://pub.dev"
306314
source: hosted
307-
version: "22.3.0"
315+
version: "24.0.0"
308316
pub_semver:
309317
dependency: transitive
310318
description:
@@ -498,4 +506,4 @@ packages:
498506
source: hosted
499507
version: "3.1.3"
500508
sdks:
501-
dart: ">=3.7.0 <4.0.0"
509+
dart: ">=3.9.0 <4.0.0"

current_results/pubspec.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ description: Cache and serve the most recent test results from Dart CI.
33
publish_to: none
44

55
environment:
6-
sdk: ^3.7.0
6+
sdk: ^3.9.0
77

88
dependencies:
99
args: ^2.4.2
1010
collection: ^1.18.0
1111
fixnum: ^1.1.0
1212
gcloud: ^0.8.10
13-
googleapis_auth: ^1.4.1
14-
grpc: ^4.0.1
13+
googleapis_auth: ^2.0.0
14+
grpc: ^4.3.1
1515
pool: ^1.5.1
16-
protobuf: ^4.1.0
16+
protobuf: ^5.1.0
1717
shelf: ^1.4.0
1818

1919
dev_dependencies:
2020
lints: ^5.1.1
21-
protoc_plugin: ^22.0.1
21+
protoc_plugin: ^24.0.0
2222
test: ^1.25.0

current_results/test/filter_test.dart

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,14 @@ void filterTest(
5757
..pageToken = ''
5858
..pageSize = 0,
5959
);
60-
final actualResults = groupBy<query_api.Result, String>(
61-
response.results,
62-
(result) => result.configuration,
63-
).map(
64-
(configuration, results) =>
65-
MapEntry(configuration, results.map((r) => r.name).toSet()),
66-
);
60+
final actualResults =
61+
groupBy<query_api.Result, String>(
62+
response.results,
63+
(result) => result.configuration,
64+
).map(
65+
(configuration, results) =>
66+
MapEntry(configuration, results.map((r) => r.name).toSet()),
67+
);
6768

6869
expect(actualResults, equals(expectedResults));
6970
});

current_results/test/iterable_test.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,9 @@ void main() {
7878
expect((a.iterator..moveNext()).iterable, a.skip(1));
7979
expect([].iterator.iterable, []);
8080
expect(
81-
() =>
82-
a.iterator.iterable
83-
..toList()
84-
..toList(),
81+
() => a.iterator.iterable
82+
..toList()
83+
..toList(),
8584
throwsStateError,
8685
);
8786
expect(a.getRange(1, 2).iterator.iterable.single, 2);

0 commit comments

Comments
 (0)