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,

0 commit comments

Comments
 (0)