[CI] Fix flaky Ameba example build (parallel-target configure race)#72283
Merged
mergify[bot] merged 1 commit intoJun 1, 2026
Merged
Conversation
…ealtek SDK dir
The Ameba example workflow builds three targets (light, all-clusters,
all-clusters-minimal) in a single build_examples.py invocation, which
generates them in parallel. Each Ameba target's generate() step shells
out to the Realtek SDK's
$AMEBA_PATH/project/realtek_amebaD_va0_example/GCC-RELEASE/build.sh,
which configures a single SDK tree that is shared across all
applications rather than scoped to the per-target output_dir.
The existing @lock_output_dir decorator keys its lock on self.output_dir,
which is distinct per target, so it provides no mutual exclusion for the
shared SDK tree. Concurrent generation therefore races on that tree:
- mkdir: cannot create directory 'linux': File exists
- CMake Error at asdk/config.cmake:20 (configure_file):
No such file or directory (asdk/CMakeLists.txt:72)
A racing configure leaves no build.ninja behind, so the subsequent
compile fails with 'ninja: error: loading build.ninja'. The failing
target rotates between runs (nondeterministic); master is green because
the race is timing-dependent.
Fix: serialize only the Realtek SDK configure step across Ameba targets
by acquiring the shared OutDirLock on a constant key
(AMEBA_SDK_GENERATE_LOCK_KEY) around the build.sh invocation in
generate(). Compilation (ninja in _build) still runs in parallel, each
in its own output_dir, so CI throughput is preserved.
Contributor
There was a problem hiding this comment.
Code Review
This pull request serializes the Realtek SDK configure step across all Ameba targets to prevent race conditions during parallel generation. It introduces a shared lock key (AMEBA_SDK_GENERATE_LOCK_KEY) and uses contextlib.nullcontext() as a fallback when locking is not active. There are no review comments, so we have no feedback to provide.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #72283 +/- ##
=======================================
Coverage 55.52% 55.52%
=======================================
Files 1630 1630
Lines 111127 111127
Branches 13418 13418
=======================================
Hits 61706 61706
Misses 49421 49421 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
antonijakubiak-samsung
approved these changes
Jun 1, 2026
andy31415
approved these changes
Jun 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The Ameba example workflow (
.github/workflows/examples-ameba.yaml) builds three targets in a singlebuild_examples.pyinvocation:build_examples.pyruns thegenerate()step for these targets in parallel (Context.Generate()uses aThreadPoolExecutor). Each Ameba target'sgenerate()shells out to the Realtek SDK's$AMEBA_PATH/project/realtek_amebaD_va0_example/GCC-RELEASE/build.sh, which configures one SDK tree shared across all applications — it is not scoped to the per-targetoutput_dir.The existing
@lock_output_dirdecorator keys its lock onself.output_dir, which is distinct per target, so it provides no mutual exclusion for the shared SDK tree. Concurrent generation therefore races on it:A racing configure leaves no
build.ninjabehind, so the subsequent compile fails withninja: error: loading 'build.ninja'. The failing target rotates between runs (nondeterministic) andmasteris green, confirming a timing-dependent parallel-configure race rather than a real build break.Fix
Serialize only the Realtek SDK configure step across Ameba targets by acquiring the shared
OutDirLockon a constant key (AMEBA_SDK_GENERATE_LOCK_KEY) around thebuild.shinvocation inAmebaBuilder.generate()(scripts/build/builders/ameba.py). The lock infrastructure already exists; this just locks on a key that is the same for all three targets (the shared SDK tree) instead of the per-targetoutput_dir.Compilation (
ninjain_build) still runs fully in parallel, each in its ownoutput_dir, so CI throughput is preserved — only the short, contended configure step is serialized.Testing
python3 -m py_compile scripts/build/builders/ameba.py— passes.OutDirLock.lock_dir()API (re-entrant, keyed by string, and a no-op when the lock isNone), so non-parallel single-target builds are unaffected.Build example - Amebaworkflow, which exercises the exact three-target parallel build that was flaking. Several green runs (vs. the previous rotating failures) validate the fix.