From de9e7958e2ab43c7013143c928d4f952ab0a71fa Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 5 Jun 2026 18:49:41 +0000 Subject: [PATCH] ci(quasar): support multi-program projects; re-enable cross-program-invocation/quasar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- .github/.ghaignore | 2 -- .github/workflows/quasar.yml | 47 ++++++++++++++++++++++++++++-------- 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/.github/.ghaignore b/.github/.ghaignore index f94cb08a..cf5190de 100644 --- a/.github/.ghaignore +++ b/.github/.ghaignore @@ -12,8 +12,6 @@ compression/cnft-vault/anchor # builds but need to test on localhost compression/cnft-burn/anchor -# CPI quasar project uses subdirectories (hand/ and lever/) instead of a root Quasar.toml -basics/cross-program-invocation/quasar # build failed - program outdated diff --git a/.github/workflows/quasar.yml b/.github/workflows/quasar.yml index dbfc48b1..609b913a 100644 --- a/.github/workflows/quasar.yml +++ b/.github/workflows/quasar.yml @@ -171,22 +171,49 @@ jobs: echo "Building and Testing $project with Solana $solana_version" cd "$project" || return 1 - # Build with quasar CLI - if ! quasar build; then - echo "::error::quasar build failed for $project" - echo "$project: quasar build failed with $solana_version" >> $GITHUB_WORKSPACE/failed_projects.txt - cd - > /dev/null - return 1 + # Determine the quasar program directories for this project. Normally + # the project dir itself holds the Quasar.toml. Some examples (e.g. the + # cross-program-invocation CPI demo) instead contain several program + # subdirectories (hand/, lever/), each its own Quasar project. In that + # case build them all *first*, then test them all, so a program whose + # tests load a sibling program's compiled .so (the CPI callee) has it + # available regardless of directory order. + local prog_dirs=() + if [ -f Quasar.toml ]; then + prog_dirs=(".") + else + for d in */; do + [ -f "${d}Quasar.toml" ] && prog_dirs+=("${d%/}") + done fi - # Run Rust tests (quasar examples use cargo test with quasar-svm) - if ! cargo test; then - echo "::error::cargo test failed for $project" - echo "$project: cargo test failed with $solana_version" >> $GITHUB_WORKSPACE/failed_projects.txt + if [ ${#prog_dirs[@]} -eq 0 ]; then + echo "::error::no Quasar.toml found for $project" + echo "$project: no Quasar.toml found with $solana_version" >> $GITHUB_WORKSPACE/failed_projects.txt cd - > /dev/null return 1 fi + # Build every program first. + for d in "${prog_dirs[@]}"; do + if ! ( cd "$d" && quasar build ); then + echo "::error::quasar build failed for $project ($d)" + echo "$project: quasar build failed with $solana_version" >> $GITHUB_WORKSPACE/failed_projects.txt + cd - > /dev/null + return 1 + fi + done + + # Then run Rust tests (quasar examples use cargo test with quasar-svm). + for d in "${prog_dirs[@]}"; do + if ! ( cd "$d" && cargo test ); then + echo "::error::cargo test failed for $project ($d)" + echo "$project: cargo test failed with $solana_version" >> $GITHUB_WORKSPACE/failed_projects.txt + cd - > /dev/null + return 1 + fi + done + echo "Build and tests succeeded for $project with $solana_version version." cd - > /dev/null return 0