Skip to content

Instantly share code, notes, and snippets.

@srawlins
Created December 11, 2023 23:53
Show Gist options
  • Save srawlins/b66dcecb9a93546891cb5f35a2407afa to your computer and use it in GitHub Desktop.
Save srawlins/b66dcecb9a93546891cb5f35a2407afa to your computer and use it in GitHub Desktop.
A little shell script to locally analyze flutter customer code with a custom dart binary
# This script is as dead simple as it can be. It emulates the behavior of the
# `.test` files at https://github.com/flutter/tests/blob/main/registry/
# but assumes that all of the mentioned repos are already cloned, and in the
# current directory. (For example, see in `analyze_assorted_layout_widgets`,
# the first step is `pushd flutter-assorted_layout_widgets` which is relative
# to the current directory.) Limiting the git work to `git fetch` and
# `git checkout` should keep the overhead low.:
#
# The hashes are hard-coded here, so you'll have to hand-update them with the
# registry mentioned above. If you have `flutter/tests` cloned, you can
# `git grep heckout` to find the hashes.
#
# This script _does not use_ the scripts at
# https://github.com/flutter/tests/tree/main/scripts or even each repo's
# "customer tests" script, because those all execute tests (in addition to
# performing analysis), which I am not interested in.
#
# It fails fast; to continue after a failure, just add `|| echo FAILURE` to
# the command that fails (e.g. after mailing a PR).
set -ex
export PATH=$HOME/code/flutter/bin:$PATH
# Put custom `dart` in front of custom `flutter`.
export PATH=$HOME/code/dart-sdk/sdk/xcodebuild/ReleaseX64/dart-sdk/bin:$PATH
export FLUTTER_ROOT=$HOME/code/flutter
DART=$HOME/code/dart-sdk/sdk/xcodebuild/ReleaseX64/dart-sdk/bin/dart
FLUTTER=$HOME/code/flutter/bin/flutter
HASH_ASSORTED_LAYOUT_WIDGETS=added2d75b7db9ace7657a87f3f6043a26e5bb57
HASH_DART_RFB=16c4afdcf13c85979ec0ad2f5d2ce5164c65ed6f
HASH_FLUTTER_COCOON=aaefce4eed4604cebae2b312e73eddf9f930d1c7
HASH_FLUTTER_DEVTOOLS=3a9e1922391ed017615d71a91ade1bdea8aa7516
HASH_FLUTTER_GALLERY=fa031bfe9d131010e7a56ee5d343f9f85b367d64
HASH_FLUTTER_PACKAGES=1da11759b4a58deb5bd37432af3410f47e0e9c7b
HASH_FLUTTER_PORTAL=d43d28386c6ad3078095e5bb0dcca255cc612106
HASH_FLUTTER_RFB=b7aa339c5534b54a63674df64b26dfb86414b815
HASH_FLUTTER_SVG=a3911bb074c49b821bb9beaa349ee04ac9f4e2f7
HASH_MACOS_UI=c6d37d88e38bddc0723fee9eb57c146aa9f0053d
HASH_PROVIDER=a60a35c49e907fed597dd2af28ed79cc94b7671a
HASH_SUPER_EDITOR=d9daa4a19f9b7553c33923f099632c5d359d7e8d
# TODO: tiler? currently disabled
### ASSORTED_LAYOUT_WIDGETS
analyze_assorted_layout_widgets() {
pushd flutter-assorted_layout_widgets
git fetch
git checkout $HASH_ASSORTED_LAYOUT_WIDGETS
$FLUTTER pub get
$DART analyze
popd
}
### DART-RFB
analyze_dart_rfb() {
pushd dart-rfb
git fetch
git checkout $HASH_DART_RFB
$FLUTTER pub get
$DART analyze
popd
}
### COCOON
analyze_flutter_cocoon() {
pushd flutter-cocoon
git fetch
git checkout $HASH_FLUTTER_COCOON
pushd dashboard
$FLUTTER packages get
$DART analyze
popd
popd
}
### FLUTTER-DEVTOOLS
analyze_flutter_devtools() {
pushd flutter-devtools
git fetch
git checkout $HASH_FLUTTER_DEVTOOLS
find case_study packages third_party tool -name pubspec.yaml |grep -v flutter-sdk |grep -v packages/pubspec.yaml |while read -r PUBSPEC ; do
PACKAGE_DIR=$(dirname $PUBSPEC)
pushd "$PACKAGE_DIR"
$FLUTTER pub get
$DART analyze --fatal-infos # || echo FAILURE
popd
done
popd
}
### FLUTTER-GALLERY
analyze_flutter_gallery() {
pushd flutter-gallery
git checkout pubspec.lock
git fetch
git checkout $HASH_FLUTTER_GALLERY
$FLUTTER pub get
$DART analyze
popd
}
### FLUTTER-PACKAGES
analyze_flutter_packages() {
pushd flutter-packages
git fetch
git checkout $HASH_FLUTTER_PACKAGES
pushd packages/animations
$FLUTTER pub get
$DART analyze
popd
pushd packages/rfw
pushd example/remote; $FLUTTER packages get; popd
pushd example/wasm; $FLUTTER packages get; popd
pushd test_coverage; $DART pub get; popd
$DART analyze
popd
popd
}
### FLUTTER-PORTAL
analyze_portal() {
pushd flutter_portal
git fetch
git checkout $HASH_FLUTTER_PORTAL
$FLUTTER pub get
$DART analyze
popd
}
### FLUTTER-RFB
analyze_flutter_rfb() {
pushd flutter-rfb
git fetch
git checkout $HASH_FLUTTER_RFB
$FLUTTER pub get
$DART analyze
popd
}
### FLUTTER-SVG
analyze_flutter_svg() {
pushd flutter_svg
git fetch
git checkout $HASH_FLUTTER_SVG
pushd packages/flutter_svg
$FLUTTER pub get
$DART analyze
popd
popd
}
### PROVIDER
analyze_provider() {
pushd dart-provider
git fetch
git checkout $HASH_PROVIDER
$FLUTTER pub get
$DART analyze lib test/null_safe
popd
}
analyze_assorted_layout_widgets
analyze_dart_rfb
analyze_flutter_cocoon
analyze_flutter_devtools
analyze_flutter_gallery
analyze_flutter_packages
analyze_portal
analyze_flutter_rfb
analyze_flutter_svg
analyze_provider
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment