Removes `AVD_CIPD_IDENTIFIER`. This was actually not used in our recipes; `AVD_CIPD_VERSION` is used which is configurable in the Flutter engine builders and the Flutter framework's .ci.yaml, respectively. Also adds a test and updates the readme. Note that updated instructions for how to update the AVD dependency (as mentioned in the README.md change I made here) will be updated by https://github.com/flutter/flutter/pull/152503. Also sets `enforce_test_expected_status` configuration to true such that tests will fail when a test case build status does not match the expected status, e.g. we expect an infra failure but achieve success. Encountered this scenario when writing tests for this PR. --------- CHANGES: --------- Update readme Change-Id: If9e364fa87725a5b08577e3999b002eb22eeb3a5 Add base changes for removing AVD_CIPD_IDENTIFIER Change-Id: I99ef67230b84add4c8ee071867aa04c4dc0aa471 Reviewed-on: https://flutter-review.googlesource.com/c/recipes/+/58740 Commit-Queue: Camille Simon <camillesimon@google.com> Reviewed-by: Zach Anderson <zra@google.com>
diff --git a/infra/config/recipes.cfg b/infra/config/recipes.cfg index 7d5a287..5a60f05 100644 --- a/infra/config/recipes.cfg +++ b/infra/config/recipes.cfg
@@ -43,5 +43,6 @@ "no_docs": true, "project_id": "flutter", "py3_only": true, - "repo_name": "flutter" + "repo_name": "flutter", + "enforce_test_expected_status": true }
diff --git a/recipe_modules/android_virtual_device/README.md b/recipe_modules/android_virtual_device/README.md index 70e7035..d05677c 100644 --- a/recipe_modules/android_virtual_device/README.md +++ b/recipe_modules/android_virtual_device/README.md
@@ -1,9 +1,9 @@ -# Understanding android virtual device in recipes. +# Understanding Android virtual device in recipes. -AVD is how flutter launches emulators as defined by CIPD. +AVD is how Flutter launches emulators as defined by CIPD. * The dependency can be found in https://chrome-infra-packages.appspot.com/p/chromium/tools/android/avd/linux-amd64/ * Available dependencies appear to be automatically uploaded once per week by the chrome team. - * At the time of writing, flutter pins the version of avd used. + * At the time of writing, Flutter pins the version of AVD used. * The "versions" supported for a particular dependency come from the source/tools/android/ave/proto directory of the downloaded asset. There is no other way to know support via the CIPD tooling. -* To update the CIPD dependency change AVD_CIPD_IDENTIFIER in [api.py](api.py) to the Instance ID of the desired dependency version, which you may find by clicking on any of the available dependency instances. \ No newline at end of file +* To learn how to update this dependency in the Flutter engine/framework, visit https://github.com/flutter/flutter/blob/master/docs/platforms/android/New-Android-version.md#update-ci. \ No newline at end of file
diff --git a/recipe_modules/android_virtual_device/api.py b/recipe_modules/android_virtual_device/api.py index dbef891..94166c2 100644 --- a/recipe_modules/android_virtual_device/api.py +++ b/recipe_modules/android_virtual_device/api.py
@@ -5,9 +5,6 @@ from contextlib import contextmanager from recipe_engine import recipe_api -# Supports 19 though API 34. -AVD_CIPD_IDENTIFIER = 'nNnmIzfGCF3wVB1sB14hKaU77TdoTFbq6uq_wXHM-WQC' - RERUN_ATTEMPTS = 3 @@ -63,7 +60,12 @@ env_prefixes(dict): Current environment prefixes variables. avd_root(Path): The root path to install the AVD package. """ - cipd_version = env.get('AVD_CIPD_VERSION', AVD_CIPD_IDENTIFIER) + cipd_version = env.get('AVD_CIPD_VERSION', None) + if cipd_version is None: + raise self.m.step.InfraFailure( + 'avd_cipd_version must be set in .ci.yaml target if depending on' + 'android_virtual_device' + ) with self.m.step.nest('download avd package'): with self.m.context( env=env, env_prefixes=env_prefixes), self.m.depot_tools.on_path():
diff --git a/recipe_modules/android_virtual_device/examples/full.expected/emulator is not started if AVD_CIPD_VERSION not defined.json b/recipe_modules/android_virtual_device/examples/full.expected/emulator is not started if AVD_CIPD_VERSION not defined.json new file mode 100644 index 0000000..33b4b92 --- /dev/null +++ b/recipe_modules/android_virtual_device/examples/full.expected/emulator is not started if AVD_CIPD_VERSION not defined.json
@@ -0,0 +1,8 @@ +[ + { + "failure": { + "humanReason": "avd_cipd_version must be set in .ci.yaml target if depending onandroid_virtual_device" + }, + "name": "$result" + } +] \ No newline at end of file
diff --git a/recipe_modules/android_virtual_device/examples/full.py b/recipe_modules/android_virtual_device/examples/full.py index a1aee67..045000f 100644 --- a/recipe_modules/android_virtual_device/examples/full.py +++ b/recipe_modules/android_virtual_device/examples/full.py
@@ -9,9 +9,10 @@ def RunSteps(api): + should_set_avd_cipd_version = api.properties.get('should_set_avd_cipd_version', True) env = { 'USE_EMULATOR': api.properties.get('use_emulator', False), - 'AVD_CIPD_VERSION': 'TESTVERSIONSTR' + 'AVD_CIPD_VERSION': 'TESTVERSIONSTR' if should_set_avd_cipd_version else None } env_prefixes = {} @@ -31,6 +32,7 @@ 'emulator started', api.properties(use_emulator="true"), api.properties(fake_data='fake data'), + api.properties(should_set_avd_cipd_version=True), api.step_data( 'start avd.Start Android emulator (%s)' % avd_api_version, stdout=api.raw_io.output_text( @@ -51,6 +53,7 @@ 'emulator started and stopped, processes killed', api.properties(use_emulator="true"), api.properties(fake_data='fake data'), + api.properties(should_set_avd_cipd_version=True), api.step_data( 'start avd.Start Android emulator (%s)' % avd_api_version, stdout=api.raw_io.output_text( @@ -66,3 +69,11 @@ ) ), ) + + yield api.test( + 'emulator is not started if AVD_CIPD_VERSION not defined', + api.properties(use_emulator="true"), + api.properties(fake_data='fake data'), + api.properties(should_set_avd_cipd_version=False), + api.expect_status('INFRA_FAILURE'), + )