From 674fba52820d60f4d2244730a8f30f233ee1cd91 Mon Sep 17 00:00:00 2001 From: noot <36753753+noot@users.noreply.github.com> Date: Mon, 6 Dec 2021 14:38:03 -0500 Subject: [PATCH] ci: add gh actions workflows (#1317) --- .github/workflows/docs.yml | 19 +++ .github/workflows/msrv.yml | 148 +++++++++++++++++++ blockchain/blocks/src/election_proof.rs | 4 +- blockchain/blocks/src/ticket.rs | 2 +- crypto/src/signature.rs | 4 +- ipld/amt/src/node.rs | 2 +- ipld/amt/src/value_mut.rs | 2 +- ipld/cid/src/json.rs | 2 +- ipld/src/json.rs | 2 +- node/forest_libp2p/src/service.rs | 2 + vm/interpreter/src/gas_tracker/price_list.rs | 12 +- vm/message/src/message_receipt.rs | 4 +- 12 files changed, 183 insertions(+), 20 deletions(-) create mode 100644 .github/workflows/docs.yml create mode 100644 .github/workflows/msrv.yml diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 000000000000..2d9d2e3c17ec --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,19 @@ +name: Publish docs +on: + push: + branches: + - main + +jobs: + publish-docs: + name: publish docs + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v2 + - name: Install toolchain + uses: actions-rs/toolchain@v1 + - run: | + cargo install mdbook + mdbook build ./documentation + bash ./scripts/build-rust-docs.sh \ No newline at end of file diff --git a/.github/workflows/msrv.yml b/.github/workflows/msrv.yml new file mode 100644 index 000000000000..664d46e98c59 --- /dev/null +++ b/.github/workflows/msrv.yml @@ -0,0 +1,148 @@ +on: [pull_request] + +name: msrv + +jobs: + check: + name: check + runs-on: ubuntu-latest + strategy: + matrix: + rust: + - stable + - 1.57.0 + steps: + - name: Checkout sources + uses: actions/checkout@v2 + + - name: Install toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.rust }} + override: true + + - name: Run cargo check + uses: actions-rs/cargo@v1 + with: + command: check + + test: + name: unit tests + runs-on: ubuntu-latest + strategy: + matrix: + rust: + - stable + - 1.57.0 + steps: + - name: Checkout sources + uses: actions/checkout@v2 + + - name: Install toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.rust }} + override: true + + - name: Run cargo test + run: make test + + fmt: + name: fmt + runs-on: ubuntu-latest + strategy: + matrix: + rust: + - stable + - 1.57.0 + steps: + - name: Checkout sources + uses: actions/checkout@v2 + + - name: Install toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.rust }} + override: true + + - name: check license + run: make license + + - name: Install rustfmt + run: rustup component add rustfmt + + - name: Run cargo fmt + uses: actions-rs/cargo@v1 + with: + command: fmt + args: --all -- --check + + clippy: + name: clippy + runs-on: ubuntu-latest + strategy: + matrix: + rust: + - stable + - 1.57.0 + steps: + - name: Checkout sources + uses: actions/checkout@v2 + + - name: Install toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.rust }} + override: true + + - name: Install clippy + run: rustup component add clippy + + - name: Run cargo clippy + uses: actions-rs/cargo@v1 + with: + command: clippy + args: -- -D warnings + + + test-vectors: + name: test-vectors + runs-on: ubuntu-latest + strategy: + matrix: + rust: + - stable + - 1.57.0 + steps: + - name: Checkout sources + uses: actions/checkout@v2 + - name: Install toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.rust }} + override: true + - name: build + run: | + git submodule update --init + make run-vectors + + audit: + name: cargo audit + runs-on: ubuntu-latest + strategy: + matrix: + rust: + - stable + - 1.57.0 + steps: + - name: Checkout sources + uses: actions/checkout@v2 + - name: Install toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.rust }} + override: true + - name: build + run: | + cargo install cargo-audit + cargo audit --ignore RUSTSEC-2020-0159 --ignore RUSTSEC-2020-0071 \ No newline at end of file diff --git a/blockchain/blocks/src/election_proof.rs b/blockchain/blocks/src/election_proof.rs index 31bae10d640f..b13843e37df6 100644 --- a/blockchain/blocks/src/election_proof.rs +++ b/blockchain/blocks/src/election_proof.rs @@ -228,9 +228,7 @@ pub mod json { where S: Serializer, { - v.as_ref() - .map(|s| ElectionProofJsonRef(s)) - .serialize(serializer) + v.as_ref().map(ElectionProofJsonRef).serialize(serializer) } pub fn deserialize<'de, D>(deserializer: D) -> Result, D::Error> diff --git a/blockchain/blocks/src/ticket.rs b/blockchain/blocks/src/ticket.rs index 6d9c32abda17..9be313909c86 100644 --- a/blockchain/blocks/src/ticket.rs +++ b/blockchain/blocks/src/ticket.rs @@ -67,7 +67,7 @@ pub mod json { where S: Serializer, { - v.as_ref().map(|s| TicketJsonRef(s)).serialize(serializer) + v.as_ref().map(TicketJsonRef).serialize(serializer) } pub fn deserialize<'de, D>(deserializer: D) -> Result, D::Error> diff --git a/crypto/src/signature.rs b/crypto/src/signature.rs index 9841670970cb..03b6720324e1 100644 --- a/crypto/src/signature.rs +++ b/crypto/src/signature.rs @@ -318,9 +318,7 @@ pub mod json { where S: Serializer, { - v.as_ref() - .map(|s| SignatureJsonRef(s)) - .serialize(serializer) + v.as_ref().map(SignatureJsonRef).serialize(serializer) } pub fn deserialize<'de, D>(deserializer: D) -> Result, D::Error> diff --git a/ipld/amt/src/node.rs b/ipld/amt/src/node.rs index 53b5f560d783..c146403c825b 100644 --- a/ipld/amt/src/node.rs +++ b/ipld/amt/src/node.rs @@ -353,7 +353,7 @@ where let sub_i = i / nodes_for_height(bit_width, height); match self { - Self::Leaf { vals } => Ok(vals.get_mut(i).map(|v| std::mem::take(v)).flatten()), + Self::Leaf { vals } => Ok(vals.get_mut(i).map(std::mem::take).flatten()), Self::Link { links } => { let (deleted, replace) = match &mut links[sub_i] { Some(Link::Dirty(n)) => { diff --git a/ipld/amt/src/value_mut.rs b/ipld/amt/src/value_mut.rs index 6487f034f196..6ce1c30045f9 100644 --- a/ipld/amt/src/value_mut.rs +++ b/ipld/amt/src/value_mut.rs @@ -41,6 +41,6 @@ impl Deref for ValueMut<'_, V> { impl DerefMut for ValueMut<'_, V> { fn deref_mut(&mut self) -> &mut Self::Target { self.value_mutated = true; - &mut self.value + self.value } } diff --git a/ipld/cid/src/json.rs b/ipld/cid/src/json.rs index bb481f2ebd16..36792a4e42bf 100644 --- a/ipld/cid/src/json.rs +++ b/ipld/cid/src/json.rs @@ -84,7 +84,7 @@ pub mod opt { where S: Serializer, { - v.as_ref().map(|s| CidJsonRef(s)).serialize(serializer) + v.as_ref().map(CidJsonRef).serialize(serializer) } pub fn deserialize<'de, D>(deserializer: D) -> Result, D::Error> diff --git a/ipld/src/json.rs b/ipld/src/json.rs index 55a35c2f98f0..41d05043c8f4 100644 --- a/ipld/src/json.rs +++ b/ipld/src/json.rs @@ -34,7 +34,7 @@ where serializer, ), Ipld::List(list) => { - let wrapped = list.iter().map(|ipld| IpldJsonRef(ipld)); + let wrapped = list.iter().map(IpldJsonRef); serializer.collect_seq(wrapped) } Ipld::Map(map) => { diff --git a/node/forest_libp2p/src/service.rs b/node/forest_libp2p/src/service.rs index 798aee5add46..6ee845399362 100644 --- a/node/forest_libp2p/src/service.rs +++ b/node/forest_libp2p/src/service.rs @@ -50,6 +50,7 @@ pub const PUBSUB_MSG_STR: &str = "/fil/msgs"; const PUBSUB_TOPICS: [&str; 2] = [PUBSUB_BLOCK_STR, PUBSUB_MSG_STR]; /// Events emitted by this Service. +#[allow(clippy::large_enum_variant)] #[derive(Debug)] pub enum NetworkEvent { PubsubMessage { @@ -72,6 +73,7 @@ pub enum NetworkEvent { } /// Message types that can come over GossipSub +#[allow(clippy::large_enum_variant)] #[derive(Debug, Clone)] pub enum PubsubMessage { /// Messages that come over the block topic diff --git a/vm/interpreter/src/gas_tracker/price_list.rs b/vm/interpreter/src/gas_tracker/price_list.rs index 948f755ab8c5..c9863c12057c 100644 --- a/vm/interpreter/src/gas_tracker/price_list.rs +++ b/vm/interpreter/src/gas_tracker/price_list.rs @@ -15,7 +15,7 @@ use vm::{MethodNum, TokenAmount, METHOD_SEND}; lazy_static! { static ref BASE_PRICES: PriceList = PriceList { - compute_gas_multiplier: 1, + _compute_gas_multiplier: 1, storage_gas_multiplier: 1000, on_chain_message_compute_base: 38863, @@ -44,7 +44,7 @@ lazy_static! { compute_unsealed_sector_cid_base: 98647, verify_seal_base: 2000, // TODO revisit potential removal of this - verify_aggregate_seal_base: 0, + _verify_aggregate_seal_base: 0, verify_aggregate_seal_per: [ ( RegisteredSealProof::StackedDRG32GiBV1P1, @@ -121,7 +121,7 @@ lazy_static! { }; static ref CALICO_PRICES: PriceList = PriceList { - compute_gas_multiplier: 1, + _compute_gas_multiplier: 1, storage_gas_multiplier: 1300, on_chain_message_compute_base: 38863, @@ -150,7 +150,7 @@ lazy_static! { compute_unsealed_sector_cid_base: 98647, verify_seal_base: 2000, // TODO revisit potential removal of this - verify_aggregate_seal_base: 0, + _verify_aggregate_seal_base: 0, verify_aggregate_seal_per: [ ( RegisteredSealProof::StackedDRG32GiBV1P1, @@ -264,7 +264,7 @@ pub struct PriceList { /// Compute gas charge multiplier // * This multiplier is not currently applied to anything, but is matching lotus. // * If the possible values are non 1 or if Lotus adds, we should change also. - pub(crate) compute_gas_multiplier: i64, + pub(crate) _compute_gas_multiplier: i64, /// Storage gas charge multiplier pub(crate) storage_gas_multiplier: i64, @@ -335,7 +335,7 @@ pub struct PriceList { pub(crate) compute_unsealed_sector_cid_base: i64, pub(crate) verify_seal_base: i64, - pub(crate) verify_aggregate_seal_base: i64, + pub(crate) _verify_aggregate_seal_base: i64, pub(crate) verify_aggregate_seal_per: AHashMap, pub(crate) verify_aggregate_seal_steps: AHashMap, diff --git a/vm/message/src/message_receipt.rs b/vm/message/src/message_receipt.rs index 7090371fdd4a..b1e9f852faf9 100644 --- a/vm/message/src/message_receipt.rs +++ b/vm/message/src/message_receipt.rs @@ -109,9 +109,7 @@ pub mod json { where S: Serializer, { - v.as_ref() - .map(|s| MessageReceiptJsonRef(s)) - .serialize(serializer) + v.as_ref().map(MessageReceiptJsonRef).serialize(serializer) } pub fn deserialize<'de, D>(deserializer: D) -> Result, D::Error>