Update repo tooling (#344)

Updates to better align with the current flutter/plugins tooling:
- Pulls the latest flutter_plugin_tools
- Enables the new version-check functionality
- Enables the new license-check functionality
- Switches over to the new publish check functionality
- Moves format checking to a bot that does several of the very fast
  checks, leaving tests as their own bot
- Switches incremental_build.sh to use the new --run-on-changed-packages
  functionality instead of the bash check_changed_packages
- Moves check_changed_packages into local_tests.sh to minimize the
  chances of future new code trying to use it, as it is now legacy.
- Renames incremental_build.sh to tool_runner.sh, to better match its
  current behavior/use
This commit is contained in:
stuartmorgan
2021-05-10 13:48:16 -04:00
committed by GitHub
parent b17875fa0e
commit 4804697bf2
7 changed files with 73 additions and 129 deletions

View File

@ -8,7 +8,7 @@ tool_setup_template: &TOOL_SETUP_TEMPLATE
- git fetch origin master # To set FETCH_HEAD for "git merge-base" to work - git fetch origin master # To set FETCH_HEAD for "git merge-base" to work
# Pinned version of the plugin tools, to avoid breakage in this repository # Pinned version of the plugin tools, to avoid breakage in this repository
# when pushing updates from flutter/plugins. # when pushing updates from flutter/plugins.
- pub global activate flutter_plugin_tools 0.0.45+3 - pub global activate flutter_plugin_tools 0.1.1
flutter_upgrade_template: &FLUTTER_UPGRADE_TEMPLATE flutter_upgrade_template: &FLUTTER_UPGRADE_TEMPLATE
upgrade_flutter_script: upgrade_flutter_script:
@ -29,17 +29,19 @@ task:
memory: 8G memory: 8G
<< : *FLUTTER_UPGRADE_TEMPLATE << : *FLUTTER_UPGRADE_TEMPLATE
matrix: matrix:
- name: analyze - name: format+analyze
script: ./script/incremental_build.sh analyze --custom-analysis=web_benchmarks/testing/test_app format_script: ./script/tool_runner.sh format --fail-on-change --clang-format=clang-format-5.0
license_script: pub global run flutter_plugin_tools license-check
analyze_script: ./script/tool_runner.sh analyze --custom-analysis=web_benchmarks/testing/test_app
- name: publishable - name: publishable
script: ./script/check_publish.sh version_script: ./script/tool_runner.sh version-check
publishable_script: ./script/tool_runner.sh publish-check
depends_on: depends_on:
- analyze - format+analyze
- name: test+format - name: test
format_script: ./script/incremental_build.sh format --travis --clang-format=clang-format-5.0 script: ./script/tool_runner.sh test
test_script: ./script/incremental_build.sh test
depends_on: depends_on:
- analyze - format+analyze
- name: build-apks+java-test - name: build-apks+java-test
env: env:
matrix: matrix:
@ -49,10 +51,10 @@ task:
BUILD_SHARDING: "--shardIndex 0 --shardCount 2" BUILD_SHARDING: "--shardIndex 0 --shardCount 2"
BUILD_SHARDING: "--shardIndex 1 --shardCount 2" BUILD_SHARDING: "--shardIndex 1 --shardCount 2"
script: script:
- ./script/incremental_build.sh build-examples --apk - ./script/tool_runner.sh build-examples --apk
- ./script/incremental_build.sh java-test # must come after apk build - ./script/tool_runner.sh java-test # must come after apk build
depends_on: depends_on:
- analyze - format+analyze
- name: web_benchmarks_test - name: web_benchmarks_test
install_chromium_script: install_chromium_script:
- ./script/install_chromium.sh - ./script/install_chromium.sh
@ -79,7 +81,7 @@ task:
BUILD_SHARDING: "--shardIndex 1 --shardCount 2" BUILD_SHARDING: "--shardIndex 1 --shardCount 2"
<< : *FLUTTER_UPGRADE_TEMPLATE << : *FLUTTER_UPGRADE_TEMPLATE
build_script: build_script:
- ./script/incremental_build.sh build-examples --ipa - ./script/tool_runner.sh build-examples --ipa
task: task:
name: local_tests name: local_tests

View File

@ -1,8 +1,7 @@
Copyright 2021, The Flutter Authors. All rights reserved. Copyright 2013 The Flutter Authors. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without modification,
modification, are permitted provided that the following conditions are are permitted provided that the following conditions are met:
met:
* Redistributions of source code must retain the above copyright * Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer. notice, this list of conditions and the following disclaimer.
@ -10,18 +9,17 @@ met:
copyright notice, this list of conditions and the following copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided disclaimer in the documentation and/or other materials provided
with the distribution. with the distribution.
* Neither the name of Google LLC nor the names of its * Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived contributors may be used to endorse or promote products derived
from this software without specific prior written permission. from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -1,4 +1,7 @@
#!/bin/bash #!/bin/bash
# Copyright 2013 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
filecount=`find . -name '*.dart' | wc -l` filecount=`find . -name '*.dart' | wc -l`
if [ $filecount -ne 0 ] if [ $filecount -ne 0 ]

View File

@ -1,43 +0,0 @@
#!/bin/bash
# Copyright 2013 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
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" && flutter 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 "WARNING: The following ${#failures[@]} package(s) failed the publishing check:"
for failure in "${failures[@]}"; do
error "$failure"
done
fi
return 0
}
# Sets CHANGED_PACKAGE_LIST
check_changed_packages
if [[ "${#CHANGED_PACKAGE_LIST[@]}" != 0 ]]; then
check_publish "${CHANGED_PACKAGE_LIST[@]}"
fi

View File

@ -1,45 +0,0 @@
#!/bin/bash
# Copyright 2013 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
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
}

