Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

Commit 0683101

Browse files
committed
ci: test-checks.sh all sbf code & use nightly only
1 parent 3a97986 commit 0683101

File tree

35 files changed

+78
-17
lines changed

35 files changed

+78
-17
lines changed

ci/test-checks.sh

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,12 @@ echo --- build environment
5151
export RUST_BACKTRACE=1
5252
export RUSTFLAGS="-D warnings -A incomplete_features"
5353

54+
# run cargo check for all rust files in this monorepo for faster turnaround in
55+
# case of any compilation/build error for nightly
56+
5457
# Only force up-to-date lock files on edge
5558
if [[ $CI_BASE_BRANCH = "$EDGE_CHANNEL" ]]; then
56-
# Exclude --benches as it's not available in rust stable yet
57-
if _ scripts/cargo-for-all-lock-files.sh check --locked --tests --bins --examples; then
59+
if _ scripts/cargo-for-all-lock-files.sh "+${rust_nightly}" check --locked --workspace --all-targets --features dummy-for-ci-check; then
5860
true
5961
else
6062
check_status=$?
@@ -63,9 +65,6 @@ if [[ $CI_BASE_BRANCH = "$EDGE_CHANNEL" ]]; then
6365
echo "$0: [tree (for outdated Cargo.lock sync)|check (for compilation error)|update -p foo --precise x.y.z (for your Cargo.toml update)] ..." >&2
6466
exit "$check_status"
6567
fi
66-
67-
# Ensure nightly and --benches
68-
_ scripts/cargo-for-all-lock-files.sh "+${rust_nightly}" check --locked --all-targets
6968
else
7069
echo "Note: cargo-for-all-lock-files.sh skipped because $CI_BASE_BRANCH != $EDGE_CHANNEL"
7170
fi
@@ -76,7 +75,7 @@ nightly_clippy_allows=()
7675

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

programs/sbf/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ edition = { workspace = true }
6666
[features]
6767
sbf_c = []
6868
sbf_rust = []
69+
dummy-for-ci-check = [
70+
"sbf_c",
71+
"sbf_rust",
72+
]
6973

7074
[build-dependencies]
7175
walkdir = "2"

programs/sbf/benches/bpf_loader.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#![feature(test)]
22
#![cfg(feature = "sbf_c")]
3+
#![allow(clippy::uninlined_format_args)]
4+
#![allow(clippy::integer_arithmetic)]
35

46
use {solana_rbpf::memory_region::MemoryState, std::slice};
57

programs/sbf/build.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ fn rerun_if_changed(files: &[&str], directories: &[&str], excludes: &[&str]) {
3737
}
3838

