Merge pull request #86 from blockworks-foundation/28-add-git-ci-action-to-github-project

WIP test.yml
This commit is contained in:
Aniket Prajapati 2023-03-19 11:57:25 +05:30 committed by GitHub
commit b8df5f24dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 62 additions and 13 deletions

52
.github/workflows/test.yml vendored Normal file
View File

@ -0,0 +1,52 @@
name: Cargo Build & Test
on:
push:
pull_request:
env:
CARGO_TERM_COLOR: always
jobs:
build_and_test:
name: Rust project - latest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Install Dependencies
run: |
sudo apt-get update -y
sudo apt-get upgrade -y
sudo apt-get install libssl-dev openssl -y
- name: Early Build
run: cargo build --workspace --tests
- name: Install node deps
run: yarn
- name: Setup validator
run: |
sh -c "$(curl -sSfL https://release.solana.com/v1.15.2/install)"
echo "$HOME/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
export PATH="$HOME/.local/share/solana/install/active_release/bin:$PATH"
ls "$HOME/.local/share/solana/install/active_release/bin"
echo "Solana Cli installed"
solana --version
echo "Generating keypair..."
solana-keygen new -o "$HOME/.config/solana/id.json" --no-passphrase --silent
solana config set --url "http://0.0.0.0:8899"
- name: Run and Test
run: |
sh -c "solana-test-validator" &
sleep 20 && solana airdrop 10000
cargo run &
sleep 20 && cargo test
yarn test
pkill lite-rpc
kill $(jobs -p)

1
.gitignore vendored
View File

@ -4,3 +4,4 @@ bench/metrics.csv
*.pem*
*.pks*
.env
test-ledger

11
Cargo.lock generated
View File

@ -381,13 +381,13 @@ dependencies = [
"csv",
"dirs",
"log",
"rand 0.8.5",
"serde",
"serde_json",
"solana-rpc-client",
"solana-sdk 1.15.0",
"tokio",
"tracing-subscriber",
"uuid",
]
[[package]]
@ -5233,15 +5233,6 @@ version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9"
[[package]]
name = "uuid"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1674845326ee10d37ca60470760d4288a6f80f304007d92e5c53bab78c9cfd79"
dependencies = [
"getrandom 0.2.8",
]
[[package]]
name = "valuable"
version = "0.1.0"

View File

@ -15,5 +15,5 @@ clap = { version = "4.1.6", features = ["derive"] }
tokio = { version = "1.25.0", features = ["full", "fs"]}
tracing-subscriber = "0.3.16"
dirs = "4.0.0"
uuid = { version = "1.3.0", features = ["v4"] }
rand = "0.8.5"

View File

@ -1,6 +1,7 @@
use std::str::FromStr;
use anyhow::Context;
use rand::{distributions::Alphanumeric, prelude::Distribution};
use solana_rpc_client::nonblocking::rpc_client::RpcClient;
use solana_sdk::{
commitment_config::CommitmentConfig,
@ -68,9 +69,13 @@ impl BenchHelper {
funded_payer: &Keypair,
blockhash: Hash,
) -> Vec<Transaction> {
let random_bytes: Vec<u8> = Alphanumeric
.sample_iter(rand::thread_rng())
.take(10)
.collect();
(0..num_of_txs)
.into_iter()
.map(|_| Self::create_memo_tx(uuid::Uuid::new_v4().as_bytes(), funded_payer, blockhash))
.map(|_| Self::create_memo_tx(&random_bytes, funded_payer, blockhash))
.collect()
}