Make sure test reporter prints out stderr, and disables Bigquery for non-contributors (#29073)
* print stderr to stderr, no bq if not contributor
* let test continue of bigquery fails
diff --git a/dev/bots/test.dart b/dev/bots/test.dart
index 1a8284b..754ad71 100644
--- a/dev/bots/test.dart
+++ b/dev/bots/test.dart
@@ -148,17 +148,24 @@
Future<bq.BigqueryApi> _getBigqueryApi() async {
// TODO(dnfield): How will we do this on LUCI?
final String privateKey = Platform.environment['GCLOUD_SERVICE_ACCOUNT_KEY'];
- if (privateKey == null || privateKey.isEmpty) {
+ // If we're on Cirrus and a non-collaborator is doing this, we can't get the key.
+ if (privateKey == null || privateKey.isEmpty || privateKey.startsWith('ENCRYPTED[')) {
return null;
}
- final auth.ServiceAccountCredentials accountCredentials = auth.ServiceAccountCredentials( //.fromJson(credentials);
- 'flutter-ci-test-reporter@flutter-infra.iam.gserviceaccount.com',
- auth.ClientId.serviceAccount('114390419920880060881.apps.googleusercontent.com'),
- '-----BEGIN PRIVATE KEY-----\n$privateKey\n-----END PRIVATE KEY-----\n',
- );
- final List<String> scopes = <String>[bq.BigqueryApi.BigqueryInsertdataScope];
- final http.Client client = await auth.clientViaServiceAccount(accountCredentials, scopes);
- return bq.BigqueryApi(client);
+ try {
+ final auth.ServiceAccountCredentials accountCredentials = auth.ServiceAccountCredentials( //.fromJson(credentials);
+ 'flutter-ci-test-reporter@flutter-infra.iam.gserviceaccount.com',
+ auth.ClientId.serviceAccount('114390419920880060881.apps.googleusercontent.com'),
+ '-----BEGIN PRIVATE KEY-----\n$privateKey\n-----END PRIVATE KEY-----\n',
+ );
+ final List<String> scopes = <String>[bq.BigqueryApi.BigqueryInsertdataScope];
+ final http.Client client = await auth.clientViaServiceAccount(accountCredentials, scopes);
+ return bq.BigqueryApi(client);
+ } catch (e) {
+ print('Failed to get BigQuery API client.');
+ print(e);
+ return null;
+ }
}
Future<void> _runToolTests() async {