ci: test-checks.sh all sbf code & use nightly only (#30602)

This commit is contained in:
Ryo Onodera 2023-03-13 14:28:34 +09:00 committed by GitHub
parent c4b2639a86
commit 7f58345dad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
35 changed files with 78 additions and 17 deletions

View File

@ -51,10 +51,12 @@ echo --- build environment
export RUST_BACKTRACE=1
export RUSTFLAGS="-D warnings -A incomplete_features"
# run cargo check for all rust files in this monorepo for faster turnaround in
# case of any compilation/build error for nightly
# 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 check --locked --tests --bins --examples; then
if _ scripts/cargo-for-all-lock-files.sh "+${rust_nightly}" check --locked --workspace --all-targets --features dummy-for-ci-check; then
true
else
check_status=$?
@ -63,9 +65,6 @@ if [[ $CI_BASE_BRANCH = "$EDGE_CHANNEL" ]]; then
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
exit "$check_status"
fi
# Ensure nightly and --benches
_ 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
@ -76,7 +75,7 @@ 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 -- "+${rust_nightly}" clippy -Zunstable-options --all-targets -- \
_ scripts/cargo-for-all-lock-files.sh -- "+${rust_nightly}" clippy -Zunstable-options --workspace --all-targets --features dummy-for-ci-check -- \
--deny=warnings \
--deny=clippy::integer_arithmetic \
"${nightly_clippy_allows[@]}"

View File

@ -66,6 +66,10 @@ edition = { workspace = true }
[features]
sbf_c = []
sbf_rust = []
dummy-for-ci-check = [
"sbf_c",
"sbf_rust",
]
[build-dependencies]
walkdir = "2"

View File

@ -1,5 +1,7 @@
#![feature(test)]
#![cfg(feature = "sbf_c")]
#![allow(clippy::uninlined_format_args)]
#![allow(clippy::integer_arithmetic)]
use {solana_rbpf::memory_region::MemoryState, std::slice};

View File

@ -37,6 +37,11 @@ fn rerun_if_changed(files: &[&str], directories: &[&str], excludes: &[&str]) {
}
fn main() {
if env::var("CARGO_FEATURE_DUMMY_FOR_CI_CHECK").is_ok() {
println!("cargo:warning=(not a warning) Compiling with host toolchain for CI...");
return;
}
let sbf_c = env::var("CARGO_FEATURE_SBF_C").is_ok();
if sbf_c {
let install_dir = "OUT_DIR=../target/".to_string() + &env::var("PROFILE").unwrap() + "/sbf";

View File

@ -1,5 +1,7 @@
//! Example Rust-based SBF program tests loop iteration
#![allow(clippy::integer_arithmetic)]
extern crate solana_program;
use solana_program::{custom_heap_default, custom_panic_default, entrypoint::SUCCESS};

View File

@ -1,5 +1,7 @@
//! Solana Rust-based SBF program utility functions and types
#![allow(clippy::integer_arithmetic)]
extern crate solana_program;
pub fn uadd(x: u128, y: u128) -> u128 {

View File

@ -1,5 +1,7 @@
//! Example Rust-based SBF program that test dynamic memory allocation
#![allow(clippy::integer_arithmetic)]
#[macro_use]
extern crate alloc;
use {
@ -37,7 +39,7 @@ pub extern "C" fn entrypoint(_input: *mut u8) -> u64 {
*ptr.add(i) = i as u8;
}
for i in 0..ITERS {
assert_eq!(*ptr.add(i as usize), i as u8);
assert_eq!(*ptr.add(i), i as u8);
}
sol_log_64(0x3, 0, 0, 0, u64::from(*ptr.add(42)));
assert_eq!(*ptr.add(42), 42);

View File

@ -1,5 +1,7 @@
//! Example Rust-based SBF that tests out using a custom heap
#![allow(clippy::integer_arithmetic)]
use {
solana_program::{
account_info::AccountInfo,

View File

@ -1,6 +1,7 @@
//! Example Rust-based SBF program that supports the deprecated loader
#![allow(unreachable_code)]
#![allow(clippy::integer_arithmetic)]
extern crate solana_program;
use solana_program::{
@ -23,7 +24,7 @@ fn return_sstruct() -> SStruct {
#[no_mangle]
fn custom_panic(info: &core::panic::PanicInfo<'_>) {
// Full panic reporting
msg!(&format!("{}", info));
msg!(&format!("{info}"));
}
solana_program::entrypoint_deprecated!(process_instruction);

View File

@ -1,5 +1,7 @@
//! Example Rust-based SBF program that tests duplicate accounts passed via accounts
#![allow(clippy::integer_arithmetic)]
extern crate solana_program;
use solana_program::{
account_info::AccountInfo,

View File

@ -1,5 +1,7 @@
//! Example Rust-based SBF program that moves a lamport from one account to another
#![allow(clippy::integer_arithmetic)]
extern crate solana_program;
use solana_program::{account_info::AccountInfo, entrypoint::ProgramResult, pubkey::Pubkey};

View File

@ -40,5 +40,5 @@ custom_heap_default!();
#[no_mangle]
fn custom_panic(info: &core::panic::PanicInfo<'_>) {
// Full panic reporting
msg!(&format!("{}", info));
msg!(&format!("{info}"));
}

View File

@ -42,7 +42,7 @@ fn process_instruction(
msg!(&format!("id: {}", instruction.program_id));
msg!(&format!("data[0]: {}", instruction.data[0]));
msg!(&format!("index: {}", current_instruction));
msg!(&format!("index: {current_instruction}"));
if instruction_data.len() == 2 {
// CPI ourself with the same arguments to confirm the instructions sysvar reports the same

View File

@ -1,6 +1,7 @@
//! Example Rust-based SBF program that issues a cross-program-invocation
#![cfg(feature = "program")]
#![allow(clippy::integer_arithmetic)]
use {
crate::instructions::*,

View File

@ -1,5 +1,7 @@
//! Example Rust-based SBF program tests loop iteration
#![allow(clippy::integer_arithmetic)]
extern crate solana_program;
use solana_program::{
custom_heap_default, custom_panic_default, entrypoint::SUCCESS, log::sol_log_64,

View File

@ -1,5 +1,7 @@
//! Example Rust-based SBF program tests loop iteration
#![allow(clippy::integer_arithmetic)]
extern crate solana_program;
use solana_program::log::*;

View File

@ -1,5 +1,7 @@
//! Solana Rust-based SBF program utility functions and types
#![allow(clippy::integer_arithmetic)]
extern crate solana_program;
use solana_program::{log::sol_log_64, msg};

View File

@ -11,6 +11,8 @@ edition = { workspace = true }
[features]
no-entrypoint = []
test-bpf = []
dummy-for-ci-check = ["test-bpf"]
[dependencies]
solana-program = { workspace = true }

View File

@ -1,6 +1,6 @@
//! Test mem functions
#[cfg(not(feature = "no-entrypoint"))]
#[cfg(any(not(feature = "no-entrypoint"), feature = "test-bpf"))]
pub mod entrypoint;
pub trait MemOps {

View File

@ -1,3 +1,5 @@
#![cfg(feature = "test-bpf")]
use {
solana_program_test::*,
solana_sbf_rust_mem::entrypoint::process_instruction,

View File

@ -5,7 +5,7 @@
fn custom_panic(info: &core::panic::PanicInfo<'_>) {
// Note: Full panic reporting is included here for testing purposes
solana_program::msg!("program custom panic enabled");
solana_program::msg!(&format!("{}", info));
solana_program::msg!(&format!("{info}"));
}
extern crate solana_program;

View File

@ -1,5 +1,7 @@
//! Example Rust-based SBF program tests loop iteration
#![allow(clippy::integer_arithmetic)]
extern crate solana_program;
#[derive(Debug)]

View File

@ -11,6 +11,7 @@ edition = { workspace = true }
[features]
test-bpf = []
dummy-for-ci-check = ["test-bpf"]
[dependencies]
solana-program = { workspace = true }

View File

@ -1,6 +1,7 @@
//! Example Rust-based SBF sanity program that prints out the parameters passed to it
#![allow(unreachable_code)]
#![allow(clippy::integer_arithmetic)]
extern crate solana_program;
use solana_program::{

View File

@ -12,7 +12,7 @@ use {
};
#[tokio::test]
async fn test_sysvars() {
async fn test_sanity() {
let program_id = Pubkey::new_unique();
let program_test = ProgramTest::new(
"solana_sbf_rust_sanity",

View File

@ -60,7 +60,7 @@ fn test_secp256k1_recover_malleability() {
let signature = libsecp256k1::Signature::parse_standard_slice(&signature_bytes).unwrap();
// Flip the S value in the signature to make a different but valid signature.
let mut alt_signature = signature.clone();
let mut alt_signature = signature;
alt_signature.s = -alt_signature.s;
let alt_recovery_id = libsecp256k1::RecoveryId::parse(recovery_id ^ 1).unwrap();

View File

@ -1,6 +1,7 @@
//! Example Rust-based SBF program that queries sibling instructions
#![cfg(feature = "program")]
#![allow(clippy::integer_arithmetic)]
use solana_program::{
account_info::AccountInfo,

View File

@ -1,3 +1,5 @@
#![allow(clippy::integer_arithmetic)]
use {
solana_program::{
account_info::{next_account_info, AccountInfo},
@ -29,7 +31,7 @@ pub fn process_instruction(
let slot: u64 = u64::from_le_bytes(data[data.len() - 8..].try_into().unwrap());
let clock_from_cache = Clock::get().unwrap();
let clock_from_account = Clock::from_account_info(&clock_account_info).unwrap();
let clock_from_account = Clock::from_account_info(clock_account_info).unwrap();
msg!("next_slot from slot history is {:?} ", slot);
msg!("clock from cache is in slot {:?} ", clock_from_cache.slot);

View File

@ -13,7 +13,7 @@ use {
};
#[tokio::test]
async fn no_panic() {
async fn no_panic_banks_client() {
let program_id = Pubkey::new_unique();
let program_test = ProgramTest::new(
"solana_sbf_rust_simulation",

View File

@ -11,7 +11,7 @@ use {
};
#[test]
fn no_panic() {
fn no_panic_rpc_client() {
solana_logger::setup_with_default("solana_program_runtime=debug");
let program_id = Pubkey::new_unique();

View File

@ -1,3 +1,5 @@
#![allow(clippy::integer_arithmetic)]
use solana_program::{account_info::AccountInfo, entrypoint::ProgramResult, pubkey::Pubkey};
solana_program::entrypoint!(process_instruction);

View File

@ -12,6 +12,10 @@ edition = { workspace = true }
[dependencies]
solana-program = { workspace = true }
[features]
test-bpf = []
dummy-for-ci-check = ["test-bpf"]
[dev-dependencies]
solana-program-runtime = { workspace = true }
solana-program-test = { workspace = true }

View File

@ -1,3 +1,5 @@
#![cfg(feature = "test-bpf")]
use {
solana_program_test::*,
solana_sbf_rust_sysvar::process_instruction,

View File

@ -1,4 +1,13 @@
#![cfg(any(feature = "sbf_c", feature = "sbf_rust"))]
#![allow(clippy::clone_on_copy)]
#![allow(clippy::needless_range_loop)]
#![allow(clippy::redundant_clone)]
#![allow(clippy::needless_borrow)]
#![allow(clippy::cmp_owned)]
#![allow(clippy::needless_collect)]
#![allow(clippy::match_like_matches_macro)]
#![allow(clippy::unnecessary_cast)]
#![allow(clippy::uninlined_format_args)]
#[macro_use]
extern crate solana_bpf_loader_program;

View File

@ -18,6 +18,9 @@ solana-frozen-abi = { workspace = true }
solana-frozen-abi-macro = { workspace = true }
solana-sdk = { workspace = true }
[features]
dummy-for-ci-check = []
[lib]
name = "solana_version"