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

[MTG-237] ci cd #17

Merged
merged 10 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from 7 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
8 changes: 8 additions & 0 deletions .cargo/audit.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[advisories]
ignore = ["RUSTSEC-2024-0344", "RUSTSEC-2022-0093"] # ignore unfixable vulnerabilities
Copy link
Collaborator

@kstepanovdev kstepanovdev Jul 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not an error, but why those two specifically?

Nvm, I have seen a comment. Why are they unfixable though?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also curious.
Probably that's because of solana-ed25519-dalek dependency in solana itself. The fix in the library had been merged 3 weeks ago, so I assume the issue should gone soon in the next versions.


[output]
deny = [] # exit on error if unmaintained dependencies are found
format = "terminal" # "terminal" (human-readable report) or "json"
quiet = true # Only print information on error
show_tree = false # Show inverse dependency trees along with advisories (default: true)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a newline everywhere (you might want to do this as a default setting on a file save, just like cargo fmt)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not showing the tree? it might be helpful to understand what should we update?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As for me it was very noisy, so I thought it would be nice to remove this tree. But if you think different I will change it.

40 changes: 40 additions & 0 deletions .github/workflows/ci-cargo-audit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Cargo Audit

on:
push:
branches:
- master
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our main branch is main I suppose

pull_request:

# Allowing manual runs with ability to choose branch
workflow_dispatch:

# Optimisation option by targeting direct paths to only scan when there are changes to dependencies in the push/PR
# push:
# paths:
# - 'Cargo.toml'
# - 'Cargo.lock'
# pull_request:
# paths:
# - 'Cargo.toml'
# - 'Cargo.lock'

# Example of running scheduled scans at 6AM UTC every Monday to regularly check for vulnerable dependencies
# schedule:
# - cron: '0 6 * * 1'

jobs:
Cargo-audit:
name: Cargo Vulnerability Scanner
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Install Cargo Audit
uses: actions-rs/[email protected]
with:
crate: cargo-audit
version: latest

- name: Run Cargo Audit
run: cargo audit -c always
76 changes: 76 additions & 0 deletions .github/workflows/ci-lint-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Lint and Test

on:
push:
branches:
- master
pull_request:

env:
CARGO_TERM_COLOR: always
SOLANA_VERSION: "1.18.9"
RUST_TOOLCHAIN: "1.78.0"

defaults:
run:
working-directory: ./

jobs:
lint:
name: Linter
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install Rust nightly
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
components: rustfmt, clippy
cache: true

- name: Run fmt
run: cargo fmt -- --check

- name: Run clippy
run: cargo clippy --all-targets --all-features --workspace -- -D warnings

tests:
name: Tests
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install Linux dependencies
run: sudo apt-get update && sudo apt-get install -y pkg-config build-essential libudev-dev

- name: Install Rust nightly
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
cache: true

- name: Cache Solana binaries
uses: actions/cache@v2
with:
path: ~/.cache/solana
key: ${{ runner.os }}-${{ env.RUST_TOOLCHAIN }}

- name: Install Solana
run: |
sh -c "$(curl -sSfL https://release.solana.com/v${{ env.SOLANA_VERSION }}/install)"
echo "$HOME/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
export PATH="$HOME/.local/share/solana/install/active_release/bin:$PATH"
solana --version
echo "Generating keypair..."
solana-keygen new -o "$HOME/.config/solana/id.json" --no-passphrase --silent

- name: Switch toolchain
run: |
rustup override set ${{ env.RUST_TOOLCHAIN }}
solana-install init ${{ env.SOLANA_VERSION }}

- name: Run tests
run: cargo test-bpf
6 changes: 6 additions & 0 deletions clients/rust/src/generated/instructions/claim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ impl ClaimInstructionData {
}
}

impl Default for ClaimInstructionData {
fn default() -> Self {
Self::new()
}
}

/// Instruction builder for `Claim`.
///
/// ### Accounts:
Expand Down
6 changes: 6 additions & 0 deletions clients/rust/src/generated/instructions/close_mining.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ impl CloseMiningInstructionData {
}
}

