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

CI setup #4

Merged
merged 1 commit into from
Jun 22, 2024
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
72 changes: 72 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Main

on:
push:
branches: [main]
pull_request:
branches: [main]

env:
NIGHTLY_TOOLCHAIN: nightly-2023-10-05
SOLANA_VERSION: 1.18.14

jobs:
rust_fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: ~/.rustup/toolchains/${{ env.NIGHTLY_TOOLCHAIN }}
key: ${{ runner.os }}-rust-toolchain-${{ env.NIGHTLY_TOOLCHAIN }}
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.NIGHTLY_TOOLCHAIN }}
components: rustfmt
- name: Run format
run: cargo +${{ env.NIGHTLY_TOOLCHAIN }} fmt --all -- --check

rust_clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: ~/.rustup/toolchains/${{ env.NIGHTLY_TOOLCHAIN }}
key: ${{ runner.os }}-rust-toolchain-${{ env.NIGHTLY_TOOLCHAIN }}
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.NIGHTLY_TOOLCHAIN }}
components: clippy
- name: Run clippy
run: cargo +${{ env.NIGHTLY_TOOLCHAIN }} clippy --all -- --deny=warnings

cargo_build_test:
name: Cargo Build and Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: ~/.local/share/solana/install/active_release/bin/solana
key: ${{ runner.os }}-solana-${{ env.SOLANA_VERSION }}
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- uses: metaplex-foundation/actions/install-solana@v1
with:
version: ${{ env.SOLANA_VERSION }}
- name: Build test program
run: cargo build-sbf --manifest-path test-program/Cargo.toml
- name: Test
run: cargo test
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ bincode = "1.3.3"
num-format = "0.4.4"
serde_json = "1.0.117"
solana-bpf-loader-program = "1.18.14"
solana-logger = "1.18.14"
solana-program = "1.18.14"
solana-program-runtime = "1.18.14"
solana-system-program = "1.18.14"
Expand Down
3 changes: 3 additions & 0 deletions bencher/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ mollusk = { path = "../harness" }
num-format = { workspace = true }
serde_json = { workspace = true }
solana-sdk = { workspace = true }

[dev-dependencies]
solana-logger = { workspace = true }
1 change: 1 addition & 0 deletions bencher/tests/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use {
#[test]
fn test_markdown() {
std::env::set_var("SBF_OUT_DIR", "../target/deploy");
solana_logger::setup_with("");

let program_id = Pubkey::new_unique();

Expand Down
2 changes: 1 addition & 1 deletion harness/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ solana-bpf-loader-program = { workspace = true }
solana-program-runtime = { workspace = true }
solana-system-program = { workspace = true }
solana-sdk = { workspace = true }
solana-logger = "2.0.0"
solana-logger = { workspace = true }


[[bench]]
Expand Down
14 changes: 8 additions & 6 deletions harness/benches/ips.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
//! Benches Mollusk invocation (instructions per second)
use criterion::{criterion_group, criterion_main, Criterion, Throughput};
use mollusk::{result::Check, Mollusk};
use solana_sdk::{
account::AccountSharedData, native_token::LAMPORTS_PER_SOL, pubkey::Pubkey, system_instruction,
system_program,
use {
criterion::{criterion_group, criterion_main, Criterion, Throughput},
mollusk::{result::Check, Mollusk},
solana_sdk::{
account::AccountSharedData, native_token::LAMPORTS_PER_SOL, pubkey::Pubkey,
system_instruction, system_program,
},
solana_system_program::system_processor::DEFAULT_COMPUTE_UNITS,
};
use solana_system_program::system_processor::DEFAULT_COMPUTE_UNITS;

fn transfer_checked_unchecked(c: &mut Criterion) {
let sender = Pubkey::new_unique();
Expand Down
4 changes: 2 additions & 2 deletions harness/tests/bpf_program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ fn test_close_account() {
],
&[
Check::err(ProgramError::MissingRequiredSignature),
Check::compute_units(597),
Check::compute_units(598),
],
);
}
Expand All @@ -222,7 +222,7 @@ fn test_close_account() {
],
&[
Check::success(),
Check::compute_units(2557),
Check::compute_units(2558),
Check::account(&key)
.data(&[])
.lamports(0)
Expand Down
5 changes: 5 additions & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
comment_width = 80
format_strings = true
group_imports = "One"
imports_granularity = "One"
wrap_comments = true
Loading