diff --git a/.cirrus.yml b/.cirrus.yml index fa8075fe7f3b..95e48872253a 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -1,4 +1,6 @@ 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 @@ -66,6 +68,8 @@ task: - 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' osx_instance: image: mojave-xcode-11.2.1-flutter @@ -97,3 +101,28 @@ task: - flutter channel $CHANNEL - ./script/incremental_build.sh build-examples --ipa - ./script/incremental_build.sh drive-examples + +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: mojave-xcode-11.3-flutter + setup_script: + - pod repo update + - flutter config --enable-macos-desktop + upgrade_script: + - flutter channel master + - flutter upgrade + - git fetch origin master + activate_script: pub global activate flutter_plugin_tools + matrix: + - name: lint_darwin_plugins + script: ./script/lint_darwin_plugins.sh + - name: build-apps+drive-examples + env: + PATH: $PATH:/usr/local/bin + build_script: + - flutter channel master + - ./script/incremental_build.sh build-examples --macos --no-ipa + - ./script/incremental_build.sh drive-examples --macos diff --git a/script/lint_darwin_plugins.sh b/script/lint_darwin_plugins.sh new file mode 100755 index 000000000000..7e749707128c --- /dev/null +++ b/script/lint_darwin_plugins.sh @@ -0,0 +1,88 @@ +#!/bin/bash + +# This script lints and tests iOS and macOS platform code. + +# So that users can run this script from anywhere and it will work as expected. +readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)" +readonly REPO_DIR="$(dirname "$SCRIPT_DIR")" + +source "$SCRIPT_DIR/common.sh" + +function lint_package() { + local package_name="$1" + local package_dir="${REPO_DIR}/packages/$package_name/" + local failure_count=0 + + # These podspecs are temporary multi-platform adoption dummy files. + local skipped_podspecs=( + "url_launcher_web.podspec" + "google_sign_in_web.podspec" + ) + + # TODO: These packages have analyzer warnings. Remove plugins from this list as issues are fixed. + local skip_analysis_packages=( + "camera.podspec" # https://github.com/flutter/flutter/issues/42673 + ) + find "${package_dir}" -type f -name "*\.podspec" | while read podspec; do + local podspecBasename=$(basename "${podspec}") + if [[ "${skipped_podspecs[*]}" =~ "${podspecBasename}" ]]; then + continue + fi + + # TODO: Remove --allow-warnings flag https://github.com/flutter/flutter/issues/41444 + local lint_args=( + lib + lint + "${podspec}" + --allow-warnings + --fail-fast + --silent + ) + if [[ ! "${skip_analysis_packages[*]}" =~ "${podspecBasename}" ]]; then + lint_args+=(--analyze) + echo "Linting and analyzing ${podspecBasename}" + else + echo "Linting ${podspecBasename}" + fi + + # Build as frameworks. + # This will also run any tests set up as a test_spec. See https://blog.cocoapods.org/CocoaPods-1.3.0. + pod "${lint_args[@]}" + if [[ "$?" -ne 0 ]]; then + error "Package ${package_name} has framework issues. Run \"pod lib lint ${podspec} --analyze\" to inspect." + failure_count+=1 + fi + + # Build as libraries. + lint_args+=(--use-libraries) + pod "${lint_args[@]}" + if [[ "$?" -ne 0 ]]; then + error "Package ${package_name} has library issues. Run \"pod lib lint ${podspec} --use-libraries --analyze\" to inspect." + failure_count+=1 + fi + done + + return "${failure_count}" +} + +function lint_packages() { + if [[ ! "$(which pod)" ]]; then + echo "pod not installed. Skipping." + return + fi + + local failure_count=0 + for package_name in "$@"; do + lint_package "${package_name}" + failure_count+="$?" + done + + return "${failure_count}" +} + +# Sets CHANGED_PACKAGE_LIST +check_changed_packages + +if [[ "${#CHANGED_PACKAGE_LIST[@]}" != 0 ]]; then + lint_packages "${CHANGED_PACKAGE_LIST[@]}" +fi