Make a packages version of the generic plugin recipe
Bug: https://github.com/flutter/flutter/issues/91061
Change-Id: I0685d5bcb097824e2e010a44c2b0bd34925d8032
Reviewed-on: https://flutter-review.googlesource.com/c/recipes/+/18720
Commit-Queue: Stuart Morgan <stuartmorgan@google.com>
Reviewed-by: Casey Hillers <chillers@google.com>
diff --git a/recipes/packages/packages.expected/basic.json b/recipes/packages/packages.expected/basic.json
new file mode 100644
index 0000000..3334baf
--- /dev/null
+++ b/recipes/packages/packages.expected/basic.json
@@ -0,0 +1,437 @@
+[
+ {
+ "cmd": [],
+ "name": "checkout source code"
+ },
+ {
+ "cmd": [],
+ "name": "checkout source code.Checkout flutter/flutter",
+ "~followup_annotations": [
+ "@@@STEP_NEST_LEVEL@1@@@"
+ ]
+ },
+ {
+ "cmd": [
+ "python",
+ "-u",
+ "RECIPE_MODULE[depot_tools::git]/resources/git_setup.py",
+ "--path",
+ "[START_DIR]/flutter",
+ "--url",
+ "https://chromium.googlesource.com/external/github.com/flutter/flutter"
+ ],
+ "name": "checkout source code.Checkout flutter/flutter.git setup",
+ "~followup_annotations": [
+ "@@@STEP_NEST_LEVEL@2@@@"
+ ]
+ },
+ {
+ "cmd": [
+ "git",
+ "fetch",
+ "origin",
+ "None",
+ "--recurse-submodules",
+ "--progress",
+ "--tags"
+ ],
+ "cwd": "[START_DIR]/flutter",
+ "env": {
+ "PATH": "RECIPE_REPO[depot_tools]:<PATH>"
+ },
+ "infra_step": true,
+ "name": "checkout source code.Checkout flutter/flutter.git fetch",
+ "~followup_annotations": [
+ "@@@STEP_NEST_LEVEL@2@@@"
+ ]
+ },
+ {
+ "cmd": [
+ "git",
+ "checkout",
+ "-f",
+ "FETCH_HEAD"
+ ],
+ "cwd": "[START_DIR]/flutter",
+ "infra_step": true,
+ "name": "checkout source code.Checkout flutter/flutter.git checkout",
+ "~followup_annotations": [
+ "@@@STEP_NEST_LEVEL@2@@@"
+ ]
+ },
+ {
+ "cmd": [
+ "git",
+ "rev-parse",
+ "HEAD"
+ ],
+ "cwd": "[START_DIR]/flutter",
+ "infra_step": true,
+ "name": "checkout source code.Checkout flutter/flutter.read revision",
+ "~followup_annotations": [
+ "@@@STEP_NEST_LEVEL@2@@@",
+ "@@@STEP_TEXT@<br/>checked out 'deadbeef'<br/>@@@",
+ "@@@SET_BUILD_PROPERTY@got_revision@\"deadbeef\"@@@"
+ ]
+ },
+ {
+ "cmd": [
+ "git",
+ "clean",
+ "-f",
+ "-d",
+ "-x"
+ ],
+ "cwd": "[START_DIR]/flutter",
+ "infra_step": true,
+ "name": "checkout source code.Checkout flutter/flutter.git clean",
+ "~followup_annotations": [
+ "@@@STEP_NEST_LEVEL@2@@@"
+ ]
+ },
+ {
+ "cmd": [
+ "git",
+ "submodule",
+ "sync"
+ ],
+ "cwd": "[START_DIR]/flutter",
+ "infra_step": true,
+ "name": "checkout source code.Checkout flutter/flutter.submodule sync",
+ "~followup_annotations": [
+ "@@@STEP_NEST_LEVEL@2@@@"
+ ]
+ },
+ {
+ "cmd": [
+ "git",
+ "submodule",
+ "update",
+ "--init",
+ "--recursive"
+ ],
+ "cwd": "[START_DIR]/flutter",
+ "infra_step": true,
+ "name": "checkout source code.Checkout flutter/flutter.submodule update",
+ "~followup_annotations": [
+ "@@@STEP_NEST_LEVEL@2@@@"
+ ]
+ },
+ {
+ "cmd": [],
+ "name": "checkout source code.Checkout flutter/packages",
+ "~followup_annotations": [
+ "@@@STEP_NEST_LEVEL@1@@@"
+ ]
+ },
+ {
+ "cmd": [
+ "python",
+ "-u",
+ "RECIPE_MODULE[depot_tools::git]/resources/git_setup.py",
+ "--path",
+ "[START_DIR]/packages",
+ "--url",
+ "https://github.com/flutter/packages"
+ ],
+ "name": "checkout source code.Checkout flutter/packages.git setup",
+ "~followup_annotations": [
+ "@@@STEP_NEST_LEVEL@2@@@"
+ ]
+ },
+ {
+ "cmd": [
+ "git",
+ "fetch",
+ "origin",
+ "master",
+ "--recurse-submodules",
+ "--progress",
+ "--tags"
+ ],
+ "cwd": "[START_DIR]/packages",
+ "env": {
+ "PATH": "RECIPE_REPO[depot_tools]:<PATH>"
+ },
+ "infra_step": true,
+ "name": "checkout source code.Checkout flutter/packages.git fetch",
+ "~followup_annotations": [
+ "@@@STEP_NEST_LEVEL@2@@@"
+ ]
+ },
+ {
+ "cmd": [
+ "git",
+ "checkout",
+ "-f",
+ "FETCH_HEAD"
+ ],
+ "cwd": "[START_DIR]/packages",
+ "infra_step": true,
+ "name": "checkout source code.Checkout flutter/packages.git checkout",
+ "~followup_annotations": [
+ "@@@STEP_NEST_LEVEL@2@@@"
+ ]
+ },
+ {
+ "cmd": [
+ "git",
+ "rev-parse",
+ "HEAD"
+ ],
+ "cwd": "[START_DIR]/packages",
+ "infra_step": true,
+ "name": "checkout source code.Checkout flutter/packages.read revision",
+ "~followup_annotations": [
+ "@@@STEP_NEST_LEVEL@2@@@",
+ "@@@STEP_TEXT@<br/>checked out 'deadbeef'<br/>@@@",
+ "@@@SET_BUILD_PROPERTY@got_revision@\"deadbeef\"@@@"
+ ]
+ },
+ {
+ "cmd": [
+ "git",
+ "clean",
+ "-f",
+ "-d",
+ "-x"
+ ],
+ "cwd": "[START_DIR]/packages",
+ "infra_step": true,
+ "name": "checkout source code.Checkout flutter/packages.git clean",
+ "~followup_annotations": [
+ "@@@STEP_NEST_LEVEL@2@@@"
+ ]
+ },
+ {
+ "cmd": [
+ "git",
+ "submodule",
+ "sync"
+ ],
+ "cwd": "[START_DIR]/packages",
+ "infra_step": true,
+ "name": "checkout source code.Checkout flutter/packages.submodule sync",
+ "~followup_annotations": [
+ "@@@STEP_NEST_LEVEL@2@@@"
+ ]
+ },
+ {
+ "cmd": [
+ "git",
+ "submodule",
+ "update",
+ "--init",
+ "--recursive"
+ ],
+ "cwd": "[START_DIR]/packages",
+ "infra_step": true,
+ "name": "checkout source code.Checkout flutter/packages.submodule update",
+ "~followup_annotations": [
+ "@@@STEP_NEST_LEVEL@2@@@"
+ ]
+ },
+ {
+ "cmd": [],
+ "name": "Dependencies"
+ },
+ {
+ "cmd": [],
+ "name": "prepare environment"
+ },
+ {
+ "cmd": [
+ "flutter",
+ "config",
+ "--enable-windows-desktop"
+ ],
+ "cwd": "[START_DIR]/flutter",
+ "env": {
+ "DEPOT_TOOLS": "RECIPE_REPO[depot_tools]",
+ "LUCI_BRANCH": "",
+ "LUCI_CI": "True",
+ "LUCI_PR": "",
+ "OS": "linux",
+ "PUB_CACHE": "[START_DIR]/.pub-cache",
+ "SDK_CHECKOUT_PATH": "[START_DIR]/flutter"
+ },
+ "env_prefixes": {
+ "PATH": [
+ "[START_DIR]/flutter/bin",
+ "[START_DIR]/flutter/bin/cache/dart-sdk/bin"
+ ]
+ },
+ "infra_step": true,
+ "name": "prepare environment.flutter config --enable-windows-desktop",
+ "~followup_annotations": [
+ "@@@STEP_NEST_LEVEL@1@@@"
+ ]
+ },
+ {
+ "cmd": [
+ "flutter",
+ "config",
+ "--enable-windows-uwp-desktop"
+ ],
+ "cwd": "[START_DIR]/flutter",
+ "env": {
+ "DEPOT_TOOLS": "RECIPE_REPO[depot_tools]",
+ "LUCI_BRANCH": "",
+ "LUCI_CI": "True",
+ "LUCI_PR": "",
+ "OS": "linux",
+ "PUB_CACHE": "[START_DIR]/.pub-cache",
+ "SDK_CHECKOUT_PATH": "[START_DIR]/flutter"
+ },
+ "env_prefixes": {
+ "PATH": [
+ "[START_DIR]/flutter/bin",
+ "[START_DIR]/flutter/bin/cache/dart-sdk/bin"
+ ]
+ },
+ "infra_step": true,
+ "name": "prepare environment.flutter config --enable-windows-uwp-desktop",
+ "~followup_annotations": [
+ "@@@STEP_NEST_LEVEL@1@@@"
+ ]
+ },
+ {
+ "cmd": [
+ "flutter",
+ "doctor",
+ "-v"
+ ],
+ "cwd": "[START_DIR]/flutter",
+ "env": {
+ "DEPOT_TOOLS": "RECIPE_REPO[depot_tools]",
+ "LUCI_BRANCH": "",
+ "LUCI_CI": "True",
+ "LUCI_PR": "",
+ "OS": "linux",
+ "PUB_CACHE": "[START_DIR]/.pub-cache",
+ "SDK_CHECKOUT_PATH": "[START_DIR]/flutter"
+ },
+ "env_prefixes": {
+ "PATH": [
+ "[START_DIR]/flutter/bin",
+ "[START_DIR]/flutter/bin/cache/dart-sdk/bin"
+ ]
+ },
+ "name": "prepare environment.flutter doctor",
+ "~followup_annotations": [
+ "@@@STEP_NEST_LEVEL@1@@@"
+ ]
+ },
+ {
+ "cmd": [
+ "flutter",
+ "update-packages"
+ ],
+ "cwd": "[START_DIR]/flutter",
+ "env": {
+ "DEPOT_TOOLS": "RECIPE_REPO[depot_tools]",
+ "LUCI_BRANCH": "",
+ "LUCI_CI": "True",
+ "LUCI_PR": "",
+ "OS": "linux",
+ "PUB_CACHE": "[START_DIR]/.pub-cache",
+ "SDK_CHECKOUT_PATH": "[START_DIR]/flutter"
+ },
+ "env_prefixes": {
+ "PATH": [
+ "[START_DIR]/flutter/bin",
+ "[START_DIR]/flutter/bin/cache/dart-sdk/bin"
+ ]
+ },
+ "infra_step": true,
+ "name": "prepare environment.download dependencies",
+ "timeout": 300,
+ "~followup_annotations": [
+ "@@@STEP_NEST_LEVEL@1@@@"
+ ]
+ },
+ {
+ "cmd": [],
+ "name": "read yaml",
+ "~followup_annotations": [
+ "@@@STEP_LOG_LINE@yaml@@@@",
+ "@@@STEP_LOG_END@yaml@@@"
+ ]
+ },
+ {
+ "cmd": [
+ "vpython",
+ "-u",
+ "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+ "--json-output",
+ "/path/to/tmp/json",
+ "copy",
+ "[START_DIR]/packages/.ci/targets/tests.yaml",
+ "/path/to/tmp/"
+ ],
+ "infra_step": true,
+ "name": "read yaml.read",
+ "~followup_annotations": [
+ "@@@STEP_NEST_LEVEL@1@@@",
+ "@@@STEP_LOG_END@tests.yaml@@@"
+ ]
+ },
+ {
+ "cmd": [
+ "vpython",
+ "-u",
+ "RECIPE_MODULE[flutter::yaml]/resources/parse_yaml.py",
+ "--yaml_file",
+ "[START_DIR]/packages/.ci/targets/tests.yaml",
+ "--json_file",
+ "/path/to/tmp/json"
+ ],
+ "infra_step": true,
+ "name": "read yaml.parse",
+ "~followup_annotations": [
+ "@@@STEP_NEST_LEVEL@1@@@",
+ "@@@STEP_LOG_LINE@json.output@{@@@",
+ "@@@STEP_LOG_LINE@json.output@ \"tasks\": [@@@",
+ "@@@STEP_LOG_LINE@json.output@ {@@@",
+ "@@@STEP_LOG_LINE@json.output@ \"name\": \"one\", @@@",
+ "@@@STEP_LOG_LINE@json.output@ \"script\": \"myscript\"@@@",
+ "@@@STEP_LOG_LINE@json.output@ }@@@",
+ "@@@STEP_LOG_LINE@json.output@ ]@@@",
+ "@@@STEP_LOG_LINE@json.output@}@@@",
+ "@@@STEP_LOG_END@json.output@@@"
+ ]
+ },
+ {
+ "cmd": [],
+ "name": "Run package tests"
+ },
+ {
+ "cmd": [
+ "bash",
+ "[START_DIR]/packages/myscript"
+ ],
+ "cwd": "[START_DIR]/packages",
+ "env": {
+ "DEPOT_TOOLS": "RECIPE_REPO[depot_tools]",
+ "LUCI_BRANCH": "",
+ "LUCI_CI": "True",
+ "LUCI_PR": "",
+ "OS": "linux",
+ "PUB_CACHE": "[START_DIR]/.pub-cache",
+ "SDK_CHECKOUT_PATH": "[START_DIR]/flutter"
+ },
+ "env_prefixes": {
+ "PATH": [
+ "[START_DIR]/flutter/bin",
+ "[START_DIR]/flutter/bin/cache/dart-sdk/bin"
+ ]
+ },
+ "name": "Run package tests.one",
+ "~followup_annotations": [
+ "@@@STEP_NEST_LEVEL@1@@@"
+ ]
+ },
+ {
+ "name": "$result"
+ }
+]
\ No newline at end of file
diff --git a/recipes/packages/packages.py b/recipes/packages/packages.py
new file mode 100644
index 0000000..177561a
--- /dev/null
+++ b/recipes/packages/packages.py
@@ -0,0 +1,81 @@
+# Copyright 2020 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+DEPS = [
+ 'flutter/flutter_deps',
+ 'flutter/repo_util',
+ 'flutter/yaml',
+ 'recipe_engine/context',
+ 'recipe_engine/json',
+ 'recipe_engine/path',
+ 'recipe_engine/properties',
+ 'recipe_engine/step',
+]
+
+
+def RunSteps(api):
+ """Recipe to run flutter package tests."""
+ packages_checkout_path = api.path['start_dir'].join('packages')
+ flutter_checkout_path = api.path['start_dir'].join('flutter')
+ channel = api.properties.get('channel')
+ with api.step.nest('checkout source code'):
+ # Check out flutter ToT from master.
+ api.repo_util.checkout(
+ 'flutter',
+ checkout_path=flutter_checkout_path,
+ ref='refs/heads/%s' % channel,
+ )
+ api.repo_util.checkout(
+ 'packages',
+ checkout_path=packages_checkout_path,
+ url=api.properties.get('git_url'),
+ ref=api.properties.get('git_ref')
+ )
+ env, env_prefixes = api.repo_util.flutter_environment(flutter_checkout_path)
+ with api.step.nest('Dependencies'):
+ deps = api.properties.get('dependencies', [])
+ api.flutter_deps.required_deps(env, env_prefixes, deps)
+
+ with api.context(env=env, env_prefixes=env_prefixes,
+ cwd=flutter_checkout_path):
+ with api.step.nest('prepare environment'):
+ config_flag = '--enable-windows-uwp-desktop' if api.properties.get(
+ 'uwp'
+ ) else ''
+ api.step(
+ 'flutter config --enable-windows-desktop',
+ ['flutter', 'config', '--enable-windows-desktop'],
+ infra_step=True,
+ )
+ api.step(
+ 'flutter config --enable-windows-uwp-desktop',
+ ['flutter', 'config', '--enable-windows-uwp-desktop'],
+ infra_step=True,
+ )
+ api.step('flutter doctor', ['flutter', 'doctor', '-v'])
+ # Fail fast on dependencies problem.
+ timeout_secs = 300
+ api.step(
+ 'download dependencies', ['flutter', 'update-packages'],
+ infra_step=True,
+ timeout=timeout_secs
+ )
+ tests_yaml_path = packages_checkout_path.join(
+ '.ci', 'targets', api.properties.get('target_file', 'tests.yaml')
+ )
+ result = api.yaml.read('read yaml', tests_yaml_path, api.json.output())
+ with api.context(env=env, env_prefixes=env_prefixes,
+ cwd=packages_checkout_path):
+ with api.step.nest('Run package tests'):
+ for task in result.json.output['tasks']:
+ script_path = packages_checkout_path.join(task['script'])
+ api.step(task['name'], cmd=['bash', script_path])
+
+
+def GenTests(api):
+ tasks_dict = {'tasks': [{'name': 'one', 'script': 'myscript'}]}
+ yield api.test(
+ 'basic', api.repo_util.flutter_environment_data(),
+ api.step_data('read yaml.parse', api.json.output(tasks_dict))
+ )