Skip to content

[all] Add macos checks to to CI #1784

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .cirrus.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
88 changes: 88 additions & 0 deletions script/lint_darwin_plugins.sh
Original file line number Diff line number Diff line change
@@ -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