diff --git a/.cirrus.yml b/.cirrus.yml index 06d7500ec4..d284ee02b6 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -8,7 +8,7 @@ tool_setup_template: &TOOL_SETUP_TEMPLATE - 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 # 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 upgrade_flutter_script: @@ -29,17 +29,19 @@ task: memory: 8G << : *FLUTTER_UPGRADE_TEMPLATE matrix: - - name: analyze - script: ./script/incremental_build.sh analyze --custom-analysis=web_benchmarks/testing/test_app + - name: format+analyze + 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 - script: ./script/check_publish.sh + version_script: ./script/tool_runner.sh version-check + publishable_script: ./script/tool_runner.sh publish-check depends_on: - - analyze - - name: test+format - format_script: ./script/incremental_build.sh format --travis --clang-format=clang-format-5.0 - test_script: ./script/incremental_build.sh test + - format+analyze + - name: test + script: ./script/tool_runner.sh test depends_on: - - analyze + - format+analyze - name: build-apks+java-test env: matrix: @@ -49,10 +51,10 @@ task: BUILD_SHARDING: "--shardIndex 0 --shardCount 2" BUILD_SHARDING: "--shardIndex 1 --shardCount 2" script: - - ./script/incremental_build.sh build-examples --apk - - ./script/incremental_build.sh java-test # must come after apk build + - ./script/tool_runner.sh build-examples --apk + - ./script/tool_runner.sh java-test # must come after apk build depends_on: - - analyze + - format+analyze - name: web_benchmarks_test install_chromium_script: - ./script/install_chromium.sh @@ -79,7 +81,7 @@ task: BUILD_SHARDING: "--shardIndex 1 --shardCount 2" << : *FLUTTER_UPGRADE_TEMPLATE build_script: - - ./script/incremental_build.sh build-examples --ipa + - ./script/tool_runner.sh build-examples --ipa task: name: local_tests diff --git a/packages/flutter_lints/LICENSE b/packages/flutter_lints/LICENSE index 7063d084ef..c6823b81eb 100644 --- a/packages/flutter_lints/LICENSE +++ b/packages/flutter_lints/LICENSE @@ -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 -modification, are permitted provided that the following conditions are -met: +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. @@ -10,18 +9,17 @@ met: copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided 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 from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/packages/flutter_lints/run_tests.sh b/packages/flutter_lints/run_tests.sh index aa9a0b0342..63369d6c4a 100755 --- a/packages/flutter_lints/run_tests.sh +++ b/packages/flutter_lints/run_tests.sh @@ -1,4 +1,7 @@ #!/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` if [ $filecount -ne 0 ] diff --git a/script/check_publish.sh b/script/check_publish.sh deleted file mode 100755 index 96dc7543bf..0000000000 --- a/script/check_publish.sh +++ /dev/null @@ -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 diff --git a/script/common.sh b/script/common.sh deleted file mode 100644 index 96e640570a..0000000000 --- a/script/common.sh +++ /dev/null @@ -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 -} diff --git a/script/local_tests.sh b/script/local_tests.sh index a572a955ba..ce2319e44b 100755 --- a/script/local_tests.sh +++ b/script/local_tests.sh @@ -2,13 +2,52 @@ # 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. + +# 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 SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)" REPO_DIR="$(dirname "$SCRIPT_DIR")" 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 diff --git a/script/incremental_build.sh b/script/tool_runner.sh similarity index 63% rename from script/incremental_build.sh rename to script/tool_runner.sh index 209c673fc3..c0a8fd06fa 100755 --- a/script/incremental_build.sh +++ b/script/tool_runner.sh @@ -7,8 +7,6 @@ set -e SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)" REPO_DIR="$(dirname "$SCRIPT_DIR")" -source "$SCRIPT_DIR/common.sh" - # Set some default actions if run without arguments. ACTIONS=("$@") if [[ "${#ACTIONS[@]}" == 0 ]]; then @@ -20,13 +18,5 @@ if [[ "${BRANCH_NAME}" == "master" ]]; then echo "Running for all packages" (cd "$REPO_DIR" && pub global run flutter_plugin_tools "${ACTIONS[@]}" $BUILD_SHARDING) else - # Sets CHANGED_PACKAGES - 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 + (cd "$REPO_DIR" && pub global run flutter_plugin_tools "${ACTIONS[@]}" --run-on-changed-packages $BUILD_SHARDING) fi