diff --git a/.ci/Dockerfile b/.ci/Dockerfile index 13ac087498d1..14000e2032ed 100644 --- a/.ci/Dockerfile +++ b/.ci/Dockerfile @@ -6,7 +6,7 @@ RUN sudo apt-get install -y --no-install-recommends gnupg # Add repo for gcloud sdk and install it RUN echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | \ - sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list + sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list RUN curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | \ sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add - @@ -23,7 +23,21 @@ RUN yes | sdkmanager \ RUN yes | sdkmanager --licenses +# Install formatter. +RUN sudo apt-get install -y clang-format + +# Install xvfb to allow running headless +RUN sudo apt-get install -y xvfb libegl1-mesa +# Install Linux desktop build tool requirements. +RUN sudo apt-get install -y clang cmake ninja-build file pkg-config +# Install necessary libraries. +RUN sudo apt-get install -y libgtk-3-dev libblkid-dev liblzma-dev + # Add repo for Google Chrome and install it RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add - RUN echo 'deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main' | sudo tee /etc/apt/sources.list.d/google-chrome.list RUN sudo apt-get update && sudo apt-get install -y --no-install-recommends google-chrome-stable + +# Make Chrome the default so http: has a handler for url_launcher tests. +RUN sudo apt-get install -y xdg-utils +RUN xdg-settings set default-web-browser google-chrome.desktop diff --git a/.ci/Dockerfile-LinuxDesktop b/.ci/Dockerfile-LegacyChrome similarity index 62% rename from .ci/Dockerfile-LinuxDesktop rename to .ci/Dockerfile-LegacyChrome index 63e4516e26fc..13ac087498d1 100644 --- a/.ci/Dockerfile-LinuxDesktop +++ b/.ci/Dockerfile-LegacyChrome @@ -6,7 +6,7 @@ RUN sudo apt-get install -y --no-install-recommends gnupg # Add repo for gcloud sdk and install it RUN echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | \ - sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list + sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list RUN curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | \ sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add - @@ -15,17 +15,15 @@ RUN sudo apt-get update && sudo apt-get install -y google-cloud-sdk && \ gcloud config set core/disable_usage_reporting true && \ gcloud config set component_manager/disable_update_check true -# Install xvfb to allow running headless -RUN sudo apt-get install -y xvfb libegl1-mesa -# Install Linux desktop build tool requirements. -RUN sudo apt-get install -y clang cmake ninja-build file pkg-config -# Install necessary libraries. -RUN sudo apt-get install -y libgtk-3-dev +RUN yes | sdkmanager \ + "platforms;android-27" \ + "build-tools;27.0.3" \ + "extras;google;m2repository" \ + "extras;android;m2repository" -# Add repo for Google Chrome and install it, for url_launcher tests. +RUN yes | sdkmanager --licenses + +# Add repo for Google Chrome and install it RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add - RUN echo 'deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main' | sudo tee /etc/apt/sources.list.d/google-chrome.list RUN sudo apt-get update && sudo apt-get install -y --no-install-recommends google-chrome-stable -# Make it the default so http: has a handler. -RUN sudo apt-get install -y xdg-utils -RUN xdg-settings set default-web-browser google-chrome.desktop diff --git a/.cirrus.yml b/.cirrus.yml index 924cb63492a0..ea27c88b97e0 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -1,22 +1,23 @@ +# Light-workload tasks. +# These use default machines, with fewer CPUs, to reduce pressure on the +# concurrency limits. task: # don't run on release tags since it creates O(n^2) tasks where n is the number of plugins only_if: $CIRRUS_TAG == '' use_compute_credits: $CIRRUS_USER_COLLABORATOR == 'true' && $CIRRUS_PR == '' container: dockerfile: .ci/Dockerfile - cpu: 8 - memory: 16G env: INTEGRATION_TEST_PATH: "./packages/integration_test" upgrade_script: - flutter channel stable - flutter upgrade - - flutter channel beta - - flutter upgrade - flutter channel master - flutter upgrade + - flutter config --enable-linux-desktop - git fetch origin master matrix: + ### Platform-agnostic tasks ### - name: plugin_tools_tests script: - cd script/tool @@ -27,48 +28,91 @@ task: - flutter channel master - ./script/check_publish.sh - name: format - install_script: - - wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - - - sudo apt-add-repository "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-7 main" - - sudo apt-get update - - sudo apt-get install -y --allow-unauthenticated clang-format-7 - format_script: ./script/incremental_build.sh format --travis --clang-format=clang-format-7 + format_script: ./script/incremental_build.sh format --fail-on-change - name: test env: matrix: CHANNEL: "master" - CHANNEL: "beta" CHANNEL: "stable" test_script: - # TODO(jackson): Allow web plugins once supported on stable - # https://github.com/flutter/flutter/issues/42864 - - if [[ "$CHANNEL" -eq "stable" ]]; then find . | grep _web$ | xargs rm -rf; fi - flutter channel $CHANNEL - ./script/incremental_build.sh test - name: analyze env: matrix: CHANNEL: "master" - CHANNEL: "beta" CHANNEL: "stable" - script: ./script/incremental_build.sh analyze + script: + - flutter channel $CHANNEL + - ./script/incremental_build.sh analyze + ### Android tasks ### - name: build_all_plugins_apk env: matrix: CHANNEL: "master" - CHANNEL: "beta" CHANNEL: "stable" script: - # TODO(jackson): Allow web plugins once supported on stable - # https://github.com/flutter/flutter/issues/42864 - - if [[ "$CHANNEL" -eq "stable" ]]; then find . | grep _web$ | xargs rm -rf; fi - flutter channel $CHANNEL - ./script/build_all_plugins_app.sh apk + ### Web tasks ### + - name: build_all_plugins_web + env: + matrix: + CHANNEL: "master" + CHANNEL: "stable" + script: + - flutter channel $CHANNEL + - ./script/build_all_plugins_app.sh web + - name: build-web-examples + env: + matrix: + CHANNEL: "master" + CHANNEL: "stable" + build_script: + - flutter channel $CHANNEL + - ./script/incremental_build.sh build-examples --web + # TODO: Add driving examples (and move to heavy-workload group). + ### Linux desktop tasks ### + - name: build_all_plugins_linux + env: + matrix: + CHANNEL: "master" + CHANNEL: "stable" + script: + - flutter channel $CHANNEL + - ./script/build_all_plugins_app.sh linux + +# Legacy Dockerfile configuration for web integration tests. +# https://github.com/flutter/web_installers doesn't yet support the current +# stable version of Chrome, so newly-generated Docker images don't work. +# TODO: Merge this task into the "Web tasks" section of the "Light-workload +# tasks" block above once web_installers has been updated to support Chrome 89 +# (which is what the current image generated from .ci/Dockerfile has). +task: + # don't run on release tags since it creates O(n^2) tasks where n is the number of plugins + only_if: $CIRRUS_TAG == '' + use_compute_credits: $CIRRUS_USER_COLLABORATOR == 'true' && $CIRRUS_PR == '' + container: + dockerfile: .ci/Dockerfile-LegacyChrome + env: + INTEGRATION_TEST_PATH: "./packages/integration_test" + upgrade_script: + - flutter channel stable + - flutter upgrade + - flutter channel master + - flutter upgrade + - flutter config --enable-linux-desktop + - git fetch origin master + matrix: - name: integration_web_smoke_test + env: + matrix: + CHANNEL: "master" + CHANNEL: "stable" # Tests integration example test in web. only_if: "changesInclude('.cirrus.yml', 'packages/integration_test/**') || $CIRRUS_PR == ''" install_script: - - flutter config --enable-web + - flutter channel $CHANNEL - git clone https://github.com/flutter/web_installers.git - cd web_installers/packages/web_drivers/ - pub get @@ -77,6 +121,29 @@ task: test_script: - cd $INTEGRATION_TEST_PATH/example/ - flutter drive -v --driver=test_driver/integration_test.dart --target=integration_test/example_test.dart -d web-server --release --browser-name=chrome + +# Heavy-workload tasks. +# These use machines with more CPUs and memory, so will reduce parallelization +# for non-credit runs. +task: + # don't run on release tags since it creates O(n^2) tasks where n is the number of plugins + only_if: $CIRRUS_TAG == '' + use_compute_credits: $CIRRUS_USER_COLLABORATOR == 'true' && $CIRRUS_PR == '' + container: + dockerfile: .ci/Dockerfile + cpu: 8 + memory: 16G + env: + INTEGRATION_TEST_PATH: "./packages/integration_test" + upgrade_script: + - flutter channel stable + - flutter upgrade + - flutter channel master + - flutter upgrade + - flutter config --enable-linux-desktop + - git fetch origin master + matrix: + ### Android tasks ### - name: build-apks+java-test+firebase-test-lab env: matrix: @@ -86,14 +153,10 @@ task: PLUGIN_SHARDING: "--shardIndex 3 --shardCount 4" matrix: CHANNEL: "master" - CHANNEL: "beta" CHANNEL: "stable" MAPS_API_KEY: ENCRYPTED[596a9f6bca436694625ac50851dc5da6b4d34cba8025f7db5bc9465142e8cd44e15f69e3507787753accebfc4910d550] GCLOUD_FIREBASE_TESTLAB_KEY: ENCRYPTED[07586610af1fdfc894e5969f70ef2458341b9b7e9c3b7c4225a663b4a48732b7208a4d91c3b7d45305a6b55fa2a37fc4] script: - # TODO(jackson): Allow web plugins once supported on stable - # https://github.com/flutter/flutter/issues/42864 - - if [[ "$CHANNEL" -eq "stable" ]]; then find . | grep _web$ | xargs rm -rf; fi - flutter channel $CHANNEL # Unsetting CIRRUS_CHANGE_MESSAGE and CIRRUS_COMMIT_MESSAGE as they # might include non-ASCII characters which makes Gradle crash. @@ -115,32 +178,14 @@ task: - fi - export CIRRUS_CHANGE_MESSAGE=`cat /tmp/cirrus_change_message.txt` - export CIRRUS_COMMIT_MESSAGE=`cat /tmp/cirrus_commit_message.txt` - -task: - # don't run on release tags since it creates O(n^2) tasks where n is the number of plugins - only_if: $CIRRUS_TAG == '' - use_compute_credits: $CIRRUS_USER_COLLABORATOR == 'true' && $CIRRUS_PR == '' - container: - dockerfile: .ci/Dockerfile-LinuxDesktop - cpu: 8 - memory: 16G - env: - INTEGRATION_TEST_PATH: "./packages/integration_test" - upgrade_script: - - flutter channel stable - - flutter upgrade - - flutter channel beta - - flutter upgrade - - flutter channel master - - flutter upgrade - - git fetch origin master - matrix: + ### Linux desktop tasks ### - name: build-linux+drive-examples - install_script: - - flutter config --enable-linux-desktop + env: + matrix: + CHANNEL: "master" + CHANNEL: "stable" build_script: - # TODO(stuartmorgan): Include stable once Linux is supported on stable. - - flutter channel master + - flutter channel $CHANNEL - ./script/incremental_build.sh build-examples --linux - xvfb-run ./script/incremental_build.sh drive-examples --linux @@ -148,32 +193,40 @@ task: # Xcode 12 task # don't run on release tags since it creates O(n^2) tasks where n is the number of plugins only_if: $CIRRUS_TAG == '' - use_compute_credits: $CIRRUS_USER_COLLABORATOR == 'true' + use_compute_credits: $CIRRUS_USER_COLLABORATOR == 'true' && $CIRRUS_PR == '' osx_instance: image: big-sur-xcode-12.3 upgrade_script: - sudo gem install cocoapods - flutter channel stable - flutter upgrade - - flutter channel beta - - flutter upgrade - flutter channel master - flutter upgrade + - flutter config --enable-macos-desktop - git fetch origin master create_simulator_script: - xcrun simctl list - xcrun simctl create Flutter-iPhone com.apple.CoreSimulator.SimDeviceType.iPhone-11 com.apple.CoreSimulator.SimRuntime.iOS-14-3 | xargs xcrun simctl boot matrix: + ### Platform-agnostic tasks ### + - name: lint_darwin_plugins + env: + matrix: + PLUGIN_SHARDING: "--shardIndex 0 --shardCount 2" + PLUGIN_SHARDING: "--shardIndex 1 --shardCount 2" + script: + # TODO(jmagman): Lint macOS podspecs but skip any that fail library validation. + - find . -name "*.podspec" | xargs grep -l "osx" | xargs rm + # Skip the dummy podspecs used to placate the tool. + - find . -name "*_web*.podspec" -o -name "*_mac*.podspec" | xargs rm + - ./script/incremental_build.sh podspecs + ### iOS tasks ### - name: build_all_plugins_ipa env: matrix: CHANNEL: "master" - CHANNEL: "beta" CHANNEL: "stable" script: - # TODO(jackson): Allow web plugins once supported on stable - # https://github.com/flutter/flutter/issues/42864 - - if [[ "$CHANNEL" -eq "stable" ]]; then find . | grep _web$ | xargs rm -rf; fi - flutter channel $CHANNEL - ./script/build_all_plugins_app.sh ios --no-codesign - name: build-ipas+drive-examples @@ -187,55 +240,32 @@ task: PLUGIN_SHARDING: "--shardIndex 3 --shardCount 4" matrix: CHANNEL: "master" - CHANNEL: "beta" CHANNEL: "stable" SIMCTL_CHILD_MAPS_API_KEY: ENCRYPTED[596a9f6bca436694625ac50851dc5da6b4d34cba8025f7db5bc9465142e8cd44e15f69e3507787753accebfc4910d550] build_script: - # TODO(jackson): Allow web plugins once supported on stable - # https://github.com/flutter/flutter/issues/42864 - - if [[ "$CHANNEL" -eq "stable" ]]; then find . | grep _web$ | xargs rm -rf; fi - flutter channel $CHANNEL - - flutter upgrade - ./script/incremental_build.sh build-examples --ipa - ./script/incremental_build.sh xctest --skip $PLUGINS_TO_SKIP_XCTESTS --ios-destination "platform=iOS Simulator,name=iPhone 11,OS=latest" # `drive-examples` contains integration tests, which changes the UI of the application. # This UI change sometimes affects `xctest`. # So we run `drive-examples` after `xctest`, changing the order will result ci failure. - ./script/incremental_build.sh drive-examples --ios - - name: lint_darwin_plugins + ### macOS desktop tasks ### + - name: build_all_plugins_macos env: matrix: - PLUGIN_SHARDING: "--shardIndex 0 --shardCount 2" - PLUGIN_SHARDING: "--shardIndex 1 --shardCount 2" - script: - # TODO(jmagman): Lint macOS podspecs but skip any that fail library validation. - - find . -name "*.podspec" | xargs grep -l "osx" | xargs rm - # Skip the dummy podspecs used to placate the tool. - - find . -name "*_web*.podspec" -o -name "*_mac*.podspec" | xargs rm - - ./script/incremental_build.sh podspecs - -task: - # don't run on release tags since it creates O(n^2) tasks where n is the number of plugins - only_if: $CIRRUS_TAG == '' - use_compute_credits: $CIRRUS_USER_COLLABORATOR == 'true' - osx_instance: - image: big-sur-xcode-12.3 - setup_script: - - flutter config --enable-macos-desktop - upgrade_script: - - sudo gem install cocoapods - - flutter channel master - - flutter upgrade - - git fetch origin master - matrix: - - name: build_all_plugins_app + CHANNEL: "master" + CHANNEL: "stable" script: - - flutter channel master + - flutter channel $CHANNEL - ./script/build_all_plugins_app.sh macos - - name: build-apps+drive-examples + - name: build-macos+drive-examples env: + matrix: + CHANNEL: "master" + CHANNEL: "stable" PATH: $PATH:/usr/local/bin build_script: - - flutter channel master + - flutter channel $CHANNEL - ./script/incremental_build.sh build-examples --macos --no-ipa - ./script/incremental_build.sh drive-examples --macos diff --git a/packages/wifi_info_flutter/wifi_info_flutter/ios/Classes/WifiInfoFlutterPlugin.m b/packages/wifi_info_flutter/wifi_info_flutter/ios/Classes/WifiInfoFlutterPlugin.m index 3abdbeef5744..f0811dd92ef6 100644 --- a/packages/wifi_info_flutter/wifi_info_flutter/ios/Classes/WifiInfoFlutterPlugin.m +++ b/packages/wifi_info_flutter/wifi_info_flutter/ios/Classes/WifiInfoFlutterPlugin.m @@ -119,7 +119,9 @@ - (NSString*)convertCLAuthorizationStatusToString:(CLAuthorizationStatus)status case kCLAuthorizationStatusAuthorizedWhenInUse: { return @"authorizedWhenInUse"; } - default: { return @"unknown"; } + default: { + return @"unknown"; + } } } diff --git a/script/build_all_plugins_app.sh b/script/build_all_plugins_app.sh index 0cd6f4888e79..f6b1c166069f 100755 --- a/script/build_all_plugins_app.sh +++ b/script/build_all_plugins_app.sh @@ -14,7 +14,6 @@ readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null && pwd)" readonly REPO_DIR="$(dirname "$SCRIPT_DIR")" source "$SCRIPT_DIR/common.sh" -source "$SCRIPT_DIR/nnbd_plugins.sh" check_changed_packages > /dev/null @@ -26,22 +25,14 @@ check_changed_packages > /dev/null # updating multiple plugins for a breaking change in a common dependency in # cases where using a relaxed version constraint isn't possible. readonly EXCLUDED_PLUGINS_LIST=( - # "file_selector" # currently out of sync with camera - # "flutter_plugin_android_lifecycle" - # "image_picker" - # "local_auth" # flutter_plugin_android_lifecycle conflict "plugin_platform_interface" # This should never be a direct app dependency. + "extension_google_sign_in_as_googleapis_auth" # Transitive dependency issues + # with integration_test. ) # Comma-separated string of the list above readonly EXCLUDED=$(IFS=, ; echo "${EXCLUDED_PLUGINS_LIST[*]}") ALL_EXCLUDED=($EXCLUDED) -# Exclude nnbd plugins from stable, and conflicting plugins otherwise. -if [ "$CHANNEL" == "stable" ]; then - ALL_EXCLUDED=("$EXCLUDED,$EXCLUDED_PLUGINS_FROM_STABLE") -else - ALL_EXCLUDED=("$EXCLUDED,$EXCLUDED_PLUGINS_FOR_NNBD") -fi echo "Excluding the following plugins: $ALL_EXCLUDED" @@ -53,7 +44,14 @@ function error() { failures=0 -for version in "debug" "release"; do +BUILD_MODES=("debug" "release") +# Web doesn't support --debug for builds. +if [[ "$1" == "web" ]]; then + BUILD_MODES=("release") +fi + +for version in "${BUILD_MODES[@]}"; do + echo "Building $version..." (cd $REPO_DIR/all_plugins && flutter build $@ --$version) if [ $? -eq 0 ]; then diff --git a/script/incremental_build.sh b/script/incremental_build.sh index bc41ebd3c70d..826229bced60 100755 --- a/script/incremental_build.sh +++ b/script/incremental_build.sh @@ -5,15 +5,9 @@ readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)" readonly REPO_DIR="$(dirname "$SCRIPT_DIR")" source "$SCRIPT_DIR/common.sh" -source "$SCRIPT_DIR/nnbd_plugins.sh" # Plugins that are excluded from this task. ALL_EXCLUDED=("") -# Exclude nnbd plugins from stable. -if [ "$CHANNEL" == "stable" ]; then - ALL_EXCLUDED=($EXCLUDED_PLUGINS_FROM_STABLE) - echo "Excluding the following plugins because stable does not yet support NNBD: $ALL_EXCLUDED" -fi # Plugins that deliberately use their own analysis_options.yaml. # diff --git a/script/nnbd_plugins.sh b/script/nnbd_plugins.sh deleted file mode 100644 index 5681775cdb3f..000000000000 --- a/script/nnbd_plugins.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/bash - -# This script contains the list of plugins migrated to nnbd -# that should be excluded from testing on Flutter stable until -# null-safe is available on stable. - -readonly NNBD_PLUGINS_LIST=( - "android_alarm_manager" - "android_intent" - "battery" - "camera" - "camera_platform_interface" - "connectivity" - "cross_file" - "device_info" - "espresso" - "file_selector" - "flutter_plugin_android_lifecycle" - "flutter_webview" - "google_maps_flutter" - "google_sign_in" - "image_picker" - "ios_platform_images" - "local_auth" - "path_provider" - "package_info" - "plugin_platform_interface" - "quick_actions" - "sensors" - "share" - "shared_preferences" - "url_launcher" - "video_player" - "webview_flutter" - "wifi_info_flutter" - "in_app_purchase" - "google_maps_flutter_web" # Not yet migrated, but compatible with others -) - -# This list contains the list of plugins that have *not* been -# migrated to nnbd, and conflict with those that have when -# building the all plugins app. This list should be kept empty. - -readonly NON_NNBD_PLUGINS_LIST=( - "extension_google_sign_in_as_googleapis_auth" # Some deps are still clashing -) - -export EXCLUDED_PLUGINS_FROM_STABLE=$(IFS=, ; echo "${NNBD_PLUGINS_LIST[*]}") -export EXCLUDED_PLUGINS_FOR_NNBD=$(IFS=, ; echo "${NON_NNBD_PLUGINS_LIST[*]}") diff --git a/script/tool/lib/src/build_examples_command.dart b/script/tool/lib/src/build_examples_command.dart index 53da9086abaa..bb140bd429c6 100644 --- a/script/tool/lib/src/build_examples_command.dart +++ b/script/tool/lib/src/build_examples_command.dart @@ -19,6 +19,7 @@ class BuildExamplesCommand extends PluginCommand { }) : super(packagesDir, fileSystem, processRunner: processRunner) { argParser.addFlag(kLinux, defaultsTo: false); argParser.addFlag(kMacos, defaultsTo: false); + argParser.addFlag(kWeb, defaultsTo: false); argParser.addFlag(kWindows, defaultsTo: false); argParser.addFlag(kIpa, defaultsTo: io.Platform.isMacOS); argParser.addFlag(kApk); @@ -43,10 +44,10 @@ class BuildExamplesCommand extends PluginCommand { !argResults[kApk] && !argResults[kLinux] && !argResults[kMacos] && + !argResults[kWeb] && !argResults[kWindows]) { - print( - 'None of --linux, --macos, --windows, --apk nor --ipa were specified, ' - 'so not building anything.'); + print('None of --linux, --macos, --web, --windows, --apk, or --ipa were ' + 'specified, so not building anything.'); return; } final String flutterCommand = @@ -84,33 +85,43 @@ class BuildExamplesCommand extends PluginCommand { if (argResults[kMacos]) { print('\nBUILDING macOS for $packageName'); if (isMacOsPlugin(plugin, fileSystem)) { - // TODO(https://github.com/flutter/flutter/issues/46236): - // Builing macos without running flutter pub get first results - // in an error. int exitCode = await processRunner.runAndStream( - flutterCommand, ['pub', 'get'], + flutterCommand, + [ + 'build', + kMacos, + if (enableExperiment.isNotEmpty) + '--enable-experiment=$enableExperiment', + ], workingDir: example); if (exitCode != 0) { failingPackages.add('$packageName (macos)'); - } else { - exitCode = await processRunner.runAndStream( - flutterCommand, - [ - 'build', - kMacos, - if (enableExperiment.isNotEmpty) - '--enable-experiment=$enableExperiment', - ], - workingDir: example); - if (exitCode != 0) { - failingPackages.add('$packageName (macos)'); - } } } else { print('macOS is not supported by this plugin'); } } + if (argResults[kWeb]) { + print('\nBUILDING web for $packageName'); + if (isWebPlugin(plugin, fileSystem)) { + int buildExitCode = await processRunner.runAndStream( + flutterCommand, + [ + 'build', + kWeb, + if (enableExperiment.isNotEmpty) + '--enable-experiment=$enableExperiment', + ], + workingDir: example); + if (buildExitCode != 0) { + failingPackages.add('$packageName (web)'); + } + } else { + print('Web is not supported by this plugin'); + } + } + if (argResults[kWindows]) { print('\nBUILDING Windows for $packageName'); if (isWindowsPlugin(plugin, fileSystem)) { diff --git a/script/tool/lib/src/format_command.dart b/script/tool/lib/src/format_command.dart index ec326b96c1f9..e1c14e04cfec 100644 --- a/script/tool/lib/src/format_command.dart +++ b/script/tool/lib/src/format_command.dart @@ -22,10 +22,10 @@ class FormatCommand extends PluginCommand { FileSystem fileSystem, { ProcessRunner processRunner = const ProcessRunner(), }) : super(packagesDir, fileSystem, processRunner: processRunner) { - argParser.addFlag('travis', hide: true); + argParser.addFlag('fail-on-change', hide: true); argParser.addOption('clang-format', defaultsTo: 'clang-format', - help: 'Path to executable of clang-format v5.'); + help: 'Path to executable of clang-format.'); } @override @@ -46,7 +46,7 @@ class FormatCommand extends PluginCommand { await _formatJava(googleFormatterPath); await _formatCppAndObjectiveC(); - if (argResults['travis']) { + if (argResults['fail-on-change']) { final bool modified = await _didModifyAnything(); if (modified) { throw ToolExit(1); diff --git a/script/tool/test/build_examples_command_test.dart b/script/tool/test/build_examples_command_test.dart index eaf5049dcc02..65417525d710 100644 --- a/script/tool/test/build_examples_command_test.dart +++ b/script/tool/test/build_examples_command_test.dart @@ -201,7 +201,7 @@ void main() { output, orderedEquals([ '\nBUILDING macOS for $packageName', - '\macOS is not supported by this plugin', + 'macOS is not supported by this plugin', '\n\n', 'All builds successful!', ]), @@ -213,6 +213,7 @@ void main() { expect(processRunner.recordedCalls, orderedEquals([])); cleanupPackages(); }); + test('building for macos', () async { createFakePlugin('plugin', withExtraFiles: >[ @@ -244,14 +245,81 @@ void main() { expect( processRunner.recordedCalls, orderedEquals([ - ProcessCall(flutterCommand, ['pub', 'get'], - pluginExampleDirectory.path), ProcessCall(flutterCommand, ['build', 'macos'], pluginExampleDirectory.path), ])); cleanupPackages(); }); + test('building for web with no implementation results in no-op', () async { + createFakePlugin('plugin', withExtraFiles: >[ + ['example', 'test'], + ]); + + final Directory pluginExampleDirectory = + mockPackagesDir.childDirectory('plugin').childDirectory('example'); + + createFakePubspec(pluginExampleDirectory, isFlutter: true); + + final List output = await runCapturingPrint( + runner, ['build-examples', '--no-ipa', '--web']); + final String packageName = + p.relative(pluginExampleDirectory.path, from: mockPackagesDir.path); + + expect( + output, + orderedEquals([ + '\nBUILDING web for $packageName', + 'Web is not supported by this plugin', + '\n\n', + 'All builds successful!', + ]), + ); + + print(processRunner.recordedCalls); + // Output should be empty since running build-examples --macos with no macos + // implementation is a no-op. + expect(processRunner.recordedCalls, orderedEquals([])); + cleanupPackages(); + }); + + test('building for web', () async { + createFakePlugin('plugin', + withExtraFiles: >[ + ['example', 'test'], + ['example', 'web', 'index.html'], + ], + isWebPlugin: true); + + final Directory pluginExampleDirectory = + mockPackagesDir.childDirectory('plugin').childDirectory('example'); + + createFakePubspec(pluginExampleDirectory, isFlutter: true); + + final List output = await runCapturingPrint( + runner, ['build-examples', '--no-ipa', '--web']); + final String packageName = + p.relative(pluginExampleDirectory.path, from: mockPackagesDir.path); + + expect( + output, + orderedEquals([ + '\nBUILDING web for $packageName', + '\n\n', + 'All builds successful!', + ]), + ); + + print(processRunner.recordedCalls); + expect( + processRunner.recordedCalls, + orderedEquals([ + ProcessCall(flutterCommand, ['build', 'web'], + pluginExampleDirectory.path), + ])); + cleanupPackages(); + }); + test( 'building for Windows when plugin is not set up for Windows results in no-op', () async {