-
Notifications
You must be signed in to change notification settings - Fork 2.3k
test: use maximal parallelization in full test run #9039
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -45,36 +45,54 @@ run_yarn_script() { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| run_yarn_script "tests:ios:pod:install" || { echo "iOS pod install failed"; exit 1; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| run_yarn_script "tests:macos:pod:install" || { echo "macOS pod install failed"; exit 1; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # 2. Build Verification | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Verifying builds..." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| run_yarn_script "tests:ios:build" || { echo "iOS build failed"; exit 1; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| run_yarn_script "tests:macos:build" || { echo "macOS build failed"; exit 1; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| run_yarn_script "tests:android:build" || { echo "Android build failed"; exit 1; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # 3. Typechecking | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Running typechecks..." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| run_yarn_script "compare:types" || { echo "Type comparison failed"; exit 1; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # 4. Linting and Formatting | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Running linting and formatting checks..." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| run_yarn_script "lint:js" || { echo "Javascript linting failed"; exit 1; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| run_yarn_script "lint:ios:check" || { echo "iOS Linting failed"; exit 1; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # disabled lint:android because it is flaky at the moment? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #yarn lint:android || { echo "Android Linting failed"; exit 1; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| run_yarn_script "lint:markdown" || { echo "Markdown linting failed"; exit 1; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| run_yarn_script "lint:spellcheck" || { echo "Spellchecking failed"; exit 1; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # 5. Unit Tests | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Running unit tests..." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| run_yarn_script "tests:jest" || { echo "Unit tests 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; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+83
to
+95
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Running 9 heavy tasks in parallel—especially three native builds ( A more balanced approach is to run the lighter linting, typechecking, and unit test tasks in parallel, while running the heavy native builds sequentially to avoid resource exhaustion.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # 6. E2E Tests with Flakiness Tolerance | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Running E2E tests..." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using
kill 0sends the termination signal to the entire process group. This can prematurely terminate the parent shell before it can run its ownEXITtrap cleanly, or kill unrelated processes sharing the same process group.A safer and more targeted approach is to explicitly kill only the background job PIDs stored in the
pidsarray.