@@ -171,22 +171,49 @@ jobs:
171171 echo "Building and Testing $project with Solana $solana_version"
172172 cd "$project" || return 1
173173
174- # Build with quasar CLI
175- if ! quasar build; then
176- echo "::error::quasar build failed for $project"
177- echo "$project: quasar build failed with $solana_version" >> $GITHUB_WORKSPACE/failed_projects.txt
178- cd - > /dev/null
179- return 1
174+ # Determine the quasar program directories for this project. Normally
175+ # the project dir itself holds the Quasar.toml. Some examples (e.g. the
176+ # cross-program-invocation CPI demo) instead contain several program
177+ # subdirectories (hand/, lever/), each its own Quasar project. In that
178+ # case build them all *first*, then test them all, so a program whose
179+ # tests load a sibling program's compiled .so (the CPI callee) has it
180+ # available regardless of directory order.
181+ local prog_dirs=()
182+ if [ -f Quasar.toml ]; then
183+ prog_dirs=(".")
184+ else
185+ for d in */; do
186+ [ -f "${d}Quasar.toml" ] && prog_dirs+=("${d%/}")
187+ done
180188 fi
181189
182- # Run Rust tests (quasar examples use cargo test with quasar-svm)
183- if ! cargo test; then
184- echo "::error::cargo test failed for $project"
185- echo "$project: cargo test failed with $solana_version" >> $GITHUB_WORKSPACE/failed_projects.txt
190+ if [ ${#prog_dirs[@]} -eq 0 ]; then
191+ echo "::error::no Quasar.toml found for $project"
192+ echo "$project: no Quasar.toml found with $solana_version" >> $GITHUB_WORKSPACE/failed_projects.txt
186193 cd - > /dev/null
187194 return 1
188195 fi
189196
197+ # Build every program first.
198+ for d in "${prog_dirs[@]}"; do
199+ if ! ( cd "$d" && quasar build ); then
200+ echo "::error::quasar build failed for $project ($d)"
201+ echo "$project: quasar build failed with $solana_version" >> $GITHUB_WORKSPACE/failed_projects.txt
202+ cd - > /dev/null
203+ return 1
204+ fi
205+ done
206+
207+ # Then run Rust tests (quasar examples use cargo test with quasar-svm).
208+ for d in "${prog_dirs[@]}"; do
209+ if ! ( cd "$d" && cargo test ); then
210+ echo "::error::cargo test failed for $project ($d)"
211+ echo "$project: cargo test failed with $solana_version" >> $GITHUB_WORKSPACE/failed_projects.txt
212+ cd - > /dev/null
213+ return 1
214+ fi
215+ done
216+
190217 echo "Build and tests succeeded for $project with $solana_version version."
191218 cd - > /dev/null
192219 return 0
0 commit comments