diff --git a/README.md b/README.md index 3df37ca8..50474f3e 100644 --- a/README.md +++ b/README.md @@ -169,6 +169,10 @@ To enable testing on a flavor add the following to your sylph.yaml: flavor: ``` +## Flutter version + +Sylph will default to flutter version `v1.12.13+hotfix.8-stable` to execute the tests in AWS but this can be overriden by setting the `FLUTTER_VERSION` environment variable to the version of your choice. + # Configuring a CI Environment for _Sylph_ In addition to running from the command line, _Sylph_ also runs in a CI environment. diff --git a/lib/resources/test_spec.yaml b/lib/resources/test_spec.yaml index d2485b2c..d27a76a9 100644 --- a/lib/resources/test_spec.yaml +++ b/lib/resources/test_spec.yaml @@ -29,7 +29,6 @@ phases: # install flutter - echo "Install flutter" - - FLUTTER_VERSION='v1.12.13+hotfix.8-stable' - >- if [ $DEVICEFARM_DEVICE_PLATFORM_NAME = "Android" ]; then diff --git a/lib/src/resources.dart b/lib/src/resources.dart index 343dba14..ed032b91 100644 --- a/lib/src/resources.dart +++ b/lib/src/resources.dart @@ -29,6 +29,7 @@ const kAWSCredentialsEnvVars = ['AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY']; // substitute names const kAppIdentifier = 'APP_IDENTIFIER'; +const kFlutterVersion = 'FLUTTER_VERSION'; /// Unpacks resources found in package into [tmpDir]. /// Appium template is used to deliver tests. @@ -43,7 +44,8 @@ Future unpackResources(String tmpDir, bool isIosPoolTypeActive, '$tmpDir/$kAppiumTemplateZip'); // unpack Appium test spec - await unpackFile(kAppiumTestSpecName, tmpDir); + final testSpecNameVals = { 'FLUTTER_VERSION': getFlutterVersion() }; + await unpackFile(kAppiumTestSpecName, tmpDir, nameVals: testSpecNameVals); // unpack scripts await unpackScripts(tmpDir); @@ -138,3 +140,9 @@ String getIosAppIdentifier(String appDir) { final iOSConfigStr = fs.file(kIosConfigPath).readAsStringSync(); return RegExp(regExp).firstMatch(iOSConfigStr)[1]; } + +/// Gets the predefined or overriden flutter version to use +String getFlutterVersion() { + const defaultVersion = 'v1.12.13+hotfix.8-stable'; + return platform.environment[kFlutterVersion] ?? defaultVersion; +} \ No newline at end of file