Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions agent/config.sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,9 @@ auth_token: blahblahblah
# Contact [email protected], [email protected] or [email protected] to
# get a Firebase token.
firebase_flutter_dashboard_token: blahblahblah

# Whether the device tests on Android (true by default)
tests_android: true

# Whether the device tests on iOS (false by default)
tests_ios: false
31 changes: 23 additions & 8 deletions agent/lib/src/commands/ci.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,31 @@ class ContinuousIntegrationCommand extends Command {
try {
results['firebase-connection'] = await checkFirebaseConnection();

Map<String, HealthCheckResult> deviceChecks = await Adb.checkDevices();
results.addAll(deviceChecks);
if (config.testsIos) {
String deviceIds = await eval('ideviceinfo', <String>['-k', 'DeviceClass'], canFail: true);
results['has-healthy-ios-devices'] = deviceIds.contains('iPhone')
? new HealthCheckResult.success('Found an iPhone')
: new HealthCheckResult.failure(
'This agent is configured to test on iOS devices. However, no '
'attached iOS devices were found.',
);
}

if (config.testsAndroid) {
Map<String, HealthCheckResult> deviceChecks = await Adb.checkDevices();
results.addAll(deviceChecks);

int healthyDeviceCount = deviceChecks.values
.where((HealthCheckResult r) => r.succeeded)
.length;
int healthyDeviceCount = deviceChecks.values
.where((HealthCheckResult r) => r.succeeded)
.length;

results['has-healthy-devices'] = healthyDeviceCount > 0
? new HealthCheckResult.success('Found ${deviceChecks.length} healthy devices')
: new HealthCheckResult.failure('No healthy devices found');
results['has-healthy-android-devices'] = healthyDeviceCount > 0
? new HealthCheckResult.success('Found ${deviceChecks.length} healthy devices')
: new HealthCheckResult.failure(
'This agent is configured to test on Android devices. However, no '
'attached Android devices were found.',
);
}

try {
String authStatus = await agent.getAuthenticationStatus();
Expand Down
22 changes: 15 additions & 7 deletions agent/lib/src/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -269,12 +269,14 @@ void cd(dynamic directory) {

class Config {
Config({
this.baseCocoonUrl,
this.agentId,
this.firebaseFlutterDashboardToken,
this.authToken,
this.flutterDirectory,
this.runTaskFile
@required this.baseCocoonUrl,
@required this.agentId,
@required this.firebaseFlutterDashboardToken,
@required this.authToken,
@required this.flutterDirectory,
@required this.runTaskFile,
@required this.testsAndroid,
@required this.testsIos,
});

static void initialize(ArgResults args) {
Expand Down Expand Up @@ -304,7 +306,9 @@ class Config {
firebaseFlutterDashboardToken: firebaseFlutterDashboardToken,
authToken: authToken,
flutterDirectory: flutterDirectory,
runTaskFile: runTaskFile
runTaskFile: runTaskFile,
testsAndroid: agentConfig['tests_android'] ?? true,
testsIos: agentConfig['tests_ios'] ?? false,
);
}

Expand All @@ -314,6 +318,8 @@ class Config {
final String authToken;
final Directory flutterDirectory;
final File runTaskFile;
final bool testsAndroid;
final bool testsIos;

String get adbPath {
String androidHome = Platform.environment['ANDROID_HOME'];
Expand All @@ -338,6 +344,8 @@ agentId: $agentId
flutterDirectory: $flutterDirectory
runTaskFile: $runTaskFile
adbPath: $adbPath
testsAndroid: $testsAndroid
testsIos: $testsIos
'''.trim();
}

Expand Down