3939
fn main() {
40+
if env::var("CARGO_FEATURE_DUMMY_FOR_CI_CHECK").is_ok() {
41+
println!("cargo:warning=(not a warning) Compiling with host toolchain for CI...");
42+
return;
43+
}
44+
4045
let sbf_c = env::var("CARGO_FEATURE_SBF_C").is_ok();
4146
if sbf_c {
4247
let install_dir = "OUT_DIR=../target/".to_string() + &env::var("PROFILE").unwrap() + "/sbf";

programs/sbf/rust/128bit/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! Example Rust-based SBF program tests loop iteration
22
3+
#![allow(clippy::integer_arithmetic)]
4+
35
extern crate solana_program;
46
use solana_program::{custom_heap_default, custom_panic_default, entrypoint::SUCCESS};
57

programs/sbf/rust/128bit_dep/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! Solana Rust-based SBF program utility functions and types
22
3+
#![allow(clippy::integer_arithmetic)]
4+
35
extern crate solana_program;
46

57
pub fn uadd(x: u128, y: u128) -> u128 {

programs/sbf/rust/alloc/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! Example Rust-based SBF program that test dynamic memory allocation
22
3+
#![allow(clippy::integer_arithmetic)]
4+
35
#[macro_use]
46
extern crate alloc;
57
use {
@@ -37,7 +39,7 @@ pub extern "C" fn entrypoint(_input: *mut u8) -> u64 {
3739
*ptr.add(i) = i as u8;
3840
}
3941
for i in 0..ITERS {
40-
assert_eq!(*ptr.add(i as usize), i as u8);
42+
assert_eq!(*ptr.add(i), i as u8);
4143
}
4244
sol_log_64(0x3, 0, 0, 0, u64::from(*ptr.add(42)));
4345
assert_eq!(*ptr.add(42), 42);

programs/sbf/rust/custom_heap/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! Example Rust-based SBF that tests out using a custom heap
22
3+
#![allow(clippy::integer_arithmetic)]
4+
35
use {
46
solana_program::{
57
account_info::AccountInfo,

programs/sbf/rust/deprecated_loader/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! Example Rust-based SBF program that supports the deprecated loader
22
33
#![allow(unreachable_code)]
4+
#![allow(clippy::integer_arithmetic)]
45

56
extern crate solana_program;
67
use solana_program::{
@@ -23,7 +24,7 @@ fn return_sstruct() -> SStruct {
2324
#[no_mangle]
2425
fn custom_panic(info: &core::panic::PanicInfo<'_>) {
2526
// Full panic reporting
26-
msg!(&format!("{}", info));
27+
msg!(&format!("{info}"));
2728
}
2829

2930
solana_program::entrypoint_deprecated!(process_instruction);

programs/sbf/rust/dup_accounts/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! Example Rust-based SBF program that tests duplicate accounts passed via accounts
22
3+
#![allow(clippy::integer_arithmetic)]
4+
35
extern crate solana_program;
46
use solana_program::{
57
account_info::AccountInfo,

programs/sbf/rust/external_spend/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! Example Rust-based SBF program that moves a lamport from one account to another
22
3+
#![allow(clippy::integer_arithmetic)]
4+
35
extern crate solana_program;
46
use solana_program::{account_info::AccountInfo, entrypoint::ProgramResult, pubkey::Pubkey};
57

programs/sbf/rust/inner_instruction_alignment_check/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,5 @@ custom_heap_default!();
4040
#[no_mangle]
4141
fn custom_panic(info: &core::panic::PanicInfo<'_>) {
4242
// Full panic reporting
43-
msg!(&format!("{}", info));
43+
msg!(&format!("{info}"));
4444
}

programs/sbf/rust/instruction_introspection/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ fn process_instruction(
4242
msg!(&format!("id: {}", instruction.program_id));
4343

4444
msg!(&format!("data[0]: {}", instruction.data[0]));
45-
msg!(&format!("index: {}", current_instruction));
45+
msg!(&format!("index: {current_instruction}"));
4646

4747
if instruction_data.len() == 2 {
4848
// CPI ourself with the same arguments to confirm the instructions sysvar reports the same

programs/sbf/rust/invoked/src/processor.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! Example Rust-based SBF program that issues a cross-program-invocation
22
33
#![cfg(feature = "program")]
4+
#![allow(clippy::integer_arithmetic)]
45

56
use {
67
crate::instructions::*,

programs/sbf/rust/iter/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! Example Rust-based SBF program tests loop iteration
22
3+
#![allow(clippy::integer_arithmetic)]
4+
35
extern crate solana_program;
46
use solana_program::{
57
custom_heap_default, custom_panic_default, entrypoint::SUCCESS, log::sol_log_64,

programs/sbf/rust/many_args/src/helper.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! Example Rust-based SBF program tests loop iteration
22
3+
#![allow(clippy::integer_arithmetic)]
4+
35
extern crate solana_program;
46
use solana_program::log::*;
57

programs/sbf/rust/many_args_dep/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! Solana Rust-based SBF program utility functions and types
22
3+
#![allow(clippy::integer_arithmetic)]
4+
35
extern crate solana_program;
46
use solana_program::{log::sol_log_64, msg};
57

programs/sbf/rust/mem/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ edition = { workspace = true }
1111

1212
[features]
1313
no-entrypoint = []
14+
test-bpf = []
15+
dummy-for-ci-check = ["test-bpf"]
1416

1517
[dependencies]
1618
solana-program = { workspace = true }

programs/sbf/rust/mem/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Test mem functions
22
3-
#[cfg(not(feature = "no-entrypoint"))]
3+
#[cfg(any(not(feature = "no-entrypoint"), feature = "test-bpf"))]
44
pub mod entrypoint;
55

66
pub trait MemOps {

programs/sbf/rust/mem/tests/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![cfg(feature = "test-bpf")]
2+
13
use {
24
solana_program_test::*,
35
solana_sbf_rust_mem::entrypoint::process_instruction,

programs/sbf/rust/panic/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
fn custom_panic(info: &core::panic::PanicInfo<'_>) {
66
// Note: Full panic reporting is included here for testing purposes
77
solana_program::msg!("program custom panic enabled");
8-
solana_program::msg!(&format!("{}", info));
8+
solana_program::msg!(&format!("{info}"));
99
}
1010

1111
extern crate solana_program;

programs/sbf/rust/param_passing_dep/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! Example Rust-based SBF program tests loop iteration
22
3+
#![allow(clippy::integer_arithmetic)]
4+
35
extern crate solana_program;
46

57
#[derive(Debug)]

programs/sbf/rust/sanity/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ edition = { workspace = true }
1111

1212
[features]
1313
test-bpf = []
14+
dummy-for-ci-check = ["test-bpf"]
1415

1516
[dependencies]
1617
solana-program = { workspace = true }

programs/sbf/rust/sanity/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! Example Rust-based SBF sanity program that prints out the parameters passed to it
22
33
#![allow(unreachable_code)]
4+
#![allow(clippy::integer_arithmetic)]
45

56
extern crate solana_program;
67
use solana_program::{

programs/sbf/rust/sanity/tests/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use {
1212
};
1313

1414
#[tokio::test]
15-
async fn test_sysvars() {
15+
async fn test_sanity() {
1616
let program_id = Pubkey::new_unique();
1717
let program_test = ProgramTest::new(
1818
"solana_sbf_rust_sanity",

programs/sbf/rust/secp256k1_recover/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ fn test_secp256k1_recover_malleability() {
6060
let signature = libsecp256k1::Signature::parse_standard_slice(&signature_bytes).unwrap();
6161

6262
// Flip the S value in the signature to make a different but valid signature.
63-
let mut alt_signature = signature.clone();
63+
let mut alt_signature = signature;
6464
alt_signature.s = -alt_signature.s;
6565
let alt_recovery_id = libsecp256k1::RecoveryId::parse(recovery_id ^ 1).unwrap();
6666

programs/sbf/rust/sibling_inner_instruction/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! Example Rust-based SBF program that queries sibling instructions
22
33
#![cfg(feature = "program")]
4+
#![allow(clippy::integer_arithmetic)]
45

56
use solana_program::{
67
account_info::AccountInfo,

programs/sbf/rust/simulation/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(clippy::integer_arithmetic)]
2+
13
use {
24
solana_program::{
35
account_info::{next_account_info, AccountInfo},
@@ -29,7 +31,7 @@ pub fn process_instruction(
2931
let slot: u64 = u64::from_le_bytes(data[data.len() - 8..].try_into().unwrap());
3032

3133
let clock_from_cache = Clock::get().unwrap();
32-
let clock_from_account = Clock::from_account_info(&clock_account_info).unwrap();
34+
let clock_from_account = Clock::from_account_info(clock_account_info).unwrap();
3335

3436
msg!("next_slot from slot history is {:?} ", slot);
3537
msg!("clock from cache is in slot {:?} ", clock_from_cache.slot);

programs/sbf/rust/simulation/tests/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use {
1313
};
1414

1515
#[tokio::test]
16-
async fn no_panic() {
16+
async fn no_panic_banks_client() {
1717
let program_id = Pubkey::new_unique();
1818
let program_test = ProgramTest::new(
1919
"solana_sbf_rust_simulation",

programs/sbf/rust/simulation/tests/validator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use {
1111
};
1212

1313
#[test]
14-
fn no_panic() {
14+
fn no_panic_rpc_client() {
1515
solana_logger::setup_with_default("solana_program_runtime=debug");
1616
let program_id = Pubkey::new_unique();
1717

programs/sbf/rust/spoof1_system/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(clippy::integer_arithmetic)]
2+
13
use solana_program::{account_info::AccountInfo, entrypoint::ProgramResult, pubkey::Pubkey};
24

35
solana_program::entrypoint!(process_instruction);

programs/sbf/rust/sysvar/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ edition = { workspace = true }
1212
[dependencies]
1313
solana-program = { workspace = true }
1414

15+
[features]
16+
test-bpf = []
17+
dummy-for-ci-check = ["test-bpf"]
18+
1519
[dev-dependencies]
1620
solana-program-runtime = { workspace = true }
1721
solana-program-test = { workspace = true }

programs/sbf/rust/sysvar/tests/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![cfg(feature = "test-bpf")]
2+
13
use {
24
solana_program_test::*,
35
solana_sbf_rust_sysvar::process_instruction,

programs/sbf/tests/programs.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
#![cfg(any(feature = "sbf_c", feature = "sbf_rust"))]
2+
#![allow(clippy::clone_on_copy)]
3+
#![allow(clippy::needless_range_loop)]
4+
#![allow(clippy::redundant_clone)]
5+
#![allow(clippy::needless_borrow)]
6+
#![allow(clippy::cmp_owned)]
7+
#![allow(clippy::needless_collect)]
8+
#![allow(clippy::match_like_matches_macro)]
9+
#![allow(clippy::unnecessary_cast)]
10+
#![allow(clippy::uninlined_format_args)]
211

312
#[macro_use]
413
extern crate solana_bpf_loader_program;

version/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ solana-frozen-abi = { workspace = true }
1818
solana-frozen-abi-macro = { workspace = true }
1919
solana-sdk = { workspace = true }
2020

21+
[features]
22+
dummy-for-ci-check = []
23+
2124
[lib]
2225
name = "solana_version"
2326

0 commit comments

Comments
 (0)