fix build dependency isuse (#12)

* fix build dependency isuse

* cargo fmt

* fix lint failure in CI

* update toolchain
This commit is contained in:
Bo QIU 2024-01-26 19:48:40 +08:00 committed by GitHub
parent 7667e02019
commit a4abe2b2a4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 37 additions and 33 deletions

View File

@ -36,9 +36,7 @@ jobs:
override: true override: true
- name: Run unittest - name: Run unittest
# Disable --all-features to avoid CI failure when download dependent lib (via yarn) for contract compilation. run: cargo test --all-features --no-fail-fast
# run: cargo test --all-features --no-fail-fast
run: cargo test --no-fail-fast
env: env:
CARGO_INCREMENTAL: '0' CARGO_INCREMENTAL: '0'
RUSTC_BOOTSTRAP: '1' RUSTC_BOOTSTRAP: '1'

View File

@ -96,4 +96,5 @@ jobs:
- name: Run cargo clippy - name: Run cargo clippy
uses: actions-rs/cargo@v1 uses: actions-rs/cargo@v1
with: with:
command: clippy command: clippy
args: -- -D warnings

View File

@ -1,30 +1,30 @@
use std::process::Command; // use std::process::Command;
const INSTALL_ERROR_MESSAGE: &str = // const INSTALL_ERROR_MESSAGE: &str =
"Install dependencies for contract fail, try to run `yarn` in folder 'zerog-storage-contracts'"; // "Install dependencies for contract fail, try to run `yarn` in folder 'zerog-storage-contracts'";
const COMPILE_ERROR_MESSAGE: &str = // const COMPILE_ERROR_MESSAGE: &str =
"Compile solidity contracts fail, try to run `yarn compile` in folder 'zerog-storage-contracts'"; // "Compile solidity contracts fail, try to run `yarn compile` in folder 'zerog-storage-contracts'";
fn main() { fn main() {
if cfg!(feature = "compile-contracts") { // if cfg!(feature = "compile-contracts") {
println!("cargo:rerun-if-changed=../../zerog-storage-contracts/contracts/"); // println!("cargo:rerun-if-changed=../../zerog-storage-contracts/contracts/");
println!("cargo:rerun-if-changed=../../zerog-storage-contracts/hardhat.config.ts"); // println!("cargo:rerun-if-changed=../../zerog-storage-contracts/hardhat.config.ts");
let output = Command::new("yarn") // let output = Command::new("yarn")
.arg("--cwd") // .arg("--cwd")
.arg("../../zerog-storage-contracts") // .arg("../../zerog-storage-contracts")
.status() // .status()
.expect(INSTALL_ERROR_MESSAGE); // .expect(INSTALL_ERROR_MESSAGE);
assert!(output.success(), "{}", INSTALL_ERROR_MESSAGE); // assert!(output.success(), "{}", INSTALL_ERROR_MESSAGE);
let output = Command::new("yarn") // let output = Command::new("yarn")
.arg("--cwd") // .arg("--cwd")
.arg("../../zerog-storage-contracts") // .arg("../../zerog-storage-contracts")
.arg("compile") // .arg("compile")
.status() // .status()
.expect(COMPILE_ERROR_MESSAGE); // .expect(COMPILE_ERROR_MESSAGE);
assert!(output.success(), "{}", COMPILE_ERROR_MESSAGE); // assert!(output.success(), "{}", COMPILE_ERROR_MESSAGE);
} else { // } else {
println!("cargo:rerun-if-changed=../../zerog-storage-contracts/artifacts/"); // println!("cargo:rerun-if-changed=../../zerog-storage-contracts/artifacts/");
} // }
} }

View File

@ -1,6 +1,6 @@
//! Helper functions and an extension trait for Ethereum 2 ENRs. //! Helper functions and an extension trait for Ethereum 2 ENRs.
pub use discv5::enr::{self, CombinedKey, EnrBuilder}; pub use discv5::enr::{CombinedKey, EnrBuilder};
use super::enr_ext::CombinedKeyExt; use super::enr_ext::CombinedKeyExt;
use super::ENR_FILENAME; use super::ENR_FILENAME;

View File

@ -24,7 +24,7 @@ lazy_static::lazy_static! {
} }
fn duration_since(timestamp: u32) -> chrono::Duration { fn duration_since(timestamp: u32) -> chrono::Duration {
let timestamp = i64::try_from(timestamp).expect("Should fit"); let timestamp = i64::from(timestamp);
let timestamp = chrono::NaiveDateTime::from_timestamp_opt(timestamp, 0).expect("should fit"); let timestamp = chrono::NaiveDateTime::from_timestamp_opt(timestamp, 0).expect("should fit");
let now = chrono::Utc::now().naive_utc(); let now = chrono::Utc::now().naive_utc();
now.signed_duration_since(timestamp) now.signed_duration_since(timestamp)

View File

@ -7,7 +7,7 @@ use network::{Enr, Multiaddr, NetworkGlobals};
use std::sync::Arc; use std::sync::Arc;
pub use builder::ClientBuilder; pub use builder::ClientBuilder;
pub use environment::{Environment, EnvironmentBuilder, RuntimeContext}; pub use environment::{EnvironmentBuilder, RuntimeContext};
/// The core Zgs client. /// The core Zgs client.
/// ///

View File

@ -1 +1 @@
1.73.0 1.75.0

5
rustlint.sh Normal file
View File

@ -0,0 +1,5 @@
#!/bin/bash
# keep consistent with CI-lint in rust.yml
cargo fmt --all
cargo clippy -- -D warnings

View File

@ -26,7 +26,7 @@
pub use super::{ pub use super::{
bucket::{ bucket::{
AppliedPending, ConnectionState, InsertResult, Node, NodeStatus, MAX_NODES_PER_BUCKET, AppliedPending, ConnectionState, InsertResult, Node, NodeStatus,
}, },
key::*, key::*,
ConnectionDirection, ConnectionDirection,