From 9d348293a99d0b76bfde7a8e450a3df7672dfc42 Mon Sep 17 00:00:00 2001 From: Swift Kim Date: Fri, 10 Dec 2021 14:04:37 +0900 Subject: [PATCH] Update the test recipe and workflow (#293) * Update the test recipe and workflow * Fix recipe * Fix styles Co-authored-by: Hakkyu Kim --- .github/workflows/build.yml | 57 +++++++++++++----------- .github/workflows/integration_test.yml | 25 ++--------- .github/workflows/pull_request_label.yml | 6 +-- tools/commands/check_tidy.py | 6 +-- tools/commands/integration_test.py | 20 ++++++--- tools/recipe.yaml | 39 +++++++++++----- 6 files changed, 85 insertions(+), 68 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9ff17fa17..17b9b3d9d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,36 +11,38 @@ jobs: fetch-depth: 2 - name: Find changed packages run: | - CHANGED_PACKAGES=$(python3 tools/run_command.py plugins --run-on-changed-packages --base-sha $(git rev-parse HEAD^)) + CHANGED_PACKAGES=$(python3 tools/run_command.py plugins \ + --run-on-changed-packages \ + --base-sha=$(git rev-parse HEAD^)) if [[ ! -z $CHANGED_PACKAGES ]]; then echo $CHANGED_PACKAGES - echo "HAS_CHANGED_PACKAGES=true" >> "$GITHUB_ENV" + echo "HAS_CHANGED_PACKAGES=true" >> $GITHUB_ENV fi - name: Install prerequisite packages if: ${{ env.HAS_CHANGED_PACKAGES == 'true' }} run: | - sudo apt-get update + sudo apt update sudo apt install -y \ - acl \ - bridge-utils \ - gettext \ - openvpn \ - libfontconfig1 \ - libglib2.0-0 \ - libjpeg-turbo8 \ - libpixman-1-0 \ - libpng16-16 \ - libsdl1.2debian \ - libsm6 \ - libv4l-0 \ - libx11-xcb1 \ - libxcb-icccm4 \ - libxcb-image0 \ - libxcb-randr0 \ - libxcb-render-util0 \ - libxcb-shape0 \ - libxcb-xfixes0 \ - libxi6 + acl \ + bridge-utils \ + gettext \ + openvpn \ + libfontconfig1 \ + libglib2.0-0 \ + libjpeg-turbo8 \ + libpixman-1-0 \ + libpng16-16 \ + libsdl1.2debian \ + libsm6 \ + libv4l-0 \ + libx11-xcb1 \ + libxcb-icccm4 \ + libxcb-image0 \ + libxcb-randr0 \ + libxcb-render-util0 \ + libxcb-shape0 \ + libxcb-xfixes0 \ + libxi6 - name: Install Tizen Studio if: ${{ env.HAS_CHANGED_PACKAGES == 'true' }} run: | @@ -62,7 +64,10 @@ jobs: run: | export PATH=$PATH:$HOME/tizen-studio/tools/ide/bin tizen certificate -a platform -p platform -f platform - tizen security-profiles add -n platform -a $HOME/tizen-studio-data/keystore/author/platform.p12 -p platform + tizen security-profiles add \ + -n platform \ + -a $HOME/tizen-studio-data/keystore/author/platform.p12 \ + -p platform - name: Install flutter-tizen if: ${{ env.HAS_CHANGED_PACKAGES == 'true' }} uses: actions/checkout@v2 @@ -73,4 +78,6 @@ jobs: if: ${{ env.HAS_CHANGED_PACKAGES == 'true' }} run: | export PATH=`pwd`/flutter-tizen/bin:$PATH - ./tools/run_command.py build --run-on-changed-packages --base-sha $(git rev-parse HEAD^) + ./tools/run_command.py build \ + --run-on-changed-packages \ + --base-sha=$(git rev-parse HEAD^) diff --git a/.github/workflows/integration_test.yml b/.github/workflows/integration_test.yml index 3b787aeef..88a32792e 100644 --- a/.github/workflows/integration_test.yml +++ b/.github/workflows/integration_test.yml @@ -20,7 +20,7 @@ jobs: with: repository: flutter-tizen/flutter-tizen path: flutter-tizen - - name: Run tests for changed plugins + - name: Run tests for changed packages if: ${{ github.event_name == 'pull_request' }} run: | export PATH=`pwd`/flutter-tizen/bin:$PATH @@ -28,28 +28,11 @@ jobs: --recipe ./tools/recipe.yaml \ --generate-emulators \ --run-on-changed-packages \ - --base-sha=$(git rev-parse HEAD^) \ - --exclude wearable_rotary image_picker camera webview_flutter \ - video_player permission_handler geolocator battery connectivity \ - device_info package_info sensors share wifi_info_flutter \ - google_maps_flutter tizen_app_control url_launcher network_info_plus - - name: Run tests for all plugins + --base-sha=$(git rev-parse HEAD^) + - name: Run tests for all packages if: ${{ github.event_name == 'push' }} run: | export PATH=`pwd`/flutter-tizen/bin:$PATH ./tools/run_command.py test \ --recipe ./tools/recipe.yaml \ - --generate-emulators \ - --exclude wearable_rotary image_picker camera webview_flutter \ - video_player permission_handler geolocator battery connectivity \ - device_info package_info sensors share wifi_info_flutter \ - google_maps_flutter tizen_app_control url_launcher network_info_plus - # The following packages are excluded from tests: - # wearable_rotary, image_picker: no tests. - # camera: no supported profiles. - # video_player: test frequently breaks due to memory issue(https://github.com/flutter-tizen/plugins/issues/135). - # permission_handler: permission related test. - # geolocator: test requires console manipulation. - # battery, connectivity, device_info, package_info, sensors, share, wifi_info_flutter: deprecated. - # google_maps_flutter, webview_flutter, url_launcher, network_info_plus: not supported by emulators - # tizen_app_control: test available after Flutter 2.5 migration. + --generate-emulators diff --git a/.github/workflows/pull_request_label.yml b/.github/workflows/pull_request_label.yml index 0e112f97a..8d899d6a5 100644 --- a/.github/workflows/pull_request_label.yml +++ b/.github/workflows/pull_request_label.yml @@ -1,6 +1,6 @@ -name: "Pull Request Labeler" -on: -- pull_request_target +name: Pull Request Labeler + +on: [pull_request_target] jobs: triage: diff --git a/tools/commands/check_tidy.py b/tools/commands/check_tidy.py index 67c388036..4e24f6da5 100755 --- a/tools/commands/check_tidy.py +++ b/tools/commands/check_tidy.py @@ -89,7 +89,8 @@ def report_error(msg, line=None): if line.endswith(' \n') or line.endswith('\t\n'): report_error('trailing whitespace', lineno) if not line.endswith('\n'): - report_error('line ends without NEW LINE character', lineno) + report_error( + 'line ends without NEW LINE character', lineno) if not line.strip(): stats.empty_lines += 1 @@ -105,8 +106,7 @@ def set_subparser(subparsers): parser = subparsers.add_parser( 'tidy', help='Check and update format for C++ files', - usage= - 'run_command.py tidy [-h] [--clang-format PATH] [--update] [--dir PATH]' + usage='run_command.py tidy [-h] [--clang-format PATH] [--update] [--dir PATH]' ) parser.add_argument('--clang-format', metavar='PATH', diff --git a/tools/commands/integration_test.py b/tools/commands/integration_test.py index eed83a41d..513b147af 100755 --- a/tools/commands/integration_test.py +++ b/tools/commands/integration_test.py @@ -35,7 +35,7 @@ class Target: """A Tizen device that can run Flutter applications. - + A target is a Tizen device (either a physical device or an emulator) that can run Flutter applications. Generally targets are connected when physical devices are connected to the host PC either with a cable or wirelessly, and when @@ -57,7 +57,7 @@ def __init__(self, name, platform, id=None): def run_integration_test(self, plugin_name, directory, timeout): """Runs integration test in the given directory. - + Args: plugin_name (str): The name of the testing plugin. directory (str): The path to the directory in which to perform @@ -374,14 +374,16 @@ def set_subparser(subparsers): help='''The recipe file path. A recipe refers to a yaml file that defines a list of target platforms to test for each plugin. Pass this file if you want to select specific target platform for different -plugins. Note that recipe does not select which plugins to test(that is covered -by the --plugins option), it only defines which target platform to test -for certain plugins if those plugins are being tested. +plugins. Every package listed in the recipe file will be recognized by the tool +(same as --plugins option) and those that specify an empty list will be +explicitly excluded (same as --exclude option). If --recipe is used, +--plugins and --exclude options will be ignored. ( plugins: a: [wearable-5.5, tv-6.0] b: [mobile-6.0] c: [wearable-4.0] + d: [] # explicitly excluded )''') parser.add_argument( '--generate-emulators', @@ -512,6 +514,12 @@ def run_integration_test(args): print( f'The recipe file {args.recipe} is not a valid yaml file.') exit(1) + if not all([isinstance(val, list) for val in platforms_per_plugin.values()]): + print('Every package in the recipe file must specify a list.') + exit(1) + args.plugins = list(platforms_per_plugin.keys()) + args.exclude = [item[0] for item in filter( + lambda item: not item[1], platforms_per_plugin.items())] if args.platforms: for platform in args.platforms: @@ -541,7 +549,7 @@ def run_integration_test(args): for testing_plugin in testing_plugins: test_num += 1 print( - f'============= Testing for {testing_plugin} ({test_num}/{total_plugin_num}) =============' + f'============= Testing {testing_plugin} ({test_num}/{total_plugin_num}) =============' ) platforms = args.platforms if testing_plugin in platforms_per_plugin: diff --git a/tools/recipe.yaml b/tools/recipe.yaml index 057b2fd5e..6b8ce717c 100644 --- a/tools/recipe.yaml +++ b/tools/recipe.yaml @@ -1,26 +1,45 @@ plugins: audioplayers: ["wearable-5.5"] battery_plus: ["wearable-5.5"] - camera: [] connectivity_plus: ["wearable-5.5", "tv-6.0"] device_info_plus: ["wearable-5.5", "tv-6.0"] flutter_tts: ["wearable-5.5", "tv-6.0"] - geolocator: ["wearable-5.5"] - google_maps_flutter: [] - image_picker: ["wearable-5.5"] integration_test: ["wearable-5.5", "tv-6.0"] messageport: ["wearable-5.5", "tv-6.0"] - network_info_plus: [] package_info_plus: ["wearable-5.5", "tv-6.0"] path_provider: ["tv-6.0"] - permission_handler: ["wearable-5.5"] sensors_plus: ["wearable-5.5"] share_plus: ["wearable-5.5"] shared_preferences: ["wearable-5.5", "tv-6.0"] sqflite: ["wearable-5.5", "tv-6.0"] - tizen_app_control: ["wearable-5.5", "tv-6.0"] - url_launcher: [] - video_player: ["wearable-5.5"] wakelock: ["wearable-5.5"] - wearable_rotary: ["wearable-5.5"] + + # Not supported by emulators. + camera: [] + google_maps_flutter: [] + network_info_plus: [] + url_launcher: [] webview_flutter: [] + + # No tests. + image_picker: [] + wearable_rotary: [] + + # Permission cannot be granted without manual interaction. + geolocator: [] + permission_handler: [] + + # Only testable with the drive command: https://github.com/flutter-tizen/plugins/issues/272 + tizen_app_control: [] + + # Test frequently breaks due to memory issue: https://github.com/flutter-tizen/plugins/issues/135 + video_player: [] + + # Deprecated. + battery: [] + connectivity: [] + device_info: [] + package_info: [] + sensors: [] + share: [] + wifi_info_flutter: []