Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add toolchain file usage #29370

Merged
merged 5 commits into from
Jan 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ci/do-audit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ cargo_audit_ignores=(
# https://github.com/solana-labs/solana/issues/29586
--ignore RUSTSEC-2023-0001
)
scripts/cargo-for-all-lock-files.sh stable audit "${cargo_audit_ignores[@]}"
scripts/cargo-for-all-lock-files.sh audit "${cargo_audit_ignores[@]}"
6 changes: 2 additions & 4 deletions ci/publish-crate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ cd "$(dirname "$0")/.."
source ci/semver_bash/semver.sh
source ci/rust-version.sh stable

cargo="$(readlink -f ./cargo)"

# shellcheck disable=SC2086
is_crate_version_uploaded() {
name=$1
Expand Down Expand Up @@ -68,11 +66,11 @@ for Cargo_toml in $Cargo_tomls; do
(
set -x
rm -rf crate-test
"$cargo" stable init crate-test
cargo init crate-test
cd crate-test/
echo "${crate_name} = \"=${expectedCrateVersion}\"" >> Cargo.toml
echo "[workspace]" >> Cargo.toml
"$cargo" stable check
cargo check
) && really_uploaded=1
if ((really_uploaded)); then
break;
Expand Down
27 changes: 15 additions & 12 deletions ci/test-bench.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/usr/bin/env bash
# To prevent usange of `./cargo` without `nightly`
# Introduce cargoNighlty and disable warning to use word splitting
# shellcheck disable=SC2086
set -e
cd "$(dirname "$0")/.."

Expand All @@ -7,7 +10,7 @@ source ci/upload-ci-artifact.sh

eval "$(ci/channel-info.sh)"

cargo="$(readlink -f "./cargo")"
cargoNightly="$(readlink -f "./cargo") nightly"

set -o pipefail
export RUST_BACKTRACE=1
Expand All @@ -24,51 +27,51 @@ BENCH_FILE=bench_output.log
BENCH_ARTIFACT=current_bench_results.log

# solana-keygen required when building C programs
_ "$cargo" build --manifest-path=keygen/Cargo.toml
_ cargo build --manifest-path=keygen/Cargo.toml
export PATH="$PWD/target/debug":$PATH

# Clear the C dependency files, if dependency moves these files are not regenerated
test -d target/debug/sbf && find target/debug/sbf -name '*.d' -delete
test -d target/release/sbf && find target/release/sbf -name '*.d' -delete

# Ensure all dependencies are built
_ "$cargo" nightly build --release
_ $cargoNightly build --release

# Remove "BENCH_FILE", if it exists so that the following commands can append
rm -f "$BENCH_FILE"

# Run sdk benches
_ "$cargo" nightly bench --manifest-path sdk/Cargo.toml ${V:+--verbose} \
_ $cargoNightly bench --manifest-path sdk/Cargo.toml ${V:+--verbose} \
-- -Z unstable-options --format=json | tee -a "$BENCH_FILE"

# Run runtime benches
_ "$cargo" nightly bench --manifest-path runtime/Cargo.toml ${V:+--verbose} \
_ $cargoNightly bench --manifest-path runtime/Cargo.toml ${V:+--verbose} \
-- -Z unstable-options --format=json | tee -a "$BENCH_FILE"

# Run gossip benches
_ "$cargo" nightly bench --manifest-path gossip/Cargo.toml ${V:+--verbose} \
_ $cargoNightly bench --manifest-path gossip/Cargo.toml ${V:+--verbose} \
-- -Z unstable-options --format=json | tee -a "$BENCH_FILE"

# Run poh benches
_ "$cargo" nightly bench --manifest-path poh/Cargo.toml ${V:+--verbose} \
_ $cargoNightly bench --manifest-path poh/Cargo.toml ${V:+--verbose} \
-- -Z unstable-options --format=json | tee -a "$BENCH_FILE"

# Run core benches
_ "$cargo" nightly bench --manifest-path core/Cargo.toml ${V:+--verbose} \
_ $cargoNightly bench --manifest-path core/Cargo.toml ${V:+--verbose} \
-- -Z unstable-options --format=json | tee -a "$BENCH_FILE"

# Run sbf benches
_ "$cargo" nightly bench --manifest-path programs/sbf/Cargo.toml ${V:+--verbose} --features=sbf_c \
_ $cargoNightly bench --manifest-path programs/sbf/Cargo.toml ${V:+--verbose} --features=sbf_c \
-- -Z unstable-options --format=json --nocapture | tee -a "$BENCH_FILE"

# Run banking/accounts bench. Doesn't require nightly, but use since it is already built.
_ "$cargo" nightly run --release --manifest-path banking-bench/Cargo.toml ${V:+--verbose} | tee -a "$BENCH_FILE"
_ "$cargo" nightly run --release --manifest-path accounts-bench/Cargo.toml ${V:+--verbose} -- --num_accounts 10000 --num_slots 4 | tee -a "$BENCH_FILE"
_ $cargoNightly run --release --manifest-path banking-bench/Cargo.toml ${V:+--verbose} | tee -a "$BENCH_FILE"
_ $cargoNightly run --release --manifest-path accounts-bench/Cargo.toml ${V:+--verbose} -- --num_accounts 10000 --num_slots 4 | tee -a "$BENCH_FILE"

# `solana-upload-perf` disabled as it can take over 30 minutes to complete for some
# reason
exit 0
_ "$cargo" nightly run --release --package solana-upload-perf \
_ $cargoNightly run --release --package solana-upload-perf \
-- "$BENCH_FILE" "$TARGET_BRANCH" "$UPLOAD_METRICS" | tee "$BENCH_ARTIFACT"

upload-ci-artifact "$BENCH_FILE"
Expand Down
25 changes: 14 additions & 11 deletions ci/test-checks.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/usr/bin/env bash
# To prevent usange of `./cargo` without `nightly`
# Introduce cargoNighlty and disable warning to use word splitting
# shellcheck disable=SC2086

set -e

Expand All @@ -8,7 +11,7 @@ source ci/_
source ci/rust-version.sh stable
source ci/rust-version.sh nightly
eval "$(ci/channel-info.sh)"
cargo="$(readlink -f "./cargo")"
cargoNightly="$(readlink -f "./cargo") nightly"

scripts/increment-cargo-version.sh check

Expand All @@ -33,14 +36,14 @@ echo --- build environment
rustup run "$rust_stable" rustc --version --verbose
rustup run "$rust_nightly" rustc --version --verbose

"$cargo" stable --version --verbose
"$cargo" nightly --version --verbose
cargo --version --verbose
$cargoNightly --version --verbose

"$cargo" stable clippy --version --verbose
"$cargo" nightly clippy --version --verbose
cargo clippy --version --verbose
$cargoNightly clippy --version --verbose

# audit is done only with "$cargo stable"
"$cargo" stable audit --version
cargo audit --version

grcov --version
)
Expand All @@ -51,7 +54,7 @@ export RUSTFLAGS="-D warnings -A incomplete_features"
# Only force up-to-date lock files on edge
if [[ $CI_BASE_BRANCH = "$EDGE_CHANNEL" ]]; then
# Exclude --benches as it's not available in rust stable yet
if _ scripts/cargo-for-all-lock-files.sh stable check --locked --tests --bins --examples; then
if _ scripts/cargo-for-all-lock-files.sh check --locked --tests --bins --examples; then
true
else
check_status=$?
Expand All @@ -62,7 +65,7 @@ if [[ $CI_BASE_BRANCH = "$EDGE_CHANNEL" ]]; then
fi

