-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Expand file tree
/
Copy pathrun-full-tests.sh
More file actions
executable file
·140 lines (116 loc) · 4.03 KB
/
Copy pathrun-full-tests.sh
File metadata and controls
executable file
·140 lines (116 loc) · 4.03 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#!/bin/bash
# Script to run full test suite in react-native-firebase
# This script handles all test categories and provides error reporting
set -e
# Create temporary directory for logs
TMP_DIR=$(mktemp -d)
# Clean up any stale metro bundler or firebase emulator processes
function terminate_testing_processes() {
# The emulator and packager are tough to kill in the background
# enumerating child processes, small searches, background job efforts - all fraught
# doing a very very specific process command line search works though
# they will fail if the upstream command lines spawned change but they work now
ps -ef | grep node | grep firebase.js | grep emulators:start | awk '{print $2}' | xargs kill 2>/dev/null || true
ps -ef | grep node | grep react-native | grep cli.js | awk '{print $2}' | xargs kill 2>/dev/null || true
# The macOS app stays running even after the run, clean it up as well
killall "io.invertase.testing" 2>/dev/null || true
sleep 5
}
# Ensure process occurs regardless of how the script exits
# Note log dir is not cleaned up as an architectural choice,
# they will remain for inspection in case needed,
# system retention policy will clean them as needed
trap 'terminate_testing_processes' EXIT
# Run yarn commands with logging to file to avoid agent context/output use
# In case of error send output to console for agentic troubleshooting
run_yarn_script() {
local script_name="$1"
local log_file="${TMP_DIR}/${script_name}.log"
echo " ...running $script_name - log: $log_file"
# Run the yarn command and redirect output to log file
if ! yarn "$script_name" > "$log_file" 2>&1; then
echo "Command failed: yarn $script_name"
cat "$log_file"
rm -f "$log_file"
return 1
fi
rm -f "$log_file"
}
# Run yarn scripts in parallel; fail if any child fails.
# Uses job-control style: background jobs + wait, SIGINT kills the group.
run_yarn_scripts_parallel() {
local scripts=("$@")
local pids=()
local pid failed=0
(
trap 'kill 0' SIGINT
for script_name in "${scripts[@]}"; do
run_yarn_script "$script_name" &
pids+=($!)
done
for pid in "${pids[@]}"; do
wait "$pid" || failed=1
done
exit "$failed"
) || return 1
}
echo "Starting full test execution..."
# 1. Dependency Installation
echo "Installing dependencies..."
run_yarn_script "install" || { echo "yarn install failed"; exit 1; }
echo "Installing iOS and macOS pods in parallel..."
run_yarn_scripts_parallel \
"tests:ios:pod:install" \
"tests:macos:pod:install" \
|| { echo "Pod install failed"; exit 1; }
# 2–5. Builds, typechecks, lint, and unit tests (all parallel)
echo "Running builds, typechecks, lint, and unit tests in parallel..."
run_yarn_scripts_parallel \
"tests:ios:build" \
"tests:macos:build" \
"tests:android:build" \
"compare:types" \
"lint:js" \
"lint:ios:check" \
"lint:markdown" \
"lint:spellcheck" \
"tests:jest" \
|| { echo "Parallel verification failed"; exit 1; }
# 6. E2E Tests with Flakiness Tolerance
echo "Running E2E tests..."
# Prep for iOS e2e run in case Xcode changed:
pushd tests
yarn detox clean-framework-cache || { echo "Clean framework cache failed"; exit 1; }
yarn detox build-framework-cache || { echo "Build framework cache failed"; exit 1; }
popd
# Start our bundler and emulator clean
terminate_testing_processes
echo "starting e2e emulator and packager..."
yarn tests:emulator:start &
yarn tests:packager:jet &
sleep 30
# Run E2E tests - 3 chances to succeed for flake tolerance
for flavor in "ios" "android" "macos"; do
for i in {1..3}; do
echo "Running $flavor E2E test run attempt $i..."
if ! yarn tests:"$flavor":test; then
if [ $i -eq 3 ]; then
echo "$flavor E2E test failed all $i attempts.";
terminate_testing_processes
exit 1;
fi
else
echo "Successful $flavor E2E test run on attempt $i."
break;
fi
done
done
# Clean up after ourselves
terminate_testing_processes
rm -rf "$TMP_DIR"
echo
echo
echo "All tests passed successfully!"
echo "Pull request can be created."
echo
echo