Skip to content

Commit

Permalink
Incremental Build Script (flutter#422)
Browse files Browse the repository at this point in the history
Similar to `plugin_tools.sh` but doesn't depend on Travis or any other CI.

+use it for Cirrus CI
  • Loading branch information
fkorotkov authored and yjbanov committed Mar 16, 2018
1 parent 4311bfe commit ac2a3a7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
8 changes: 4 additions & 4 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ task:
- sudo apt-add-repository "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-5.0 main"
- sudo apt-get update
- sudo apt-get install -y --allow-unauthenticated clang-format-5.0
format_script: ./script/plugin_tools.sh format --travis --clang-format=clang-format-5.0
test_script: ./script/plugin_tools.sh test
format_script: ./script/incremental_build.sh format --travis --clang-format=clang-format-5.0
test_script: ./script/incremental_build.sh test
- name: analyze
script: ./script/plugin_tools.sh analyze
script: ./script/incremental_build.sh analyze
- name: build-apks
script: ./script/plugin_tools.sh build-examples --apk
script: ./script/incremental_build.sh build-examples --apk
24 changes: 24 additions & 0 deletions script/incremental_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

set -ev

BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)

if [ "${BRANCH_NAME}" = "master" ]; then
echo "Running for all packages"
pub global run flutter_plugin_tools "$@"
else
# Make sure there is up-to-date master.
git fetch origin master
BRANCH_BASE_SHA=$(git merge-base --fork-point FETCH_HEAD HEAD)
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, -`
if [ "${FLUTTER_CHANGED_PACKAGES}" = "" ] || [ $FLUTTER_CHANGED_GLOBAL -gt 0 ]; then
echo "Running for all packages"
pub global run flutter_plugin_tools "$@"
else
echo "Running only for $FLUTTER_CHANGED_PACKAGES"
pub global run flutter_plugin_tools "$@" --plugins=$FLUTTER_CHANGED_PACKAGES
fi
fi

0 comments on commit ac2a3a7

Please sign in to comment.