Skip to content

Commit

Permalink
Run clippy on CI (Layr-Labs#78)
Browse files Browse the repository at this point in the history
This PR adds a new check in the CI pipeline to run cargo clippy. 
It also adds a Makefile target so we can run it locally with the same
parameters as in the CI.

---------

Co-authored-by: tomasarrachea <tomas.arrachea@lambdaclass.com>
  • Loading branch information
juanbono and TomasArrachea authored Sep 2, 2024
1 parent f1c43c1 commit aef571d
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 10 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,24 @@ on:
branches: [main]

jobs:
lint:
name: Run Lints
runs-on: ubuntu-latest
steps:
- name: Install Rust
uses: dtolnay/rust-toolchain@1.80.1
with:
components: rustfmt, clippy

- name: Checkout repository
uses: actions/checkout@v4

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

- name: Run clippy
run: cargo clippy --workspace --all-features --benches --examples --tests -- -D warnings

test:
name: Run Integration Tests
runs-on: ubuntu-latest
Expand Down
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@ pr: reset-anvil ##
$(MAKE) start-anvil-chain-with-contracts-deployed > /dev/null &
sleep 4 # needed to wait for anvil setup to finish
cargo test --workspace
cargo clippy --workspace --lib --examples --tests --benches --all-features
cargo +nightly fmt -- --check
docker stop anvil

fireblocks-tests:
$(MAKE) start-anvil-chain-with-contracts-deployed > /dev/null &
cargo test --workspace --features fireblock-tests

lint:
cargo fmt --all -- --check \
&& cargo clippy --workspace --all-features --benches --examples --tests -- -D warnings

start-anvil: reset-anvil ##
$(MAKE) start-anvil-chain-with-contracts-deployed
docker start anvil
docker start anvil
2 changes: 1 addition & 1 deletion crates/chainio/clients/elcontracts/src/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ mod tests {
let service_manager_address = anvil_constants::get_service_manager_address().await;
let service_manager_contract = mockAvsServiceManager::new(
service_manager_address,
get_provider(&"http://localhost:8545"),
get_provider("http://localhost:8545"),
);
let avs_directory_address_return = service_manager_contract
.avsDirectory()
Expand Down
2 changes: 1 addition & 1 deletion crates/eigen-cli/src/eigen_address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl ContractAddresses {
/// # Returns
///
/// * `(Address, Address)` - The registry coordinator and service manager contract addresses,
/// used to call `get_avs_contract_addresses` and `get_eigenlayer_contract_addresses` functions.
/// used to call `get_avs_contract_addresses` and `get_eigenlayer_contract_addresses` functions.
async fn get_registry_coord_and_service_manager_addr<T, P, N>(
registry_coordinator: Option<Address>,
service_manager: Option<Address>,
Expand Down
2 changes: 1 addition & 1 deletion crates/eigen-cli/src/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl KeyGenerator {
};
let dir_path = Path::new(&dir_name);
let key_path = dir_path.join(DEFAULT_KEY_FOLDER);
fs::create_dir_all(&key_path).map_err(EigenKeyCliError::FileError)?;
fs::create_dir_all(key_path).map_err(EigenKeyCliError::FileError)?;

self.generate_keys(num_keys, dir_path)
}
Expand Down
5 changes: 1 addition & 4 deletions crates/eigen-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,7 @@ mod test {

let keystore_instance = Keystore::from_file(output_path.to_str().unwrap()).unwrap();
let decrypted_key = keystore_instance.decrypt("testpassword").unwrap();
let fr_key: String = decrypted_key
.iter()
.map(|&value| value as u8 as char)
.collect();
let fr_key: String = decrypted_key.iter().map(|&value| value as char).collect();
assert_eq!(fr_key, key);
}

Expand Down

0 comments on commit aef571d

Please sign in to comment.