ci: Add Anchor and Anchor projects to the downstream build (#22098)

* ci: Add Anchor and Anchor projects to the downstream build

* Separate downstream anchor projects into separate step

* Decrease anchor project build time
This commit is contained in:
Jon Cinque
2022-01-11 00:21:53 +01:00
committed by GitHub
parent 49da347d84
commit ec364cc737
4 changed files with 162 additions and 28 deletions

View File

@ -6,6 +6,7 @@
set -e
cd "$(dirname "$0")"/..
source ci/_
source scripts/patch-crates.sh
source scripts/read-cargo-variable.sh
solana_ver=$(readCargoVariable version sdk/Cargo.toml)
@ -17,28 +18,6 @@ cargo_test_bpf="$solana_dir"/cargo-test-bpf
mkdir -p target/downstream-projects
cd target/downstream-projects
update_solana_dependencies() {
declare tomls=()
while IFS='' read -r line; do tomls+=("$line"); done < <(find "$1" -name Cargo.toml)
sed -i -e "s#\(solana-program = \"\)[^\"]*\(\"\)#\1=$solana_ver\2#g" "${tomls[@]}" || return $?
sed -i -e "s#\(solana-program-test = \"\)[^\"]*\(\"\)#\1=$solana_ver\2#g" "${tomls[@]}" || return $?
sed -i -e "s#\(solana-sdk = \"\).*\(\"\)#\1=$solana_ver\2#g" "${tomls[@]}" || return $?
sed -i -e "s#\(solana-sdk = { version = \"\)[^\"]*\(\"\)#\1=$solana_ver\2#g" "${tomls[@]}" || return $?
sed -i -e "s#\(solana-client = \"\)[^\"]*\(\"\)#\1=$solana_ver\2#g" "${tomls[@]}" || return $?
sed -i -e "s#\(solana-client = { version = \"\)[^\"]*\(\"\)#\1=$solana_ver\2#g" "${tomls[@]}" || return $?
}
patch_crates_io() {
cat >> "$1" <<EOF
[patch.crates-io]
solana-client = { path = "$solana_dir/client" }
solana-program = { path = "$solana_dir/sdk/program" }
solana-program-test = { path = "$solana_dir/program-test" }
solana-sdk = { path = "$solana_dir/sdk" }
EOF
}
example_helloworld() {
(
set -x
@ -46,8 +25,8 @@ example_helloworld() {
git clone https://github.com/solana-labs/example-helloworld.git
cd example-helloworld
update_solana_dependencies src/program-rust
patch_crates_io src/program-rust/Cargo.toml
update_solana_dependencies src/program-rust "$solana_ver"
patch_crates_io_solana src/program-rust/Cargo.toml "$solana_dir"
echo "[workspace]" >> src/program-rust/Cargo.toml
$cargo_build_bpf \
@ -80,9 +59,9 @@ serum_dex() {
git clone https://github.com/project-serum/serum-dex.git
cd serum-dex
update_solana_dependencies .
patch_crates_io Cargo.toml
patch_crates_io dex/Cargo.toml
update_solana_dependencies . "$solana_ver"
patch_crates_io_solana Cargo.toml "$solana_dir"
patch_crates_io_solana dex/Cargo.toml "$solana_dir"
cat >> dex/Cargo.toml <<EOF
[workspace]
exclude = [
@ -100,7 +79,6 @@ EOF
)
}
_ example_helloworld
_ spl
_ serum_dex