View File

@ -2,13 +2,52 @@
# Copyright 2013 The Flutter Authors. All rights reserved. # Copyright 2013 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
# TODO(stuartmorgan): Replace this script either with flutter_plugin_tools
# functionality, or something pigeon-specific, to eliminate the need to have a
# bash copy of checked_changed_packages in this repository.
set -e set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
REPO_DIR="$(dirname "$SCRIPT_DIR")" REPO_DIR="$(dirname "$SCRIPT_DIR")"
TEST_SCRIPT_NAME="run_tests.sh" TEST_SCRIPT_NAME="run_tests.sh"
source "$SCRIPT_DIR/common.sh" 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
}
check_changed_packages check_changed_packages

View File

@ -7,8 +7,6 @@ set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
REPO_DIR="$(dirname "$SCRIPT_DIR")" REPO_DIR="$(dirname "$SCRIPT_DIR")"
source "$SCRIPT_DIR/common.sh"
# Set some default actions if run without arguments. # Set some default actions if run without arguments.
ACTIONS=("$@") ACTIONS=("$@")
if [[ "${#ACTIONS[@]}" == 0 ]]; then if [[ "${#ACTIONS[@]}" == 0 ]]; then
@ -20,13 +18,5 @@ if [[ "${BRANCH_NAME}" == "master" ]]; then
echo "Running for all packages" echo "Running for all packages"
(cd "$REPO_DIR" && pub global run flutter_plugin_tools "${ACTIONS[@]}" $BUILD_SHARDING) (cd "$REPO_DIR" && pub global run flutter_plugin_tools "${ACTIONS[@]}" $BUILD_SHARDING)
else else
# Sets CHANGED_PACKAGES (cd "$REPO_DIR" && pub global run flutter_plugin_tools "${ACTIONS[@]}" --run-on-changed-packages $BUILD_SHARDING)
check_changed_packages
if [[ "$CHANGED_PACKAGES" == "" ]]; then
echo "Running for all packages"
(cd "$REPO_DIR" && pub global run flutter_plugin_tools "${ACTIONS[@]}" $BUILD_SHARDING)
else
(cd "$REPO_DIR" && pub global run flutter_plugin_tools "${ACTIONS[@]}" --plugins="$CHANGED_PACKAGES" $BUILD_SHARDING)
fi
fi fi