# Ensure nightly and --benches
_ scripts/cargo-for-all-lock-files.sh nightly check --locked --all-targets
_ scripts/cargo-for-all-lock-files.sh "+${rust_nightly}" check --locked --all-targets
else
echo "Note: cargo-for-all-lock-files.sh skipped because $CI_BASE_BRANCH != $EDGE_CHANNEL"
fi
Expand All @@ -73,13 +76,13 @@ nightly_clippy_allows=()

# -Z... is needed because of clippy bug: https://github.com/rust-lang/rust-clippy/issues/4612
# run nightly clippy for `sdk/` as there's a moderate amount of nightly-only code there
_ scripts/cargo-for-all-lock-files.sh -- nightly clippy -Zunstable-options --all-targets -- \
_ scripts/cargo-for-all-lock-files.sh -- "+${rust_nightly}" clippy -Zunstable-options --all-targets -- \
--deny=warnings \
--deny=clippy::integer_arithmetic \
"${nightly_clippy_allows[@]}"

_ scripts/cargo-for-all-lock-files.sh -- nightly sort --workspace --check
_ scripts/cargo-for-all-lock-files.sh -- nightly fmt --all -- --check
_ scripts/cargo-for-all-lock-files.sh -- "+${rust_nightly}" sort --workspace --check
_ scripts/cargo-for-all-lock-files.sh -- "+${rust_nightly}" fmt --all -- --check

_ ci/do-audit.sh

