Skip to content

Commit

Permalink
ci: update anchor downstream project (#35274)
Browse files Browse the repository at this point in the history
* Update build downstream projects script (#35262)

* fix patch-crates.sh doesn't pass the real variables

* fix downstream project anchor doesn't be triggered correctly

---------

Co-authored-by: Lucas Steuernagel <[email protected]>
  • Loading branch information
yihau and LucasSte authored Feb 21, 2024
1 parent 14453eb commit d223a43
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 20 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/downstream-project-anchor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ on:
- "cargo-test-bpf"
- "cargo-build-sbf"
- "cargo-test-sbf"
- "scripts/build-downstream-anchor-projects.sh"
- ".github/scripts/purge-ubuntu-runner.sh"
- ".github/scripts/downstream-project-spl-install-deps.sh"
- ".github/workflows/downstream-project-anchor.yml"
workflow_call:
inputs:
Expand Down
45 changes: 25 additions & 20 deletions scripts/build-downstream-anchor-projects.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,25 +68,27 @@ anchor() {
cd "$solana_dir"/target/downstream-projects-anchor
}

openbook() {
# Openbook-v2 is still using cargo 1.70.0, which is not compatible with the latest main
rm -rf openbook-v2
git clone https://github.com/openbook-dex/openbook-v2.git
cd openbook-v2
update_solana_dependencies . "$solana_ver"
patch_crates_io_solana Cargo.toml "$solana_dir"
$cargo_build_sbf --features enable-gpl
cd programs/openbook-v2
$cargo_test_sbf --features enable-gpl
}

mango() {
(
set -x
rm -rf mango-v3
git clone https://github.com/blockworks-foundation/mango-v3
# copy toolchain file to use solana's rust version
cp "$solana_dir"/rust-toolchain.toml mango-v3/
cd mango-v3

rm -rf mango-v4
git clone https://github.com/blockworks-foundation/mango-v4.git
cd mango-v4
update_solana_dependencies . "$solana_ver"
update_anchor_dependencies . "$anchor_ver"
patch_crates_io_solana Cargo.toml "$solana_dir"
patch_crates_io_anchor Cargo.toml "$anchor_dir"

cd program
$cargo build
$cargo test
$cargo_build_sbf
$cargo_test_sbf
patch_crates_io_solana_no_header Cargo.toml "$solana_dir"
$cargo_test_sbf --features enable-gpl
)
}

Expand All @@ -97,18 +99,21 @@ metaplex() {
git clone https://github.com/metaplex-foundation/mpl-token-metadata
# copy toolchain file to use solana's rust version
cp "$solana_dir"/rust-toolchain.toml mpl-token-metadata/
cd mpl-token-metadata/programs/token-metadata/program
cd mpl-token-metadata
./configs/program-scripts/dump.sh ./programs/bin
ROOT_DIR=$(pwd)
cd programs/token-metadata

update_solana_dependencies . "$solana_ver"
patch_crates_io_solana Cargo.toml "$solana_dir"

$cargo build
$cargo test
$cargo_build_sbf
$cargo_test_sbf
OUT_DIR="$ROOT_DIR"/programs/bin
export SBF_OUT_DIR="$OUT_DIR"
$cargo_test_sbf --sbf-out-dir "${OUT_DIR}"
)
}

_ anchor
#_ metaplex
#_ mango
#_ openbook
8 changes: 8 additions & 0 deletions scripts/patch-crates.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ patch_crates_io_solana() {
declare solana_dir="$2"
cat >> "$Cargo_toml" <<EOF
[patch.crates-io]
EOF
patch_crates_io_solana_no_header "$Cargo_toml" "$solana_dir"
}

patch_crates_io_solana_no_header() {
declare Cargo_toml="$1"
declare solana_dir="$2"
cat >> "$Cargo_toml" <<EOF
solana-account-decoder = { path = "$solana_dir/account-decoder" }
solana-clap-utils = { path = "$solana_dir/clap-utils" }
solana-client = { path = "$solana_dir/client" }
Expand Down

0 comments on commit d223a43

Please sign in to comment.