Skip to content

Commit de9e795

Browse files
committed
ci(quasar): support multi-program projects; re-enable cross-program-invocation/quasar
The CPI quasar example contains two separate Quasar programs (hand/ and lever/) rather than a single program with a root Quasar.toml, so the Quasar workflow — which ran `quasar build && cargo test` directly in the project dir — failed (quasar build requires ./src/lib.rs and is single-program only), and the example was excluded in .ghaignore. Teach the workflow's build_and_test to detect a project's program directories: the project itself when it has a Quasar.toml (unchanged for every existing example), otherwise its immediate subdirectories that each contain one. It now builds all of a project's programs first, then tests them all — so hand's test, which loads lever's freshly-built .so to exercise the CPI, finds it regardless of directory order (the 47 quasar projects shard across parallel jobs, so cross-project build order can't be relied on). Verified locally with the quasar CLI: both programs build and all tests pass (hand 3, lever 4). Drop the example from .github/.ghaignore.
1 parent e4faaa5 commit de9e795

2 files changed

Lines changed: 37 additions & 12 deletions

File tree

.github/.ghaignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ compression/cnft-vault/anchor
1212
# builds but need to test on localhost
1313
compression/cnft-burn/anchor
1414

15-
# CPI quasar project uses subdirectories (hand/ and lever/) instead of a root Quasar.toml
16-
basics/cross-program-invocation/quasar
1715

1816

1917
# build failed - program outdated

.github/workflows/quasar.yml

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)