From d2f3b971a5926203e05c76f550f327f7e283effb Mon Sep 17 00:00:00 2001 From: Kirill Lykov Date: Sun, 18 Dec 2022 13:14:17 +0000 Subject: [PATCH] introduce cargo-nightly --- cargo-nightly | 8 ++++++++ ci/test-bench.sh | 21 +++++++++++---------- ci/test-checks.sh | 5 +++-- scripts/cargo-fmt.sh | 18 +++++++++--------- scripts/coverage-in-disk.sh | 6 +++--- scripts/coverage.sh | 6 +++--- 6 files changed, 37 insertions(+), 27 deletions(-) create mode 100755 cargo-nightly diff --git a/cargo-nightly b/cargo-nightly new file mode 100755 index 00000000000000..5ec97df06be372 --- /dev/null +++ b/cargo-nightly @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +# shellcheck source=ci/rust-version.sh +here=$(dirname "$0") + +source "${here}"/ci/rust-version.sh nightly +set -x +exec cargo "+${rust_nightly}" "${@}" diff --git a/ci/test-bench.sh b/ci/test-bench.sh index 1bb18f02eac790..037fdb707792a6 100755 --- a/ci/test-bench.sh +++ b/ci/test-bench.sh @@ -8,6 +8,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 @@ -32,43 +33,43 @@ 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" diff --git a/ci/test-checks.sh b/ci/test-checks.sh index 3dc7c194a4cdc9..72780c9c974364 100755 --- a/ci/test-checks.sh +++ b/ci/test-checks.sh @@ -9,6 +9,7 @@ source ci/rust-version.sh stable source ci/rust-version.sh nightly eval "$(ci/channel-info.sh)" cargo="$(readlink -f "./cargo")" +cargo="$(readlink -f "./cargo-nightly")" scripts/increment-cargo-version.sh check @@ -34,10 +35,10 @@ echo --- build environment rustup run "$rust_nightly" rustc --version --verbose "$cargo" stable --version --verbose - "$cargo" nightly --version --verbose + "$cargoNightly" --version --verbose "$cargo" stable clippy --version --verbose - "$cargo" nightly clippy --version --verbose + "$cargoNightly" clippy --version --verbose # audit is done only with "$cargo stable" "$cargo" stable audit --version diff --git a/scripts/cargo-fmt.sh b/scripts/cargo-fmt.sh index f8df585b21ea29..5e63bbe3f0b5d3 100755 --- a/scripts/cargo-fmt.sh +++ b/scripts/cargo-fmt.sh @@ -1,10 +1,10 @@ #!/usr/bin/env bash here="$(dirname "$0")" -cargo="$(readlink -f "${here}/../cargo")" +cargoNightly="$(readlink -f "${here}/../cargo")" -if [[ -z $cargo ]]; then - >&2 echo "Failed to find cargo. Mac readlink doesn't support -f. Consider switching +if [[ -z $cargoNightly ]]; then + >&2 echo "Failed to find cargo-nightly. Mac readlink doesn't support -f. Consider switching to gnu readlink with 'brew install coreutils' and then symlink greadlink as /usr/local/bin/readlink." exit 1 @@ -12,9 +12,9 @@ fi set -ex -"$cargo" nightly fmt --all -(cd programs/sbf && "$cargo" nightly fmt --all) -(cd sdk/cargo-build-sbf/tests/crates/fail && "$cargo" nightly fmt --all) -(cd sdk/cargo-build-sbf/tests/crates/noop && "$cargo" nightly fmt --all) -(cd storage-bigtable/build-proto && "$cargo" nightly fmt --all) -(cd web3.js/test/fixtures/noop-program && "$cargo" nightly fmt --all) +"$cargoNightly" fmt --all +(cd programs/sbf && "$cargoNightly" fmt --all) +(cd sdk/cargo-build-sbf/tests/crates/fail && "$cargoNightly" fmt --all) +(cd sdk/cargo-build-sbf/tests/crates/noop && "$cargoNightly" fmt --all) +(cd storage-bigtable/build-proto && "$cargoNightly" fmt --all) +(cd web3.js/test/fixtures/noop-program && "$cargoNightly" fmt --all) diff --git a/scripts/coverage-in-disk.sh b/scripts/coverage-in-disk.sh index 5d472bd5c223da..0d54a242f042bf 100644 --- a/scripts/coverage-in-disk.sh +++ b/scripts/coverage-in-disk.sh @@ -21,7 +21,7 @@ set -e cd "$(dirname "$0")/.." source ci/_ -cargo="$(readlink -f "./cargo")" +cargoNightly="$(readlink -f "./cargo-nightly")" : "${CI_COMMIT:=local}" reportName="lcov-${CI_COMMIT:0:9}" @@ -79,8 +79,8 @@ fi NPROC=$(nproc) JOBS=$((JOBS>NPROC ? NPROC : JOBS)) -RUST_LOG=solana=trace _ "$cargo" nightly test --jobs "$JOBS" --target-dir target/cov --no-run "${packages[@]}" -if RUST_LOG=solana=trace _ "$cargo" nightly test --jobs "$JOBS" --target-dir target/cov "${packages[@]}" 2> target/cov/coverage-stderr.log; then +RUST_LOG=solana=trace _ "$cargoNightly" test --jobs "$JOBS" --target-dir target/cov --no-run "${packages[@]}" +if RUST_LOG=solana=trace _ "$cargoNightly" test --jobs "$JOBS" --target-dir target/cov "${packages[@]}" 2> target/cov/coverage-stderr.log; then test_status=0 else test_status=$? diff --git a/scripts/coverage.sh b/scripts/coverage.sh index 059ddc2e20c654..183b7c0abea76a 100755 --- a/scripts/coverage.sh +++ b/scripts/coverage.sh @@ -21,7 +21,7 @@ set -e cd "$(dirname "$0")/.." source ci/_ -cargo="$(readlink -f "./cargo")" +cargoNightly="$(readlink -f "./cargo-nightly")" : "${CI_COMMIT:=local}" reportName="lcov-${CI_COMMIT:0:9}" @@ -78,8 +78,8 @@ fi NPROC=$(nproc) JOBS=$((JOBS>NPROC ? NPROC : JOBS)) -RUST_LOG=solana=trace _ "$cargo" nightly test --jobs "$JOBS" --target-dir target/cov --no-run "${packages[@]}" -if RUST_LOG=solana=trace _ "$cargo" nightly test --jobs "$JOBS" --target-dir target/cov "${packages[@]}" -- --nocapture 2> >(tee target/cov/coverage-stderr.log >&2); then +RUST_LOG=solana=trace _ "$cargoNightly" test --jobs "$JOBS" --target-dir target/cov --no-run "${packages[@]}" +if RUST_LOG=solana=trace _ "$cargoNightly" test --jobs "$JOBS" --target-dir target/cov "${packages[@]}" -- --nocapture 2> >(tee target/cov/coverage-stderr.log >&2); then test_status=0 else test_status=$?