mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
This cleans up the ci scripts so that they can be run from an arbitrary directory, and so that they don't have any bash lint issues, and are more explicit about which dart/pub/dartanalyzer executable they run. I also fixed the format script to take a "--fix" argument that will fix all of the formatting issues found, including trailing whitespace and gn files. I added a warning to the license script about untracked/ignored files in the fluttter repo because those so often trip up the license script. I added missing license information to the ci scripts too. There's now a bit of boilerplate at the beginning of each script (the follow_links function) in order to reliably find the actual location of the script: I'd put it into a common file, except that that code would be needed to reliably find the common location too, so I needed to duplicate it. It's the same boilerplate as what is used in the flutter/flutter repo for the flutter and dart scripts. I deleted the ci/test.sh script, since it seems to be obsolete (the test it tries to run doesn't exist anywhere).
95 lines
2.9 KiB
Bash
Executable File
95 lines
2.9 KiB
Bash
Executable File
#!/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
|
|
|
|
# Needed because if it is set, cd may print the path it changed to.
|
|
unset CDPATH
|
|
|
|
# On Mac OS, readlink -f doesn't work, so follow_links traverses the path one
|
|
# link at a time, and then cds into the link destination and find out where it
|
|
# ends up.
|
|
#
|
|
# The function is enclosed in a subshell to avoid changing the working directory
|
|
# of the caller.
|
|
function follow_links() (
|
|
cd -P "$(dirname -- "$1")"
|
|
file="$PWD/$(basename -- "$1")"
|
|
while [[ -L "$file" ]]; do
|
|
cd -P "$(dirname -- "$file")"
|
|
file="$(readlink -- "$file")"
|
|
cd -P "$(dirname -- "$file")"
|
|
file="$PWD/$(basename -- "$file")"
|
|
done
|
|
echo "$file"
|
|
)
|
|
|
|
SCRIPT_DIR=$(follow_links "$(dirname -- "${BASH_SOURCE[0]}")")
|
|
SRC_DIR="$(cd "$SCRIPT_DIR/../.."; pwd -P)"
|
|
FLUTTER_DIR="$SRC_DIR/flutter"
|
|
DART_BIN="$SRC_DIR/third_party/dart/tools/sdks/dart-sdk/bin"
|
|
PUB="$DART_BIN/pub"
|
|
DART_ANALYZER="$DART_BIN/dartanalyzer"
|
|
|
|
echo "Using analyzer from $DART_ANALYZER"
|
|
|
|
"$DART_ANALYZER" --version
|
|
|
|
function analyze() (
|
|
local last_arg="${!#}"
|
|
local results
|
|
# Grep sets its return status to non-zero if it doesn't find what it's
|
|
# looking for.
|
|
set +e
|
|
results="$("$DART_ANALYZER" "$@" 2>&1 |
|
|
grep -Ev "No issues found!" |
|
|
grep -Ev "Analyzing.+$last_arg")"
|
|
set -e
|
|
echo "$results"
|
|
if [ -n "$results" ]; then
|
|
echo "Failed analysis of $last_arg"
|
|
return 1
|
|
else
|
|
echo "Success: no issues found in $last_arg"
|
|
fi
|
|
return 0
|
|
)
|
|
|
|
echo "Analyzing dart:ui library..."
|
|
analyze \
|
|
--options "$FLUTTER_DIR/analysis_options.yaml" \
|
|
--enable-experiment=non-nullable \
|
|
"$SRC_DIR/out/host_debug_unopt/gen/sky/bindings/dart_ui/ui.dart"
|
|
|
|
echo "Analyzing flutter_frontend_server..."
|
|
analyze \
|
|
--packages="$FLUTTER_DIR/flutter_frontend_server/.dart_tool/package_config.json" \
|
|
--options "$FLUTTER_DIR/analysis_options.yaml" \
|
|
"$FLUTTER_DIR/flutter_frontend_server"
|
|
|
|
echo "Analyzing tools/licenses..."
|
|
(cd "$FLUTTER_DIR/tools/licenses" && "$PUB" get)
|
|
analyze \
|
|
--packages="$FLUTTER_DIR/tools/licenses/.dart_tool/package_config.json" \
|
|
--options "$FLUTTER_DIR/tools/licenses/analysis_options.yaml" \
|
|
"$FLUTTER_DIR/tools/licenses"
|
|
|
|
echo "Analyzing testing/dart..."
|
|
"$FLUTTER_DIR/tools/gn" --unoptimized
|
|
ninja -C "$SRC_DIR/out/host_debug_unopt" sky_engine sky_services
|
|
(cd "$FLUTTER_DIR/testing/dart" && "$PUB" get)
|
|
analyze \
|
|
--packages="$FLUTTER_DIR/testing/dart/.dart_tool/package_config.json" \
|
|
--options "$FLUTTER_DIR/analysis_options.yaml" \
|
|
"$FLUTTER_DIR/testing/dart"
|
|
|
|
echo "Analyzing testing/scenario_app..."
|
|
(cd "$FLUTTER_DIR/testing/scenario_app" && "$PUB" get)
|
|
analyze \
|
|
--packages="$FLUTTER_DIR/testing/scenario_app/.dart_tool/package_config.json" \
|
|
--options "$FLUTTER_DIR/analysis_options.yaml" \
|
|
"$FLUTTER_DIR/testing/scenario_app"
|