impl Default for CloseMiningInstructionData {
fn default() -> Self {
Self::new()
}
}

/// Instruction builder for `CloseMining`.
///
/// ### Accounts:
Expand Down
6 changes: 6 additions & 0 deletions clients/rust/src/generated/instructions/deposit_mining.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ impl DepositMiningInstructionData {
}
}

impl Default for DepositMiningInstructionData {
fn default() -> Self {
Self::new()
}
}

#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct DepositMiningInstructionArgs {
Expand Down
6 changes: 6 additions & 0 deletions clients/rust/src/generated/instructions/distribute_rewards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ impl DistributeRewardsInstructionData {
}
}

impl Default for DistributeRewardsInstructionData {
fn default() -> Self {
Self::new()
}
}

/// Instruction builder for `DistributeRewards`.
///
/// ### Accounts:
Expand Down
6 changes: 6 additions & 0 deletions clients/rust/src/generated/instructions/extend_stake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ impl ExtendStakeInstructionData {
}
}

impl Default for ExtendStakeInstructionData {
fn default() -> Self {
Self::new()
}
}

#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ExtendStakeInstructionArgs {
Expand Down
6 changes: 6 additions & 0 deletions clients/rust/src/generated/instructions/fill_vault.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ impl FillVaultInstructionData {
}
}

impl Default for FillVaultInstructionData {
fn default() -> Self {
Self::new()
}
}

#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct FillVaultInstructionArgs {
Expand Down
6 changes: 6 additions & 0 deletions clients/rust/src/generated/instructions/initialize_mining.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ impl InitializeMiningInstructionData {
}
}

impl Default for InitializeMiningInstructionData {
fn default() -> Self {
Self::new()
}
}

#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct InitializeMiningInstructionArgs {
Expand Down
6 changes: 6 additions & 0 deletions clients/rust/src/generated/instructions/initialize_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ impl InitializePoolInstructionData {
}
}

impl Default for InitializePoolInstructionData {
fn default() -> Self {
Self::new()
}
}

#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct InitializePoolInstructionArgs {
Expand Down
6 changes: 6 additions & 0 deletions clients/rust/src/generated/instructions/withdraw_mining.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ impl WithdrawMiningInstructionData {
}
}

impl Default for WithdrawMiningInstructionData {
fn default() -> Self {
Self::new()
}
}

#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct WithdrawMiningInstructionArgs {
Expand Down
9 changes: 2 additions & 7 deletions clients/rust/tests/create.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
#![cfg(feature = "test-sbf")]

use borsh::BorshDeserialize;
// use rewards::{accounts::MyAccount, instructions::CreateBuilder};
use solana_program_test::{tokio, ProgramTest};
use solana_sdk::{
signature::{Keypair, Signer},
transaction::Transaction,
};
use solana_program_test::tokio;

#[tokio::test]
async fn create() {
Expand All @@ -16,7 +11,7 @@ async fn create() {

// Given a new keypair.

let address = Keypair::new();
// let address = Keypair::new();

// let ix = CreateBuilder::new()
// .address(address.pubkey())
Expand Down
2 changes: 1 addition & 1 deletion programs/rewards/src/instructions/initialize_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl<'a, 'b> InitializePoolContext<'a, 'b> {
assert_uninitialized(self.reward_vault)?;

let (reward_pool_pubkey, pool_bump) =
find_reward_pool_program_address(program_id, &self.deposit_authority.key);
find_reward_pool_program_address(program_id, self.deposit_authority.key);
assert_account_key(self.reward_pool, &reward_pool_pubkey)?;

let reward_pool_seeds = &[
Expand Down
2 changes: 1 addition & 1 deletion programs/rewards/tests/rewards/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ impl TestRewards {
&self.reward_pool,
)],
Some(&context.payer.pubkey()),
&[&context.payer, &self.deposit_authority, &mining_owner],
&[&context.payer, &self.deposit_authority, mining_owner],
context.last_blockhash,
);

Expand Down
Loading