forked from flutter/codelabs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flutter_ci_script_shared.sh
executable file
·61 lines (51 loc) · 1.73 KB
/
flutter_ci_script_shared.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
function ci_codelabs () {
local channel="$1"
shift
# plugin_codelab is a special case since it's a plugin. Analysis doesn't seem to be working.
pushd $PWD
echo "== TESTING plugin_codelab on $channel"
cd ./plugin_codelab
dart format --output none --set-exit-if-changed .;
popd
# Grab packages.
for dir in `find . -name pubspec.yaml -exec dirname {} \;`; do
pushd $dir
flutter pub get
popd
done
local arr=("$@")
for CODELAB in "${arr[@]}"
do
echo "== Testing '${CODELAB}' on $channel"
declare -a PROJECT_PATHS=($(
find $CODELAB -not -path './flutter/*' -not -path './plugin_codelab/pubspec.yaml' -name pubspec.yaml -exec dirname {} \;
))
for PROJECT in "${PROJECT_PATHS[@]}"
do
pushd "${PROJECT}"
echo "== Testing '${PROJECT}'"
# Run the analyzer to find any static analysis issues.
dart analyze --fatal-infos
# Run the formatter on all the dart files to make sure everything's linted.
dart format --output none --set-exit-if-changed .
# Run the actual tests.
if [ -d "test" ]
then
flutter test
fi
popd
done
done
declare -a WORKSHOP_STEP_PATHS=($(
find dartpad_codelabs -name snippet.dart -exec dirname {} \;
))
for WORKSHOP_STEP_PATH in "${WORKSHOP_STEP_PATHS[@]}"; do
echo "== TESTING $WORKSHOP_STEP_PATH"
(
cd "$WORKSHOP_STEP_PATH"
if [[ -r solution.dart ]]; then DART_FILE=solution.dart; else DART_FILE=snippet.dart; fi
set -x
dart format --output none --set-exit-if-changed $DART_FILE
)
done
}