Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Turn off Travis, clean up Cirrus #731

Closed
wants to merge 1 commit into from
Closed
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
6 changes: 6 additions & 0 deletions .cirrus.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
task:
container:
image: cirrusci/flutter:latest
cpu: 4
memory: 8G
upgrade_script:
- flutter channel master
- flutter upgrade
- git fetch origin master
activate_script: pub global activate flutter_plugin_tools
matrix:
- name: publishable
script: ./script/check_publish.sh
- name: test+format
install_script:
- wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
Expand Down Expand Up @@ -41,6 +46,7 @@ task:
- brew install ios-deploy
- pod repo update
- git clone https://github.com/flutter/flutter.git
- git fetch origin master
- export PATH=`pwd`/flutter/bin:`pwd`/flutter/bin/cache/dart-sdk/bin:$PATH
- flutter doctor
- pub global activate flutter_plugin_tools
Expand Down
120 changes: 0 additions & 120 deletions .travis.yml

This file was deleted.

26 changes: 0 additions & 26 deletions script/before_build_apks.sh

This file was deleted.

11 changes: 0 additions & 11 deletions script/before_build_ipas.sh

This file was deleted.

75 changes: 75 additions & 0 deletions script/check_publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/bin/bash
set -e

# This script checks to make sure that each of the plugins *could* be published.
# It doesn't acutually 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")"

function error() {
echo "$@" 1>&2
}

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
echo "FAIL: The following ${#failures[@]} package(s) failed the publishing check:"
for failure in "${failures[@]}"; do
echo "$failure"
done
fi
return "${#failures[@]}"
}

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.
# If merge-base --fork-point can't be found (it's more conservative), then use regular merge-base.
local branch_base_sha="$(git merge-base --fork-point FETCH_HEAD HEAD || git merge-base FETCH_HEAD HEAD)"
echo "Checking for changed packages from $branch_base_sha"
local packages
if [[ "$?" == 0 ]]; then
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.
local existing=()
for package in "${packages[@]}"; do
if [[ -f "$REPO_DIR/packages/$package/pubspec.yaml" ]]; then
existing=("${existing[@]}" "$package")
fi
done

if [[ "${#existing[@]}" == 0 ]]; then
echo "No changes detected in packages. Skipping publish check."
return 0
else
echo "Detected changes in the following ${#existing[@]} package(s):"
for package in "${existing[@]}"; do
echo "$package"
done
echo ""
fi

check_publish "${existing[@]}"
}

check_changed_packages "$@"

75 changes: 54 additions & 21 deletions script/incremental_build.sh
Original file line number Diff line number Diff line change
@@ -1,35 +1,68 @@
#!/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)
function error() {
echo "$@" 1>&2
}

if [ "${BRANCH_NAME}" = "master" ]; then
echo "Running for all packages"
pub global run flutter_plugin_tools "$@" $PLUGIN_SHARDING
else
# Make sure there is up-to-date master.
git fetch origin master

FLUTTER_CHANGED_GLOBAL=0
FLUTTER_CHANGED_PACKAGES=""
CHANGED_PACKAGES=""

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.
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, -`
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
echo "Cannot find a merge base for the current branch to run an incremental build..."
echo "Please rebase your branch onto the latest master!"
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

if [ "${FLUTTER_CHANGED_PACKAGES}" = "" ] || [ $FLUTTER_CHANGED_GLOBAL -gt 0 ]; then
# Filter out any packages that don't have a pubspec.yaml: they have probably
# been deleted in this PR.
CHANGED_PACKAGES=""
local package_set=()
for package in "${packages[@]}"; do
if [[ -f "$REPO_DIR/packages/$package/pubspec.yaml" ]]; then
CHANGED_PACKAGES="${CHANGED_PACKAGES},$package"
package_set=("${package_set[@]}" "$package")
fi
done

if [[ "${#package_set[@]}" == 0 ]]; then
echo "No changes detected in packages. Skipping."
return 0
else
echo "Detected changes in the following ${#package_set[@]} package(s):"
for package in "${package_set[@]}"; do
echo "$package"
done
echo ""
fi
}

# 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"
(cd "$REPO_DIR" && pub global run flutter_plugin_tools "${ACTIONS[@]}" $PLUGIN_SHARDING)
else
check_changed_packages
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