Expand Down
48 changes: 24 additions & 24 deletions ci/test-stable.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ echo "Executing $testName"
case $testName in
test-stable)
if need_to_generate_test_result; then
_ "$cargo" stable test --jobs "$JOBS" --all --tests --exclude solana-local-cluster ${V:+--verbose} -- -Z unstable-options --format json --report-time | tee results.json
_ cargo test --jobs "$JOBS" --all --tests --exclude solana-local-cluster ${V:+--verbose} -- -Z unstable-options --format json --report-time | tee results.json
exit_if_error "${PIPESTATUS[0]}"
else
_ "$cargo" stable test --jobs "$JOBS" --all --tests --exclude solana-local-cluster ${V:+--verbose} -- --nocapture
_ cargo test --jobs "$JOBS" --all --tests --exclude solana-local-cluster ${V:+--verbose} -- --nocapture
fi
;;
test-stable-sbf)
Expand All @@ -89,12 +89,12 @@ test-stable-sbf)
# SBF C program system tests
_ make -C programs/sbf/c tests
if need_to_generate_test_result; then
_ "$cargo" stable test \
_ cargo test \
--manifest-path programs/sbf/Cargo.toml \
--no-default-features --features=sbf_c,sbf_rust -- -Z unstable-options --format json --report-time | tee results.json
exit_if_error "${PIPESTATUS[0]}"
else
_ "$cargo" stable test \
_ cargo test \
--manifest-path programs/sbf/Cargo.toml \
--no-default-features --features=sbf_c,sbf_rust -- --nocapture
fi
Expand Down Expand Up @@ -131,13 +131,13 @@ test-stable-sbf)
# SBF program instruction count assertion
sbf_target_path=programs/sbf/target
if need_to_generate_test_result; then
_ "$cargo" stable test \
_ cargo test \
--manifest-path programs/sbf/Cargo.toml \
--no-default-features --features=sbf_c,sbf_rust assert_instruction_count \
-- -Z unstable-options --format json --report-time |& tee results.json
awk '!/{ "type": .* }/' results.json >"${sbf_target_path}"/deploy/instuction_counts.txt
else
_ "$cargo" stable test \
_ cargo test \
--manifest-path programs/sbf/Cargo.toml \
--no-default-features --features=sbf_c,sbf_rust assert_instruction_count \
-- --nocapture &> "${sbf_target_path}"/deploy/instuction_counts.txt
Expand Down Expand Up @@ -165,52 +165,52 @@ test-stable-perf)
export SOLANA_CUDA=1
fi

