Fedor Korotkov | 0d6e488 | 2018-03-15 20:50:08 -0400 | [diff] [blame] | 1 | #!/bin/bash |
Greg Spencer | 69af1b7 | 2018-08-20 12:17:49 -0700 | [diff] [blame] | 2 | set -e |
Fedor Korotkov | 0d6e488 | 2018-03-15 20:50:08 -0400 | [diff] [blame] | 3 | |
Jenn Magder | 15b8029 | 2019-09-30 11:22:52 -0700 | [diff] [blame] | 4 | readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)" |
| 5 | readonly REPO_DIR="$(dirname "$SCRIPT_DIR")" |
Fedor Korotkov | 0d6e488 | 2018-03-15 20:50:08 -0400 | [diff] [blame] | 6 | |
Greg Spencer | 69af1b7 | 2018-08-20 12:17:49 -0700 | [diff] [blame] | 7 | source "$SCRIPT_DIR/common.sh" |
Fedor Korotkov | 0d6e488 | 2018-03-15 20:50:08 -0400 | [diff] [blame] | 8 | |
stuartmorgan | 7027e9d | 2020-09-01 16:36:02 -0400 | [diff] [blame^] | 9 | if [ "$(expr substr $(uname -s) 1 5)" == "MINGW" ]; then |
| 10 | PUB=pub.bat |
| 11 | else |
| 12 | PUB=pub |
| 13 | fi |
| 14 | |
Michael Klimushyn | ee4cb3b | 2019-12-05 14:29:44 -0800 | [diff] [blame] | 15 | # Plugins that deliberately use their own analysis_options.yaml. |
| 16 | # |
| 17 | # This list should only be deleted from, never added to. This only exists |
| 18 | # because we adopted stricter analysis rules recently and needed to exclude |
| 19 | # already failing packages to start linting the repo as a whole. |
| 20 | # |
| 21 | # TODO(mklim): Remove everything from this list. https://github.com/flutter/flutter/issues/45440 |
| 22 | CUSTOM_ANALYSIS_PLUGINS=( |
| 23 | "in_app_purchase" |
| 24 | "camera" |
David Iglesias | 66095bf | 2020-04-16 17:33:47 -0700 | [diff] [blame] | 25 | "video_player/video_player_web" |
David Iglesias | 027827f | 2020-08-18 19:06:45 -0700 | [diff] [blame] | 26 | "google_maps_flutter/google_maps_flutter_web" |
Michael Klimushyn | ee4cb3b | 2019-12-05 14:29:44 -0800 | [diff] [blame] | 27 | ) |
| 28 | # Comma-separated string of the list above |
| 29 | readonly CUSTOM_FLAG=$(IFS=, ; echo "${CUSTOM_ANALYSIS_PLUGINS[*]}") |
Greg Spencer | 69af1b7 | 2018-08-20 12:17:49 -0700 | [diff] [blame] | 30 | # Set some default actions if run without arguments. |
| 31 | ACTIONS=("$@") |
| 32 | if [[ "${#ACTIONS[@]}" == 0 ]]; then |
Michael Klimushyn | ee4cb3b | 2019-12-05 14:29:44 -0800 | [diff] [blame] | 33 | ACTIONS=("analyze" "--custom-analysis" "$CUSTOM_FLAG" "test" "java-test") |
Sebastian Roth | e18356f | 2019-12-06 08:17:24 +0000 | [diff] [blame] | 34 | elif [[ "${ACTIONS[@]}" == "analyze" ]]; then |
Michael Klimushyn | ee4cb3b | 2019-12-05 14:29:44 -0800 | [diff] [blame] | 35 | ACTIONS=("analyze" "--custom-analysis" "$CUSTOM_FLAG") |
Greg Spencer | 69af1b7 | 2018-08-20 12:17:49 -0700 | [diff] [blame] | 36 | fi |
| 37 | |
| 38 | BRANCH_NAME="${BRANCH_NAME:-"$(git rev-parse --abbrev-ref HEAD)"}" |
Dan Field | d93d408 | 2020-08-17 23:49:31 -0700 | [diff] [blame] | 39 | |
| 40 | # This has to be turned into a list and then split out to the command line, |
| 41 | # otherwise it gets treated as a single argument. |
| 42 | PLUGIN_SHARDING=($PLUGIN_SHARDING) |
| 43 | |
Greg Spencer | 69af1b7 | 2018-08-20 12:17:49 -0700 | [diff] [blame] | 44 | if [[ "${BRANCH_NAME}" == "master" ]]; then |
Fedor Korotkov | 0d6e488 | 2018-03-15 20:50:08 -0400 | [diff] [blame] | 45 | echo "Running for all packages" |
stuartmorgan | 7027e9d | 2020-09-01 16:36:02 -0400 | [diff] [blame^] | 46 | (cd "$REPO_DIR" && $PUB global run flutter_plugin_tools "${ACTIONS[@]}" ${PLUGIN_SHARDING[@]}) |
Fedor Korotkov | 0d6e488 | 2018-03-15 20:50:08 -0400 | [diff] [blame] | 47 | else |
Greg Spencer | 69af1b7 | 2018-08-20 12:17:49 -0700 | [diff] [blame] | 48 | # Sets CHANGED_PACKAGES |
| 49 | check_changed_packages |
Fedor Korotkov | 81ef8e4 | 2018-04-03 11:34:20 -0400 | [diff] [blame] | 50 | |
Greg Spencer | 69af1b7 | 2018-08-20 12:17:49 -0700 | [diff] [blame] | 51 | if [[ "$CHANGED_PACKAGES" == "" ]]; then |
Maurice Parrish | e2f9acc | 2019-06-24 16:17:59 -0700 | [diff] [blame] | 52 | echo "No changes detected in packages." |
Collin Jackson | 3e271bc | 2019-10-17 13:18:24 -0700 | [diff] [blame] | 53 | echo "Running for all packages" |
stuartmorgan | 7027e9d | 2020-09-01 16:36:02 -0400 | [diff] [blame^] | 54 | (cd "$REPO_DIR" && $PUB global run flutter_plugin_tools "${ACTIONS[@]}" ${PLUGIN_SHARDING[@]}) |
Fedor Korotkov | 0d6e488 | 2018-03-15 20:50:08 -0400 | [diff] [blame] | 55 | else |
Collin Jackson | 3e271bc | 2019-10-17 13:18:24 -0700 | [diff] [blame] | 56 | echo running "${ACTIONS[@]}" |
stuartmorgan | 7027e9d | 2020-09-01 16:36:02 -0400 | [diff] [blame^] | 57 | (cd "$REPO_DIR" && $PUB global run flutter_plugin_tools "${ACTIONS[@]}" --plugins="$CHANGED_PACKAGES" ${PLUGIN_SHARDING[@]}) |
Kaushik Iska | 02ff568 | 2019-07-01 14:01:34 -0700 | [diff] [blame] | 58 | echo "Running version check for changed packages" |
stuartmorgan | 7027e9d | 2020-09-01 16:36:02 -0400 | [diff] [blame^] | 59 | (cd "$REPO_DIR" && $PUB global run flutter_plugin_tools version-check --base_sha="$(get_branch_base_sha)") |
Fedor Korotkov | 0d6e488 | 2018-03-15 20:50:08 -0400 | [diff] [blame] | 60 | fi |
| 61 | fi |