diff --git a/.github/_backup/android_alarm_manager_plus.yaml b/.github/_backup/android_alarm_manager_plus.yaml new file mode 100644 index 0000000000..e69de29bb2 diff --git a/.github/_backup/android_intent_plus.yaml b/.github/_backup/android_intent_plus.yaml new file mode 100644 index 0000000000..e69de29bb2 diff --git a/.github/_backup/battery_plus.yaml b/.github/_backup/battery_plus.yaml new file mode 100644 index 0000000000..e69de29bb2 diff --git a/.github/_backup/connectivity_plus.yaml b/.github/_backup/connectivity_plus.yaml new file mode 100644 index 0000000000..e69de29bb2 diff --git a/.github/_backup/device_info_plus.yaml b/.github/_backup/device_info_plus.yaml new file mode 100644 index 0000000000..e69de29bb2 diff --git a/.github/_backup/network_info_plus.yaml b/.github/_backup/network_info_plus.yaml new file mode 100644 index 0000000000..e69de29bb2 diff --git a/.github/_backup/package_info_plus.yaml b/.github/_backup/package_info_plus.yaml new file mode 100644 index 0000000000..e69de29bb2 diff --git a/.github/_backup/sensors_plus.yaml b/.github/_backup/sensors_plus.yaml new file mode 100644 index 0000000000..e69de29bb2 diff --git a/.github/_backup/share_plus.yaml b/.github/_backup/share_plus.yaml new file mode 100644 index 0000000000..a8a205120c --- /dev/null +++ b/.github/_backup/share_plus.yaml @@ -0,0 +1,93 @@ +name: share_plus + +on: + pull_request: + paths: + - "packages/share_plus/**" + - ".github/workflows/share_plus.yaml" + push: + branches: + - main + paths-ignore: + - "docs/**" + - "**.md" + +# defaults: +# run: +# working-directory: packages/share_plus + +env: + PLUS_PLUGIN_SCOPE: "*share_plus*" + PLUS_PLUGIN_SCOPE_EXAMPLE: "*share_plus_example*" + +jobs: + build: + runs-on: ${{matrix.os}} + strategy: + matrix: + os: [macos-latest, ubuntu-latest, windows-latest] + timeout-minutes: 15 + steps: + - uses: actions/checkout@v2.3.4 + with: + fetch-depth: 0 + - name: "Install Flutter" + run: ./.github/workflows/scripts/install-flutter.sh stable + - name: "Install Tools" + run: | + ./.github/workflows/scripts/install-tools.sh + - name: "Build Web Example" + run: | + ./.github/workflows/scripts/build-example.sh web + if: matrix.os == 'ubuntu-latest' + - name: "Build Linux Example" + run: | + ./.github/workflows/scripts/build-example.sh linux + if: matrix.os == 'ubuntu-latest' + - name: "Build Android Example" + run: | + ./.github/workflows/scripts/build-example.sh android + if: matrix.os == 'macos-latest' + - name: "Build Web Example" + run: | + ./.github/workflows/scripts/build-example.sh ios + if: matrix.os == 'macos-latest' + - name: "Build Web Example" + run: | + ./.github/workflows/scripts/build-example.sh macos + if: matrix.os == 'macos-latest' + - name: "Build Web Example" + run: | + ./.github/workflows/scripts/build-example.sh windows + if: matrix.os == 'windows-latest' + + integration_tests: + if: false # currently broken, see issue 220 + runs-on: ${{matrix.os}} + strategy: + matrix: + os: [ubuntu-latest] + timeout-minutes: 15 + steps: + - uses: actions/checkout@v2.3.4 + with: + fetch-depth: 0 + - name: "Install Flutter" + run: ./.github/workflows/scripts/install-flutter.sh stable + - name: "Install Tools" + run: ./.github/workflows/scripts/install-tools.sh + - name: "Setup Linux" + run: | + sudo apt update + sudo apt install -y cmake dbus libblkid-dev libgtk-3-dev liblzma-dev ninja-build pkg-config xvfb clang-format + sudo apt install -y network-manager upower + flutter config --enable-linux-desktop + if: matrix.os == 'ubuntu-latest' + - name: "Bootstrap Workspace" + run: melos bootstrap + - name: "Flutter Integration Test" + run: | + melos run test:mobile_e2e --no-select + melos run test:web_e2e --no-select + melos run test:linux_e2e --no-select + if: matrix.os == 'ubuntu-latest' diff --git a/.github/workflows/all_plugins.yaml b/.github/workflows/all_plugins.yaml index 459db4f615..a04ca9d412 100644 --- a/.github/workflows/all_plugins.yaml +++ b/.github/workflows/all_plugins.yaml @@ -2,153 +2,226 @@ name: all_plugins on: pull_request: + paths-ignore: + - "docs/**" + - "website/**" + - "**.md" push: branches: - main paths-ignore: - "docs/**" + - "website/**" + - "**.md" jobs: analyze: timeout-minutes: 15 runs-on: ubuntu-latest steps: - - name: "Git Checkout" - uses: actions/checkout@v2 + - uses: actions/checkout@v2.3.4 with: fetch-depth: 0 - name: "Install Flutter" - uses: subosito/flutter-action@v1 - with: - flutter-version: "2.2.1" + run: ./.github/workflows/scripts/install-flutter.sh stable - name: "Install Tools" run: | - flutter pub global activate melos - flutter pub global activate tuneup + ./.github/workflows/scripts/install-tools.sh - name: "Bootstrap Workspace" run: melos bootstrap - - name: "Dart Analyze" - run: | - melos run analyze + - name: "Run Analyze" + run: melos run analyze - name: "Pub Check" run: | - melos run lint:pub + melos exec -c 1 --no-private --ignore="*example*" -- \ + pub publish --dry-run - format: + pub_get_check: + timeout-minutes: 15 runs-on: ubuntu-latest - timeout-minutes: 30 steps: - - name: "Git Checkout" - uses: actions/checkout@v2 + - uses: actions/checkout@v2.3.4 with: fetch-depth: 0 - name: "Install Flutter" - uses: subosito/flutter-action@v1 - with: - flutter-version: "2.2.1" + run: ./.github/workflows/scripts/install-flutter.sh stable - name: "Install Tools" run: | - sudo apt update - sudo apt install -y clang-format - flutter pub global activate melos - pub global activate flutter_plugin_tools 0.1.4 - - name: "Bootstrap Workspace" - run: melos bootstrap - - name: "Melos Format" - run: melos run format - - name: "Validate Formatting" + ./.github/workflows/scripts/install-tools.sh + - name: "Flutter Pub Get" run: | - ./.github/workflows/scripts/validate-formatting.sh + melos exec -c 1 --scope="*example*" -- \ + "flutter pub get" - build_examples_dart: - timeout-minutes: 15 + format: runs-on: ubuntu-latest + timeout-minutes: 40 steps: - - name: "Git Checkout" - uses: actions/checkout@v2 + - uses: actions/checkout@v2.3.4 with: fetch-depth: 0 - name: "Install Flutter" - uses: subosito/flutter-action@v1 - with: - flutter-version: "2.2.1" + run: ./.github/workflows/scripts/install-flutter.sh stable - name: "Install Tools" - run: flutter pub global activate melos + run: | + ./.github/workflows/scripts/install-tools.sh + curl -sL https://github.com/google/google-java-format/releases/download/google-java-format-1.3/google-java-format-1.3-all-deps.jar -o $HOME/google-java-format.jar - name: "Bootstrap Workspace" run: melos bootstrap - - name: "Build Example Snapshots" + - name: "Dart" + run: | + melos exec -c 1 -- \ + "flutter format ." + ./.github/workflows/scripts/validate-formatting.sh + - name: "Objective-C" + if: ${{ success() || failure() }} + run: | + melos exec -c 4 --ignore="*platform_interface*" --ignore="*web*" -- \ + find . -maxdepth 3 -name "*.h" -o -name "*.m" -print0 \| xargs -0 clang-format -i --style=Google --verbose + ./.github/workflows/scripts/validate-formatting.sh + - name: "Java" + if: ${{ success() || failure() }} run: | - melos run build:examples:bundle + melos exec -c 4 --ignore="*platform_interface*" --ignore="*web*" -- \ + find . -maxdepth 12 -name "*.java" -print0 \| xargs -0 java -jar $HOME/google-java-format.jar --replace + ./.github/workflows/scripts/validate-formatting.sh - test: + build_examples_dart: runs-on: ${{matrix.os}} strategy: matrix: - os: [macos-latest, ubuntu-latest, windows-latest] - continue-on-error: true - timeout-minutes: 15 + os: [macos-latest] + timeout-minutes: 40 steps: - - name: "Git Checkout" - uses: actions/checkout@v2 + - uses: actions/checkout@v2.3.4 with: fetch-depth: 0 + - name: "Install Flutter" - uses: subosito/flutter-action@v1 + run: ./.github/workflows/scripts/install-flutter.sh stable + + - name: "Install Tools" + run: | + ./.github/workflows/scripts/install-tools.sh + + - name: "Bootstrap Workspace" + run: melos bootstrap + + - name: "Build iOs,Android, and web Examples" + run: melos run build:all + if: matrix.os == 'macos-latest' + + # - name: "Build Linux Examples" + # run: | + # flutter config --enable-linux-desktop + # melos run build:example_linux --no-select + # if: matrix.os == 'ubuntu-latest' + + # - name: "Build windows Examples" + # run: melos run build:example_windows + # if: matrix.os == 'windows-latest' + + # - name: "Build macos Examples" + # run: | + # flutter config --enable-macos-desktop + # melos run build:example_macos --no-select + # if: matrix.os == 'macos-latest' + + test_and_coverage: + runs-on: ubuntu-latest + timeout-minutes: 40 + steps: + - uses: actions/checkout@v2.3.4 with: - flutter-version: "2.2.1" + fetch-depth: 0 + + - name: "Install Flutter" + run: ./.github/workflows/scripts/install-flutter.sh stable + - name: "Install Tools" - run: flutter pub global activate melos + run: ./.github/workflows/scripts/install-tools.sh + - name: "Bootstrap Workspace" run: melos bootstrap + - name: "Flutter Test" - run: | - melos run test - if: matrix.os != 'ubuntu-latest' - - name: "Flutter web Test" - run: | - melos run test:web - if: matrix.os != 'ubuntu-latest' + run: melos run test --no-select + + - name: "Flutter Test - Web" + run: melos run test:web --no-select + - name: "Collect Coverage" - run: | - melos run coverage - if: matrix.os == 'ubuntu-latest' + run: melos run coverage + - name: Upload Coverage uses: codecov/codecov-action@v1 with: token: ${{secrets.CODECOV_TOKEN}} files: packages/*/coverage/lcov.info - if: matrix.os == 'ubuntu-latest' integration_tests: if: false # currently broken, see issue 220 - runs-on: ${{matrix.os}} - strategy: - matrix: - os: [ubuntu-latest] - continue-on-error: true - timeout-minutes: 15 + runs-on: macos-latest + timeout-minutes: 40 steps: - - name: "Git Checkout" - uses: actions/checkout@v2 + - uses: actions/checkout@v2.3.4 with: fetch-depth: 0 + - name: "Install Flutter" - uses: subosito/flutter-action@v1 - with: - channel: dev + run: ./.github/workflows/scripts/install-flutter.sh stable + - name: "Install Tools" - run: | - flutter pub global activate melos - flutter config --enable-linux-desktop + run: ./.github/workflows/scripts/install-tools.sh + + - name: "Bootstrap Workspace" + run: melos bootstrap + + - uses: nanasess/setup-chromedriver@master + with: + chromedriver-version: "94.0.4606.61" + - name: "Setup Linux" run: | sudo apt update sudo apt install -y cmake dbus libblkid-dev libgtk-3-dev liblzma-dev ninja-build pkg-config xvfb clang-format sudo apt install -y network-manager upower if: matrix.os == 'ubuntu-latest' - - name: "Bootstrap Workspace" - run: melos bootstrap - - name: "Flutter Integration Test" + + - name: "Flutter Linux Integration Test" run: | - melos run test:e2e:linux + flutter config --enable-linux-desktop + ./.github/workflows/scripts/drive-example.sh linux if: matrix.os == 'ubuntu-latest' + + - name: "Drive Android Integration Test" + if: matrix.os == 'macos-latest' + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: 30 + arch: x86_64 + target: google_apis + profile: Nexus 5X + script: ./.github/workflows/scripts/drive-example.sh android + + # - name: "Flutter Windows Integration Test" + # run: | + # flutter config --enable-windows-desktop + # ./.github/workflows/scripts/drive-example.sh windows + # if: matrix.os == 'windows-latest' + + - name: "Drive iOS Integration Test" + run: | + ./.github/workflows/scripts/drive-example.sh ios + if: matrix.os == 'macos-latest' + + - name: "Drive MacOS Integration Test" + run: | + flutter config --enable-macos-desktop + ./.github/workflows/scripts/drive-example.sh macos + if: matrix.os == 'macos-latest' + + - name: "Drive Web Integration Test" + run: | + ./.github/workflows/scripts/drive-example.sh web + if: matrix.os == 'linux-latest' diff --git a/.github/workflows/scripts/build-examples.sh b/.github/workflows/scripts/build-examples.sh new file mode 100755 index 0000000000..4f1014d6e2 --- /dev/null +++ b/.github/workflows/scripts/build-examples.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +DEFAULT_TARGET="./test_driver/MELOS_PARENT_PACKAGE_NAME_e2e.dart" + +ACTION=$1 +TARGET_FILE=${2:-$DEFAULT_TARGET} + +melos bootstrap --scope="$PLUS_PLUGIN_SCOPE" + +if [ "$ACTION" == "android" ] +then + melos exec -c 1 --scope="$PLUS_PLUGIN_SCOPE_EXAMPLE" -- \ + flutter build apk $FLUTTER_COMMAND_FLAGS --debug --target="$TARGET_FILE" --dart-define=CI=true --no-android-gradle-daemon + MELOS_EXIT_CODE=$? + pkill dart || true + pkill java || true + exit $MELOS_EXIT_CODE +fi + +if [ "$ACTION" == "ios" ] +then + melos exec -c 1 --scope="$PLUS_PLUGIN_SCOPE_EXAMPLE" -- \ + flutter build ios $FLUTTER_COMMAND_FLAGS --no-codesign --simulator --debug --target="$TARGET_FILE" --dart-define=CI=true + exit +fi + +if [ "$ACTION" == "macos" ] +then + melos exec -c 1 --scope="$PLUS_PLUGIN_SCOPE_EXAMPLE" -- \ + flutter config --enable-macos-desktop && flutter build macos $FLUTTER_COMMAND_FLAGS --debug --target="$TARGET_FILE" --dart-define=CI=true + exit +fi + +if [ "$ACTION" == "linux" ] +then + melos exec -c 1 --scope="$PLUS_PLUGIN_SCOPE_EXAMPLE" -- \ + flutter config --enable-linux-desktop && flutter build linux $FLUTTER_COMMAND_FLAGS --debug --target="$TARGET_FILE" --dart-define=CI=true + exit +fi + +if [ "$ACTION" == "windows" ] +then + melos exec -c 1 --scope="$PLUS_PLUGIN_SCOPE_EXAMPLE" -- \ + flutter config --enable-windows-desktop && flutter build windows $FLUTTER_COMMAND_FLAGS --debug --target="$TARGET_FILE" --dart-define=CI=true + exit +fi + +if [ "$ACTION" == "web" ] +then + melos exec -c 1 --scope="$PLUS_PLUGIN_SCOPE_EXAMPLE" -- \ + flutter build web $FLUTTER_COMMAND_FLAGS --debug --target="$TARGET_FILE" --dart-define=CI=true + exit +fi \ No newline at end of file diff --git a/.github/workflows/scripts/drive-example.sh b/.github/workflows/scripts/drive-example.sh new file mode 100755 index 0000000000..0cbfa69710 --- /dev/null +++ b/.github/workflows/scripts/drive-example.sh @@ -0,0 +1,58 @@ +.#!/bin/bash + +ACTION=$1 + +if [ "$ACTION" == "android" ] +then + # Sleep to allow emulator to settle. + sleep 15 + melos exec -c 1 --fail-fast --scope="$PLUS_PLUGIN_SCOPE_EXAMPLE" --dir-exists=test_driver -- \ + flutter drive $FLUTTER_COMMAND_FLAGS --no-pub --target=./test_driver/MELOS_PARENT_PACKAGE_NAME_e2e.dart --dart-define=CI=true + exit +fi + +if [ "$ACTION" == "ios" ] +then + SIMULATOR="iPhone 11" + # Boot simulator and wait for System app to be ready. + xcrun simctl bootstatus "$SIMULATOR" -b + xcrun simctl logverbose "$SIMULATOR" enable + # Sleep to allow simulator to settle. + sleep 15 + # Uncomment following line to have simulator logs printed out for debugging purposes. + # xcrun simctl spawn booted log stream --predicate 'eventMessage contains "flutter"' & + melos exec -c 1 --fail-fast --scope="$PLUS_PLUGIN_SCOPE_EXAMPLE" --dir-exists=test_driver -- \ + flutter drive $FLUTTER_COMMAND_FLAGS -d \"$SIMULATOR\" --no-pub --target=./test_driver/MELOS_PARENT_PACKAGE_NAME_e2e.dart --dart-define=CI=true + MELOS_EXIT_CODE=$? + xcrun simctl shutdown "$SIMULATOR" + exit $MELOS_EXIT_CODE +fi + +if [ "$ACTION" == "macos" ] +then + melos exec -c 1 --fail-fast --scope="$PLUS_PLUGIN_SCOPE_EXAMPLE" --dir-exists=test_driver -- \ + flutter drive $FLUTTER_COMMAND_FLAGS -d macos --no-pub --target=./test_driver/MELOS_PARENT_PACKAGE_NAME_e2e.dart --dart-define=CI=true + exit +fi + +if [ "$ACTION" == "linux" ] +then + melos exec -c 1 --fail-fast --scope="$PLUS_PLUGIN_SCOPE_EXAMPLE" --dir-exists=test_driver -- \ + flutter drive $FLUTTER_COMMAND_FLAGS -d linux --no-pub --target=./test_driver/MELOS_PARENT_PACKAGE_NAME_e2e.dart --dart-define=CI=true + exit +fi + +if [ "$ACTION" == "windows" ] +then + melos exec -c 1 --fail-fast --scope="$PLUS_PLUGIN_SCOPE_EXAMPLE" --dir-exists=test_driver -- \ + flutter drive $FLUTTER_COMMAND_FLAGS -d windows --no-pub --target=./test_driver/MELOS_PARENT_PACKAGE_NAME_e2e.dart --dart-define=CI=true + exit +fi + +if [ "$ACTION" == "web" ] +then + melos bootstrap --scope="$PLUS_PLUGIN_SCOPE" + chromedriver --port=4444 & melos exec -c 1 --scope="$PLUS_PLUGIN_SCOPE_EXAMPLE" --dir-exists=web -- \ + flutter drive $FLUTTER_COMMAND_FLAGS --no-pub --verbose-system-logs --device-id=web-server --target=./test_driver/MELOS_PARENT_PACKAGE_NAME_e2e.dart --dart-define=CI=true + exit +fi \ No newline at end of file diff --git a/.github/workflows/scripts/install-flutter.sh b/.github/workflows/scripts/install-flutter.sh new file mode 100755 index 0000000000..9ae26bec02 --- /dev/null +++ b/.github/workflows/scripts/install-flutter.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +BRANCH=$1 + +git clone https://github.com/flutter/flutter.git --depth 1 -b $BRANCH _flutter +echo "$GITHUB_WORKSPACE/_flutter/bin" >> $GITHUB_PATH \ No newline at end of file diff --git a/.github/workflows/scripts/install-tools.sh b/.github/workflows/scripts/install-tools.sh new file mode 100755 index 0000000000..1317d4e3f8 --- /dev/null +++ b/.github/workflows/scripts/install-tools.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +flutter config --no-analytics +flutter pub global activate melos +dart pub global run flutter_plugin_tools format +echo "$HOME/.pub-cache/bin" >> $GITHUB_PATH +echo "$GITHUB_WORKSPACE/_flutter/.pub-cache/bin" >> $GITHUB_PATH +echo "$GITHUB_WORKSPACE/_flutter/bin/cache/dart-sdk/bin" >> $GITHUB_PATH \ No newline at end of file diff --git a/melos.yaml b/melos.yaml index 6ebf9be50e..577e4f96ee 100644 --- a/melos.yaml +++ b/melos.yaml @@ -13,9 +13,11 @@ packages: scripts: lint:all: run: melos run analyze && melos run format - description: Run all static analysis checks - # Analyze the project for Dart analysis issues. - # - Requires `pub global activate tuneup`. + description: | + Run all static analysis checks + - Analyze the project for Dart analysis issues. + - Requires `pub global activate tuneup`. + analyze: run: | melos exec -c 5 -- \ @@ -24,75 +26,205 @@ scripts: Run `dart analyze` in all packages. - Note: you can also rely on your IDEs Dart Analysis / Issues window. - # Formats the code of all packages (Java, Objective-C, and Dart). - # - Requires `flutter_plugin_tools` (`pub global activate flutter_plugin_tools`). - # - Requires `git`. - # - Requires `clang-format` (can be installed via Brew on MacOS). - format: pub global run flutter_plugin_tools format - - # Build iOS plugin example apps. - build:examples:ios: > - melos exec -c 1 --scope="*example*" --fail-fast -- \ - flutter build ios --no-codesign - - # Build example bundles. - build:examples:bundle: > - melos exec -c 1 --scope="*example*" --fail-fast -- \ - flutter build bundle - - # Build Android plugin example apps. - build:examples:android: > - melos exec -c 1 --scope="*example*" --fail-fast -- \ - flutter build apk - - # Build any plugin example apps that have MacOS support. - # - Requires `flutter config --enable-macos-desktop` enabled. - # - Requires `flutter channel master && flutter upgrade`. - build:examples:macos: > - melos exec -c 1 --scope="*example*" --dir-exists=macos --fail-fast -- \ - flutter build macos - - # Run standard flutter tests in all packages that have them. - test: > - melos exec -c 1 --fail-fast --dir-exists=test --ignore="*example*" --ignore="*web*" -- \ - flutter test + format: + run: dart pub global run flutter_plugin_tools format + description: | + activate flutter_plugin_tools + - Requires `flutter_plugin_tools` (`pub global activate flutter_plugin_tools`). + - Requires `clang-format` (can be installed via Brew on macOS). - test:web: > - melos exec -c 1 --fail-fast --dir-exists=test --scope="*web*" -- \ - flutter test --platform=chrome + build:all: + run: | + melos bootstrap + melos run build:example_ios_pub --no-select + melos run build:example_android_pub --no-select + melos run build:example_web --no-select + description: Build all example apps + + build:example_ios: + run: | + melos exec -c 6 --fail-fast -- \ + "flutter build ios --no-codesign --no-pub" + description: Build a specific example app for iOS. + select-package: + dir-exists: + - ios + scope: "*example*" + + build:example_ios_pub: + run: | + melos exec -c 6 --fail-fast -- \ + "flutter build ios --no-codesign" + description: | + Build a specific example app for iOS. + melos bootstrap does not generate all files generated by a build that runs + `pub get`, and `flutter drive` does not either, so it is still necessary to + build sometimes without the `--no-pub` switch. Careful: `melos bootstrap` after. + select-package: + dir-exists: + - ios + scope: "*example*" + + build:example_android: + run: | + melos exec -c 6 --fail-fast -- \ + "flutter build apk --no-pub" + description: Build a specific example app for Android. + select-package: + dir-exists: + - android + scope: "*example*" + + build:example_android_pub: + run: | + melos exec -c 6 --fail-fast -- \ + "flutter build apk" + description: Build a specific example app for Android. + select-package: + dir-exists: + - android + scope: "*example*" + + build:example_macos: + run: | + melos exec -c 6 --fail-fast -- \ + "flutter build macos --no-pub" + description: | + Build a specific example app for macOS. + - Requires `flutter channel stable`. + - Requires `flutter config --enable-macos-desktop` set. + select-package: + dir-exists: + - macos + scope: "*example*" + + build:example_linux: + run: | + melos exec -c 6 --fail-fast -- \ + "flutter build linux --no-pub" + description: | + Build a specific example app for web. + - Requires `flutter channel stable`. + - Requires `flutter config --enable-linux-desktop` set. + select-package: + dir-exists: + - linux + scope: "*example*" + + build:example_windows: + run: | + melos exec -c 6 --fail-fast -- \ + "flutter build windows --no-pub" + description: | + Build a specific example app for windows. + - Requires `flutter channel stable`. + - Requires `flutter config --enable-windows-desktop` set. + select-package: + dir-exists: + - windows + scope: "*example*" + + build:example_web: + run: | + melos exec -c 6 --fail-fast -- \ + "flutter build web --no-pub" + description: | + Build a specific example app for web. + - Requires `flutter channel stable`. + select-package: + dir-exists: + - web + scope: "*example*" + + test:all: + run: melos run test --no-select && melos run test:mobile_e2e --no-select + description: Run all tests available on stable channel + + test:unit_all: + run: melos run test --no-select + description: Run all tests available on stable channel + + test: + run: | + melos exec -c 6 --fail-fast -- \ + "flutter test --no-pub" + description: Run `flutter test` for a specific package. + select-package: + dir-exists: + - test + ignore: + - "*web*" + - "*example*" + + test:web: + run: | + melos exec -c 1 --fail-fast -- \ + "flutter test --no-pub --platform=chrome" + description: Run `flutter test --platform=chrome` for a specific '*web' package. + select-package: + dir-exists: + - test + scope: "*web*" + + test:mobile_e2e: + run: | + melos exec -c 1 --fail-fast -- \ + "flutter drive --target=./test_driver/MELOS_PARENT_PACKAGE_NAME_e2e.dart" + description: | + Run all Android or iOS test driver e2e tests in a specific example app. + - Requires an Android emulator or iOS simulator. + select-package: + dir-exists: + - test_driver + scope: "*example*" + + test:web_e2e: + run: | + melos exec -c 1 --fail-fast -- \ + "flutter drive --device-id=web-server --no-pub --target=./test_driver/MELOS_PARENT_PACKAGE_NAME_e2e.dart" + description: | + Run all Web test driver e2e tests in a specific example app. + - Requires `flutter channel stable`. + - Requires chromedriver running on port 4444. + select-package: + dir-exists: + - web + - test_driver + scope: "*example*" + + test:linux_e2e: + run: | + melos exec -c 1 --fail-fast -- \ + "flutter drive -d linux --no-pub --target=./test_driver/MELOS_PARENT_PACKAGE_NAME_e2e.dart" + description: | + Run all Linux test driver e2e tests in a specific example app. + - Requires `flutter channel stable`. + - Requires `flutter config --enable-linux-desktop` set. + select-package: + dir-exists: + - linux + - test_driver + scope: "*example*" + + test:macos_e2e: + run: | + melos exec -c 1 --fail-fast -- \ + "flutter drive -d macos --no-pub --target=./test_driver/MELOS_PARENT_PACKAGE_NAME_e2e.dart" + description: | + Run all MacOS test driver e2e tests in a specific example app. + - Requires `flutter channel stable`. + - Requires `flutter config --enable-macos-desktop` set. + select-package: + dir-exists: + - macos + - test_driver + scope: "*example*" # Coverage coverage: > melos exec -c 1 --fail-fast --dir-exists=test --ignore="*example*" --ignore="*web*" -- \ flutter test --coverage - # Run all test driver e2e tests in the example apps, use this for mobile. - # Will target Android/iOS depending on what emulator/simulator you have running. - test:e2e: > - melos exec -c 1 --fail-fast --scope="*example*" --dir-exists=test_driver -- \ - flutter drive --no-pub --target=./test_driver/MELOS_PARENT_PACKAGE_NAME_e2e.dart - - # Run all web test driver e2e tests in the example apps. - # - Requires `flutter channel master && flutter upgrade`. - # - Requires `flutter config --enable-web` enabled. - test:e2e:web: > - melos exec -c 1 --fail-fast --dir-exists=web --scope="*example*" --dir-exists=test_driver -- \ - flutter drive --release -d chrome --no-pub --verbose-system-logs --browser-name=chrome --target=./test_driver/MELOS_PARENT_PACKAGE_NAME_e2e.dart - - # Run all Linux test driver e2e tests in the example apps. - # - Requires `flutter config --enable-linux-desktop` enabled. - # - Requires `flutter channel dev && flutter upgrade`. - test:e2e:linux: > - melos exec -c 1 --fail-fast --dir-exists=linux --scope="*example*" --dir-exists=test_driver -- \ - xvfb-run -a flutter drive -d linux --no-pub --target=./test_driver/MELOS_PARENT_PACKAGE_NAME_e2e.dart - - # Run all MacOS test driver e2e tests in the example apps. - # - Requires `flutter config --enable-macos-desktop` enabled. - # - Requires `flutter channel master && flutter upgrade`. - test:e2e:macos: > - melos exec -c 1 --fail-fast --dir-exists=macos --scope="*example*" --dir-exists=test_driver -- \ - flutter drive -d macos --no-pub --target=./test_driver/MELOS_PARENT_PACKAGE_NAME_e2e.dart - # Check pubspecs are valid and publishable in each package. lint:pub: > melos exec -c 5 --fail-fast --no-private --ignore="*example*" -- \ @@ -102,14 +234,17 @@ scripts: clean:deep: > git clean -x -d -f -q + # Run all targets generally expected in CI for a full local quality check + qualitycheck: > + melos run clean:deep && melos clean && melos bootstrap && melos run lint:all && melos run build:all && melos run test:all + # Additional cleanup lifecycle script, executed when `melos clean` is ran. postclean: > - melos exec -- \ - rm -rf ./build ./android/.gradle ./ios/.symlinks ./ios/Pods ./android/.idea ./.idea ./.dart-tool/build + melos exec -c 6 -- "flutter clean" dev_dependencies: pedantic: 1.10.0 environment: sdk: ">=2.12.0 <3.0.0" - flutter: ">=1.12.13+hotfix.5" + flutter: ">=1.12.13+hotfix.5 <3.0.0" diff --git a/packages/sensors_plus/sensors_plus/test/sensors_test.dart b/packages/sensors_plus/sensors_plus/test/sensors_test.dart index 2a98c1d9fc..9bbfb603b5 100644 --- a/packages/sensors_plus/sensors_plus/test/sensors_test.dart +++ b/packages/sensors_plus/sensors_plus/test/sensors_test.dart @@ -5,7 +5,8 @@ import 'dart:typed_data'; import 'package:flutter/services.dart'; -import 'package:flutter_test/flutter_test.dart' show TestWidgetsFlutterBinding; +import 'package:flutter_test/flutter_test.dart' + show TestDefaultBinaryMessengerBinding, TestWidgetsFlutterBinding; import 'package:sensors_plus/sensors_plus.dart'; import 'package:test/test.dart'; @@ -72,7 +73,7 @@ void _initializeFakeSensorChannel(String channelName, List sensorData) { ); } - ServicesBinding.instance!.defaultBinaryMessenger + TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger .setMockMessageHandler(channelName, (ByteData? message) async { final methodCall = standardMethod.decodeMethodCall(message); if (methodCall.method == 'listen') { diff --git a/packages/sensors_plus/sensors_plus_platform_interface/test/sensors_plus_platform_interface_test.dart b/packages/sensors_plus/sensors_plus_platform_interface/test/sensors_plus_platform_interface_test.dart index b7bff2dbf4..fb32e1f4ed 100644 --- a/packages/sensors_plus/sensors_plus_platform_interface/test/sensors_plus_platform_interface_test.dart +++ b/packages/sensors_plus/sensors_plus_platform_interface/test/sensors_plus_platform_interface_test.dart @@ -5,7 +5,8 @@ import 'dart:typed_data'; import 'package:flutter/services.dart'; -import 'package:flutter_test/flutter_test.dart' show TestWidgetsFlutterBinding; +import 'package:flutter_test/flutter_test.dart' + show TestDefaultBinaryMessengerBinding, TestWidgetsFlutterBinding; import 'package:sensors_plus_platform_interface/sensors_plus_platform_interface.dart'; import 'package:sensors_plus_platform_interface/src/method_channel_sensors.dart'; import 'package:test/test.dart'; @@ -95,7 +96,7 @@ void _initializeFakeSensorChannel(String channelName, List sensorData) { ); } - ServicesBinding.instance!.defaultBinaryMessenger + TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger .setMockMessageHandler(channelName, (ByteData? message) async { final methodCall = standardMethod.decodeMethodCall(message); if (methodCall.method == 'listen') { diff --git a/packages/sensors_plus/sensors_plus_web/test/sensors_plus_web_test.dart b/packages/sensors_plus/sensors_plus_web/test/sensors_plus_web_test.dart deleted file mode 100644 index bd8bc742bd..0000000000 --- a/packages/sensors_plus/sensors_plus_web/test/sensors_plus_web_test.dart +++ /dev/null @@ -1,5 +0,0 @@ -import 'package:flutter_test/flutter_test.dart'; - -void main() { - test('check', () {}); -} diff --git a/packages/share_plus/share_plus_platform_interface/test/share_plus_platform_interface_test.dart b/packages/share_plus/share_plus_platform_interface/test/share_plus_platform_interface_test.dart index 68de78e751..18cc581af7 100644 --- a/packages/share_plus/share_plus_platform_interface/test/share_plus_platform_interface_test.dart +++ b/packages/share_plus/share_plus_platform_interface/test/share_plus_platform_interface_test.dart @@ -5,7 +5,8 @@ import 'dart:io'; import 'dart:ui'; -import 'package:flutter_test/flutter_test.dart' show TestWidgetsFlutterBinding; +import 'package:flutter_test/flutter_test.dart' + show TestDefaultBinaryMessengerBinding, TestWidgetsFlutterBinding; import 'package:mockito/mockito.dart'; import 'package:share_plus_platform_interface/share_plus_platform_interface.dart'; import 'package:share_plus_platform_interface/method_channel/method_channel_share.dart'; @@ -21,8 +22,9 @@ void main() { setUp(() { mockChannel = MockMethodChannel(); // Re-pipe to mockito for easier verifies. - MethodChannelShare.channel - .setMockMethodCallHandler((MethodCall call) async { + TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger + .setMockMethodCallHandler(MethodChannelShare.channel, + (MethodCall call) async { // The explicit type can be void as the only method call has a return type of void. await mockChannel.invokeMethod(call.method, call.arguments); });