_ "$cargo" stable build --bins ${V:+--verbose}
_ cargo build --bins ${V:+--verbose}
if need_to_generate_test_result; then
_ "$cargo" stable test --package solana-perf --package solana-ledger --package solana-core --lib ${V:+--verbose} -- -Z unstable-options --format json --report-time | tee results.json
_ cargo test --package solana-perf --package solana-ledger --package solana-core --lib ${V:+--verbose} -- -Z unstable-options --format json --report-time | tee results.json
exit_if_error "${PIPESTATUS[0]}"
else
_ "$cargo" stable test --package solana-perf --package solana-ledger --package solana-core --lib ${V:+--verbose} -- --nocapture
_ cargo test --package solana-perf --package solana-ledger --package solana-core --lib ${V:+--verbose} -- --nocapture
fi
_ "$cargo" stable run --manifest-path poh-bench/Cargo.toml ${V:+--verbose} -- --hashes-per-tick 10
_ cargo run --manifest-path poh-bench/Cargo.toml ${V:+--verbose} -- --hashes-per-tick 10
;;
test-local-cluster)
_ "$cargo" stable build --release --bins ${V:+--verbose}
_ cargo build --release --bins ${V:+--verbose}
if need_to_generate_test_result; then
_ "$cargo" stable test --release --package solana-local-cluster --test local_cluster ${V:+--verbose} -- --test-threads=1 -Z unstable-options --format json --report-time | tee results.json
_ cargo test --release --package solana-local-cluster --test local_cluster ${V:+--verbose} -- --test-threads=1 -Z unstable-options --format json --report-time | tee results.json
exit_if_error "${PIPESTATUS[0]}"
else
_ "$cargo" stable test --release --package solana-local-cluster --test local_cluster ${V:+--verbose} -- --nocapture --test-threads=1
_ cargo test --release --package solana-local-cluster --test local_cluster ${V:+--verbose} -- --nocapture --test-threads=1
fi
exit 0
;;
test-local-cluster-flakey)
_ "$cargo" stable build --release --bins ${V:+--verbose}
_ cargo build --release --bins ${V:+--verbose}
if need_to_generate_test_result; then
_ "$cargo" stable test --release --package solana-local-cluster --test local_cluster_flakey ${V:+--verbose} -- --test-threads=1 -Z unstable-options --format json --report-time | tee results.json
_ cargo test --release --package solana-local-cluster --test local_cluster_flakey ${V:+--verbose} -- --test-threads=1 -Z unstable-options --format json --report-time | tee results.json
exit_if_error "${PIPESTATUS[0]}"
else
_ "$cargo" stable test --release --package solana-local-cluster --test local_cluster_flakey ${V:+--verbose} -- --nocapture --test-threads=1
_ cargo test --release --package solana-local-cluster --test local_cluster_flakey ${V:+--verbose} -- --nocapture --test-threads=1
fi
exit 0
;;
test-local-cluster-slow-1)
_ "$cargo" stable build --release --bins ${V:+--verbose}
_ cargo build --release --bins ${V:+--verbose}
if need_to_generate_test_result; then
_ "$cargo" stable test --release --package solana-local-cluster --test local_cluster_slow_1 ${V:+--verbose} -- --test-threads=1 -Z unstable-options --format json --report-time | tee results.json
_ cargo test --release --package solana-local-cluster --test local_cluster_slow_1 ${V:+--verbose} -- --test-threads=1 -Z unstable-options --format json --report-time | tee results.json
exit_if_error "${PIPESTATUS[0]}"
else
_ "$cargo" stable test --release --package solana-local-cluster --test local_cluster_slow_1 ${V:+--verbose} -- --nocapture --test-threads=1
_ cargo test --release --package solana-local-cluster --test local_cluster_slow_1 ${V:+--verbose} -- --nocapture --test-threads=1
fi
exit 0
;;
test-local-cluster-slow-2)
_ "$cargo" stable build --release --bins ${V:+--verbose}
_ cargo build --release --bins ${V:+--verbose}
if need_to_generate_test_result; then
_ "$cargo" stable test --release --package solana-local-cluster --test local_cluster_slow_2 ${V:+--verbose} -- --test-threads=1 -Z unstable-options --format json --report-time | tee results.json
_ cargo test --release --package solana-local-cluster --test local_cluster_slow_2 ${V:+--verbose} -- --test-threads=1 -Z unstable-options --format json --report-time | tee results.json
exit_if_error "${PIPESTATUS[0]}"
else
_ "$cargo" stable test --release --package solana-local-cluster --test local_cluster_slow_2 ${V:+--verbose} -- --nocapture --test-threads=1
_ cargo test --release --package solana-local-cluster --test local_cluster_slow_2 ${V:+--verbose} -- --nocapture --test-threads=1
fi
exit 0
;;
Expand All @@ -229,10 +229,10 @@ test-wasm)
;;
test-docs)
if need_to_generate_test_result; then
_ "$cargo" stable test --jobs "$JOBS" --all --doc --exclude solana-local-cluster ${V:+--verbose} -- -Z unstable-options --format json --report-time | tee results.json
_ cargo test --jobs "$JOBS" --all --doc --exclude solana-local-cluster ${V:+--verbose} -- -Z unstable-options --format json --report-time | tee results.json
exit "${PIPESTATUS[0]}"
else
_ "$cargo" stable test --jobs "$JOBS" --all --doc --exclude solana-local-cluster ${V:+--verbose} -- --nocapture
_ cargo test --jobs "$JOBS" --all --doc --exclude solana-local-cluster ${V:+--verbose} -- --nocapture
exit 0
fi
;;
Expand Down
7 changes: 2 additions & 5 deletions scripts/cargo-for-all-lock-files.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#!/usr/bin/env bash

here="$(dirname "$0")"
cargo="$(readlink -f "${here}/../cargo")"

if [[ -z $cargo ]]; then
if ! command -v cargo &> /dev/null ; then
>&2 echo "Failed to find cargo. Mac readlink doesn't support -f. Consider switching
to gnu readlink with 'brew install coreutils' and then symlink greadlink as
/usr/local/bin/readlink."
Expand Down Expand Up @@ -47,7 +44,7 @@ for lock_file in $files; do
echo "--- [$lock_file]: cargo " "${shifted_args[@]}" "$@"
fi

if (set -x && cd "$(dirname "$lock_file")" && "$cargo" "${shifted_args[@]}" "$@"); then
if (set -x && cd "$(dirname "$lock_file")" && cargo "${shifted_args[@]}" "$@"); then
# noop
true
else
Expand Down