Fix version conflicts, verify publishability of packages in CI, Remove Travis (#729)
This fixes a number of version resolution errors that would prevent these packages from building, and turn off Travis, since Cirrus now works.
I also fixed a number of errors that would have prevented these packages from being published without warnings, and establishes a CI script that will verify publishability for any changed packages in a PR.
For some examples, we were depending upon versions of other 1st-party plugins by using path: ../../<package>, which really isn't the right way to do things, so for those examples, they now depend on a published version.
I bumped the version number of any packages that were modified, and updated their CHANGELOGs since the dependencies have changed.
Also fixed a number of analyzer errors that somehow snuck in.
diff --git a/script/before_build_apks.sh b/script/before_build_apks.sh
deleted file mode 100755
index 145e056..0000000
--- a/script/before_build_apks.sh
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/bin/bash
-wget https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip
-mkdir android-sdk
-unzip -qq sdk-tools-linux-3859397.zip -d android-sdk
-export ANDROID_HOME=`pwd`/android-sdk
-export PATH=`pwd`/android-sdk/tools/bin:$PATH
-mkdir -p /home/travis/.android # silence sdkmanager warning
-echo 'count=0' > /home/travis/.android/repositories.cfg # silence sdkmanager warning
- # suppressing output of sdkmanager to keep log under 4MB (travis limit)
-echo y | sdkmanager "tools" >/dev/null
-echo y | sdkmanager "platform-tools" >/dev/null
-echo y | sdkmanager "build-tools;26.0.3" >/dev/null
-echo y | sdkmanager "platforms;android-26" >/dev/null
-echo y | sdkmanager "extras;android;m2repository" >/dev/null
-echo y | sdkmanager "extras;google;m2repository" >/dev/null
-echo y | sdkmanager "patcher;v4" >/dev/null
-sdkmanager --list
-wget http://services.gradle.org/distributions/gradle-4.1-bin.zip
-unzip -qq gradle-4.1-bin.zip
-export GRADLE_HOME=$PWD/gradle-4.1
-export PATH=$GRADLE_HOME/bin:$PATH
-gradle -v
-git clone https://github.com/flutter/flutter.git
-export PATH=`pwd`/flutter/bin:`pwd`/flutter/bin/cache/dart-sdk/bin:$PATH
-flutter doctor
-pub global activate flutter_plugin_tools
diff --git a/script/before_build_ipas.sh b/script/before_build_ipas.sh
deleted file mode 100755
index 93ffb37..0000000
--- a/script/before_build_ipas.sh
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/bin/bash
-brew update
-brew install libimobiledevice
-brew install ideviceinstaller
-brew install ios-deploy
-pod repo update
-gem update cocoapods
-git clone https://github.com/flutter/flutter.git
-export PATH=`pwd`/flutter/bin:`pwd`/flutter/bin/cache/dart-sdk/bin:$PATH
-flutter doctor
-pub global activate flutter_plugin_tools
diff --git a/script/check_publish.sh b/script/check_publish.sh
new file mode 100755
index 0000000..c12b776
--- /dev/null
+++ b/script/check_publish.sh
@@ -0,0 +1,39 @@
+#!/bin/bash
+set -e
+
+# This script checks to make sure that each of the plugins *could* be published.
+# It doesn't actually publish anything.
+
+# So that users can run this script from anywhere and it will work as expected.
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
+REPO_DIR="$(dirname "$SCRIPT_DIR")"
+
+source "$SCRIPT_DIR/common.sh"
+
+function check_publish() {
+ local failures=()
+ for package_name in "$@"; do
+ local dir="$REPO_DIR/packages/$package_name"
+ echo "Checking that $package_name can be published."
+ if (cd "$dir" && pub publish --dry-run > /dev/null); then
+ echo "Package $package_name is able to be published."
+ else
+ error "Unable to publish $package_name"
+ failures=("${failures[@]}" "$package_name")
+ fi
+ done
+ if [[ "${#failures[@]}" != 0 ]]; then
+ error "FAIL: The following ${#failures[@]} package(s) failed the publishing check:"
+ for failure in "${failures[@]}"; do
+ error "$failure"
+ done
+ fi
+ return "${#failures[@]}"
+}
+
+# Sets CHANGED_PACKAGE_LIST
+check_changed_packages
+
+if [[ "${#CHANGED_PACKAGE_LIST[@]}" != 0 ]]; then
+ check_publish "${CHANGED_PACKAGE_LIST[@]}"
+fi
\ No newline at end of file
diff --git a/script/common.sh b/script/common.sh
new file mode 100644
index 0000000..eaf94c7
--- /dev/null
+++ b/script/common.sh
@@ -0,0 +1,42 @@
+#!/bin/bash
+
+function error() {
+ echo "$@" 1>&2
+}
+
+function check_changed_packages() {
+ # Try get a merge base for the branch and calculate affected packages.
+ # We need this check because some CIs can do a single branch clones with a limited history of commits.
+ local packages
+ local branch_base_sha="$(git merge-base --fork-point FETCH_HEAD HEAD || git merge-base FETCH_HEAD HEAD)"
+ if [[ "$?" == 0 ]]; then
+ echo "Checking for changed packages from $branch_base_sha"
+ IFS=$'\n' packages=( $(git diff --name-only "$branch_base_sha" HEAD | grep -o "packages/[^/]*" | sed -e "s/packages\///g" | sort | uniq) )
+ else
+ error "Cannot find a merge base for the current branch to run an incremental build..."
+ error "Please rebase your branch onto the latest master!"
+ return 1
+ fi
+
+ # Filter out any packages that don't have a pubspec.yaml: they have probably
+ # been deleted in this PR.
+ CHANGED_PACKAGES=""
+ CHANGED_PACKAGE_LIST=()
+ for package in "${packages[@]}"; do
+ if [[ -f "$REPO_DIR/packages/$package/pubspec.yaml" ]]; then
+ CHANGED_PACKAGES="${CHANGED_PACKAGES},$package"
+ CHANGED_PACKAGE_LIST=("${CHANGED_PACKAGE_LIST[@]}" "$package")
+ fi
+ done
+
+ if [[ "${#CHANGED_PACKAGE_LIST[@]}" == 0 ]]; then
+ echo "No changes detected in packages."
+ else
+ echo "Detected changes in the following ${#CHANGED_PACKAGE_LIST[@]} package(s):"
+ for package in "${CHANGED_PACKAGE_LIST[@]}"; do
+ echo "$package"
+ done
+ echo ""
+ fi
+ return 0
+}
diff --git a/script/incremental_build.sh b/script/incremental_build.sh
index 788a24c..c3a3941 100755
--- a/script/incremental_build.sh
+++ b/script/incremental_build.sh
@@ -1,35 +1,29 @@
#!/bin/bash
+set -e
-set -ev
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
+REPO_DIR="$(dirname "$SCRIPT_DIR")"
-BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
+source "$SCRIPT_DIR/common.sh"
-if [ "${BRANCH_NAME}" = "master" ]; then
+# Set some default actions if run without arguments.
+ACTIONS=("$@")
+if [[ "${#ACTIONS[@]}" == 0 ]]; then
+ ACTIONS=("test" "analyze" "java-test")
+fi
+
+BRANCH_NAME="${BRANCH_NAME:-"$(git rev-parse --abbrev-ref HEAD)"}"
+if [[ "${BRANCH_NAME}" == "master" ]]; then
echo "Running for all packages"
- pub global run flutter_plugin_tools "$@" $PLUGIN_SHARDING
+ (cd "$REPO_DIR" && pub global run flutter_plugin_tools "${ACTIONS[@]}" $PLUGIN_SHARDING)
else
- # Make sure there is up-to-date master.
- git fetch origin master
+ # Sets CHANGED_PACKAGES
+ check_changed_packages
- FLUTTER_CHANGED_GLOBAL=0
- FLUTTER_CHANGED_PACKAGES=""
-
- # Try get a merge base for the branch and calculate affected packages.
- # We need this check because some CIs can do a single branch clones with a limited history of commits.
- if BRANCH_BASE_SHA=$(git merge-base --fork-point FETCH_HEAD HEAD); then
- echo "Checking changes from $BRANCH_BASE_SHA..."
- FLUTTER_CHANGED_GLOBAL=`git diff --name-only $BRANCH_BASE_SHA HEAD | grep -v packages | wc -l`
- FLUTTER_CHANGED_PACKAGES=`git diff --name-only $BRANCH_BASE_SHA HEAD | grep -o "packages/[^/]*" | sed -e "s/packages\///g" | sort | uniq | paste -s -d, -`
- else
- echo "Cannot find a merge base for the current branch to run an incremental build..."
- echo "Please rebase your branch onto the latest master!"
- fi
-
- if [ "${FLUTTER_CHANGED_PACKAGES}" = "" ] || [ $FLUTTER_CHANGED_GLOBAL -gt 0 ]; then
+ if [[ "$CHANGED_PACKAGES" == "" ]]; then
echo "Running for all packages"
- pub global run flutter_plugin_tools "$@" $PLUGIN_SHARDING
+ (cd "$REPO_DIR" && pub global run flutter_plugin_tools "${ACTIONS[@]}" $PLUGIN_SHARDING)
else
- echo "Running only for $FLUTTER_CHANGED_PACKAGES"
- pub global run flutter_plugin_tools "$@" --plugins=$FLUTTER_CHANGED_PACKAGES
+ (cd "$REPO_DIR" && pub global run flutter_plugin_tools "${ACTIONS[@]}" --plugins="$CHANGED_PACKAGES" $PLUGIN_SHARDING)
fi
fi