Unverified Commit a228a17c authored by Casey Hillers's avatar Casey Hillers Committed by GitHub

[devicelab] LUCI builder flag (#70702)

parent 26ba1848
...@@ -30,6 +30,12 @@ String localEngine; ...@@ -30,6 +30,12 @@ String localEngine;
/// The path to the engine "src/" directory. /// The path to the engine "src/" directory.
String localEngineSrcPath; String localEngineSrcPath;
/// Name of the LUCI builder this test is currently running on.
///
/// This is only passed on CI runs for Cocoon to be able to uniquely identify
/// this test run.
String luciBuilder;
/// Whether to exit on first test failure. /// Whether to exit on first test failure.
bool exitOnFirstTestFailure; bool exitOnFirstTestFailure;
...@@ -81,9 +87,10 @@ Future<void> main(List<String> rawArgs) async { ...@@ -81,9 +87,10 @@ Future<void> main(List<String> rawArgs) async {
} }
deviceId = args['device-id'] as String; deviceId = args['device-id'] as String;
exitOnFirstTestFailure = args['exit'] as bool;
localEngine = args['local-engine'] as String; localEngine = args['local-engine'] as String;
localEngineSrcPath = args['local-engine-src-path'] as String; localEngineSrcPath = args['local-engine-src-path'] as String;
exitOnFirstTestFailure = args['exit'] as bool; luciBuilder = args['luci-builder'] as String;
serviceAccountTokenFile = args['service-account-token-file'] as String; serviceAccountTokenFile = args['service-account-token-file'] as String;
silent = args['silent'] as bool; silent = args['silent'] as bool;
...@@ -111,7 +118,8 @@ Future<void> _runTasks() async { ...@@ -111,7 +118,8 @@ Future<void> _runTasks() async {
if (serviceAccountTokenFile != null) { if (serviceAccountTokenFile != null) {
final Cocoon cocoon = Cocoon(serviceAccountTokenPath: serviceAccountTokenFile); final Cocoon cocoon = Cocoon(serviceAccountTokenPath: serviceAccountTokenFile);
await cocoon.sendTaskResult(taskName: taskName, result: result); /// Cocoon references LUCI tasks by the [luciBuilder] instead of [taskName].
await cocoon.sendTaskResult(builderName: luciBuilder, result: result);
} }
if (!result.succeeded) { if (!result.succeeded) {
...@@ -338,6 +346,10 @@ final ArgParser _argParser = ArgParser() ...@@ -338,6 +346,10 @@ final ArgParser _argParser = ArgParser()
'locally. Defaults to \$FLUTTER_ENGINE if set, or tries to guess at\n' 'locally. Defaults to \$FLUTTER_ENGINE if set, or tries to guess at\n'
'the location based on the value of the --flutter-root option.', 'the location based on the value of the --flutter-root option.',
) )
..addOption(
'luci-builder',
help: '[Flutter infrastructure] Name of the LUCI builder being run on.'
)
..addFlag( ..addFlag(
'match-host-platform', 'match-host-platform',
defaultsTo: true, defaultsTo: true,
......
...@@ -75,7 +75,7 @@ class Cocoon { ...@@ -75,7 +75,7 @@ class Cocoon {
} }
/// Send [TaskResult] to Cocoon. /// Send [TaskResult] to Cocoon.
Future<void> sendTaskResult({String taskName, TaskResult result}) async { Future<void> sendTaskResult({String builderName, TaskResult result}) async {
// Skip logging on test runs // Skip logging on test runs
Logger.root.level = Level.ALL; Logger.root.level = Level.ALL;
Logger.root.onRecord.listen((LogRecord rec) { Logger.root.onRecord.listen((LogRecord rec) {
...@@ -85,7 +85,7 @@ class Cocoon { ...@@ -85,7 +85,7 @@ class Cocoon {
final Map<String, dynamic> status = <String, dynamic>{ final Map<String, dynamic> status = <String, dynamic>{
'CommitBranch': commitBranch, 'CommitBranch': commitBranch,
'CommitSha': commitSha, 'CommitSha': commitSha,
'TaskName': taskName, 'BuilderName': builderName,
'NewStatus': result.succeeded ? 'Succeeded' : 'Failed', 'NewStatus': result.succeeded ? 'Succeeded' : 'Failed',
}; };
......
...@@ -93,7 +93,7 @@ void main() { ...@@ -93,7 +93,7 @@ void main() {
final TaskResult result = TaskResult.success(<String, dynamic>{}); final TaskResult result = TaskResult.success(<String, dynamic>{});
// This should not throw an error. // This should not throw an error.
await cocoon.sendTaskResult(taskName: 'taskAbc', result: result); await cocoon.sendTaskResult(builderName: 'builderAbc', result: result);
}); });
test('throws client exception on non-200 responses', () async { test('throws client exception on non-200 responses', () async {
...@@ -106,7 +106,7 @@ void main() { ...@@ -106,7 +106,7 @@ void main() {
); );
final TaskResult result = TaskResult.success(<String, dynamic>{}); final TaskResult result = TaskResult.success(<String, dynamic>{});
expect(() => cocoon.sendTaskResult(taskName: 'taskAbc', result: result), throwsA(isA<ClientException>())); expect(() => cocoon.sendTaskResult(builderName: 'builderAbc', result: result), throwsA(isA<ClientException>()));
}); });
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment