From 963022223088fb2ef463d5f0b9dee64549fe55f3 Mon Sep 17 00:00:00 2001 From: Andrew Brogdon Date: Tue, 21 Jan 2020 14:03:53 -0800 Subject: [PATCH] Adds iOS builds for add-to-app to Travis setup (#244) --- .travis.yml | 51 +++++++++++++------ tool/travis_android_script.sh | 18 +++---- tool/travis_flutter_script.sh | 20 ++++---- tool/travis_ios_script.sh | 94 +++++++++++++++++++++++++++++++++++ 4 files changed, 148 insertions(+), 35 deletions(-) create mode 100755 tool/travis_ios_script.sh diff --git a/.travis.yml b/.travis.yml index d02f9fd75..22558495e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,40 +1,58 @@ -os: linux -dist: trusty - -addons: - apt: - sources: - - ubuntu-toolchain-r-test - packages: - - libstdc++6 - - fonts-noto - git: depth: 3 -android: - components: - - build-tools-28.0.3 - - android-28 - jobs: include: + - name: "iOS tests, stable channel" + os: osx + osx_image: xcode11.2 + language: objective-c + script: ./tool/travis_ios_script.sh + env: FLUTTER_VERSION=stable + - name: "Android tests, stable channel" + os: linux + dist: trusty language: android + android: + components: + - build-tools-28.0.3 + - android-28 script: ./tool/travis_android_script.sh env: FLUTTER_VERSION=stable + - name: "Flutter tests, stable channel" + os: linux + dist: trusty language: ruby script: ./tool/travis_flutter_script.sh env: FLUTTER_VERSION=stable + + - name: "iOS tests, beta channel" + os: osx + osx_image: xcode11.2 + language: objective-c + script: ./tool/travis_ios_script.sh + env: FLUTTER_VERSION=beta + - name: "Android tests, beta channel" + os: linux + dist: trusty language: android + android: + components: + - build-tools-28.0.3 + - android-28 script: ./tool/travis_android_script.sh env: FLUTTER_VERSION=beta + - name: "Flutter tests, beta channel" + os: linux + dist: trusty language: ruby script: ./tool/travis_flutter_script.sh env: FLUTTER_VERSION=beta + allow_failures: - env: FLUTTER_VERSION=beta @@ -44,6 +62,7 @@ before_script: - chmod +x tool/travis_*_script.sh cache: + cocoapods: true directories: - $HOME/shared/.pub-cache diff --git a/tool/travis_android_script.sh b/tool/travis_android_script.sh index 5a89e2625..c52851b42 100755 --- a/tool/travis_android_script.sh +++ b/tool/travis_android_script.sh @@ -15,28 +15,28 @@ function getFlutterPath() { done } -localSdkPath=$(getFlutterPath) +readonly LOCAL_SDK_PATH=$(getFlutterPath) -if [ -z "$localSdkPath" ] +if [ -z "${LOCAL_SDK_PATH}" ] then - echo "Failed to find the Flutter SDK!." + echo "Failed to find the Flutter SDK!" exit 1 fi -echo "Flutter SDK found at ${localSdkPath}" +echo "Flutter SDK found at ${LOCAL_SDK_PATH}" echo "Fetching dependencies and building 'flutter_module'." pushd add_to_app/flutter_module -"${localSdkPath}/bin/flutter" packages get -"${localSdkPath}/bin/flutter" build aar +"${LOCAL_SDK_PATH}/bin/flutter" packages get +"${LOCAL_SDK_PATH}/bin/flutter" build aar popd echo "Fetching dependencies for 'flutter_module_using_plugin'." pushd add_to_app/flutter_module_using_plugin -"${localSdkPath}/bin/flutter" packages get +"${LOCAL_SDK_PATH}/bin/flutter" packages get popd -declare -a ANDROID_PROJECT_NAMES=( +declare -ar ANDROID_PROJECT_NAMES=( "add_to_app/android_fullscreen" \ "add_to_app/android_using_plugin" \ "add_to_app/android_using_prebuilt_module" \ @@ -44,7 +44,7 @@ declare -a ANDROID_PROJECT_NAMES=( for PROJECT_NAME in "${ANDROID_PROJECT_NAMES[@]}" do - echo "== Testing '${PROJECT_NAME}' on Flutter's $FLUTTER_VERSION channel ==" + echo "== Testing '${PROJECT_NAME}' on Flutter's ${FLUTTER_VERSION} channel ==" pushd "${PROJECT_NAME}" ./gradlew --stacktrace assembleDebug diff --git a/tool/travis_flutter_script.sh b/tool/travis_flutter_script.sh index 0bbc77f1c..347145130 100755 --- a/tool/travis_flutter_script.sh +++ b/tool/travis_flutter_script.sh @@ -15,17 +15,17 @@ function getFlutterPath() { done } -localSdkPath=$(getFlutterPath) +readonly LOCAL_SDK_PATH=$(getFlutterPath) -if [ -z "$localSdkPath" ] +if [ -z "${LOCAL_SDK_PATH}" ] then - echo "Failed to find the Flutter SDK!." + echo "Failed to find the Flutter SDK!" exit 1 fi -echo "Flutter SDK found at ${localSdkPath}" +echo "Flutter SDK found at ${LOCAL_SDK_PATH}" -declare -a PROJECT_NAMES=( +declare -ar PROJECT_NAMES=( "add_to_app/flutter_module" \ "add_to_app/flutter_module_using_plugin" \ "animations" \ @@ -43,17 +43,17 @@ declare -a PROJECT_NAMES=( for PROJECT_NAME in "${PROJECT_NAMES[@]}" do - echo "== Testing '${PROJECT_NAME}' on Flutter's $FLUTTER_VERSION channel ==" + echo "== Testing '${PROJECT_NAME}' on Flutter's ${FLUTTER_VERSION} channel ==" pushd "${PROJECT_NAME}" # Run the analyzer to find any static analysis issues. - "${localSdkPath}/bin/flutter" analyze + "${LOCAL_SDK_PATH}/bin/flutter" analyze # Run the formatter on all the dart files to make sure everything's linted. - "${localSdkPath}/bin/flutter" format -n --set-exit-if-changed . + "${LOCAL_SDK_PATH}/bin/flutter" format -n --set-exit-if-changed . # Run the actual tests. - "${localSdkPath}/bin/flutter" test + "${LOCAL_SDK_PATH}/bin/flutter" test popd done @@ -62,7 +62,7 @@ done # gallery have been generated using the latest gallery code. echo "Run code segments check for 'gallery/gallery'." pushd gallery/gallery -"${localSdkPath}/bin/flutter" pub run grinder verify-code-segments +"${LOCAL_SDK_PATH}/bin/flutter" pub run grinder verify-code-segments popd echo "-- Success --" diff --git a/tool/travis_ios_script.sh b/tool/travis_ios_script.sh new file mode 100755 index 000000000..3d767a57b --- /dev/null +++ b/tool/travis_ios_script.sh @@ -0,0 +1,94 @@ +#!/bin/bash + +set -e + +# Backs up one directory at a time, looking for one called "flutter". Once it +# finds that directory, an absolute path to it is returned. +function getFlutterPath() { + local path="" + local counter=0 + + while [[ "${counter}" -lt 10 ]]; do + [ -d "${path}flutter" ] && echo "$(pwd)/${path}flutter" && return 0 + let counter++ + path="${path}../" + done +} + +readonly LOCAL_SDK_PATH=$(getFlutterPath) + +if [ -z "${LOCAL_SDK_PATH}" ] +then + echo "Failed to find the Flutter SDK!" + exit 1 +fi + +echo "Flutter SDK found at ${LOCAL_SDK_PATH}" + +echo "Pre-caching ios artifacts, such as the Flutter.framework" +"${LOCAL_SDK_PATH}/bin/flutter" precache --no-web --no-linux --no-windows --no-fuchsia --no-android --no-macos + +echo "Fetching dependencies and building 'flutter_module'." +pushd add_to_app/flutter_module +"${LOCAL_SDK_PATH}/bin/flutter" packages get +"${LOCAL_SDK_PATH}/bin/flutter" build ios-framework --output=../ios_using_prebuilt_module/Flutter +popd + +echo "Fetching dependencies for 'flutter_module_using_plugin'." +pushd add_to_app/flutter_module_using_plugin +"${LOCAL_SDK_PATH}/bin/flutter" packages get +popd + + +echo "== Testing 'add_to_app/ios_fullscreen' on Flutter's $FLUTTER_VERSION channel ==" +pushd "add_to_app/ios_fullscreen" + +pod install + +xcodebuild -workspace "IOSFullScreen.xcworkspace" \ +-scheme "IOSFullScreen" CODE_SIGNING_ALLOWED=NO CODE_SIGNING_REQUIRED=NO \ +CODE_SIGN_IDENTITY=- EXPANDED_CODE_SIGN_IDENTITY=- \ +COMPILER_INDEX_STORE_ENABLE=NO CONFIGURATION=Debug | xcpretty + +xcodebuild -workspace "IOSFullScreen.xcworkspace" \ +-scheme "IOSFullScreen" CODE_SIGNING_ALLOWED=NO CODE_SIGNING_REQUIRED=NO \ +CODE_SIGN_IDENTITY=- EXPANDED_CODE_SIGN_IDENTITY=- \ +COMPILER_INDEX_STORE_ENABLE=NO CONFIGURATION=Release \ +-destination generic/platform=iOS | xcpretty + +popd + +echo "== Testing 'add_to_app/ios_using_plugin' on Flutter's $FLUTTER_VERSION channel ==" +pushd "add_to_app/ios_using_plugin" + +pod install + +xcodebuild -workspace "IOSUsingPlugin.xcworkspace" \ +-scheme "IOSUsingPlugin" CODE_SIGNING_ALLOWED=NO CODE_SIGNING_REQUIRED=NO \ +CODE_SIGN_IDENTITY=- EXPANDED_CODE_SIGN_IDENTITY=- \ +COMPILER_INDEX_STORE_ENABLE=NO CONFIGURATION=Debug | xcpretty + +xcodebuild -workspace "IOSUsingPlugin.xcworkspace" \ +-scheme "IOSUsingPlugin" CODE_SIGNING_ALLOWED=NO CODE_SIGNING_REQUIRED=NO \ +CODE_SIGN_IDENTITY=- EXPANDED_CODE_SIGN_IDENTITY=- \ +COMPILER_INDEX_STORE_ENABLE=NO CONFIGURATION=Release \ +-destination generic/platform=iOS | xcpretty + +popd + +echo "== Testing 'add_to_app/ios_using_prebuilt_module' on Flutter's $FLUTTER_VERSION channel ==" +pushd "add_to_app/ios_using_prebuilt_module" + +xcodebuild CODE_SIGNING_ALLOWED=NO CODE_SIGNING_REQUIRED=NO \ +CODE_SIGN_IDENTITY=- EXPANDED_CODE_SIGN_IDENTITY=- \ +COMPILER_INDEX_STORE_ENABLE=NO CONFIGURATION=Debug | xcpretty + +xcodebuild CODE_SIGNING_ALLOWED=NO CODE_SIGNING_REQUIRED=NO \ +CODE_SIGN_IDENTITY=- EXPANDED_CODE_SIGN_IDENTITY=- \ +COMPILER_INDEX_STORE_ENABLE=NO CONFIGURATION=Release \ +-destination generic/platform=iOS | xcpretty + +popd + + +echo "-- Success --"