From 70c80f76f0ef864d00778d6ca3c64987659be16b Mon Sep 17 00:00:00 2001 From: Joseph Livesey Date: Fri, 29 Nov 2024 15:21:59 -0500 Subject: [PATCH 1/4] ci: set up CI --- .github/workflows/audit.yml | 33 ++++++ .github/workflows/conventional-commits.yml | 22 ++++ .github/workflows/license_headers_check.yml | 31 +++++ .github/workflows/tests.yml | 122 ++++++++++++++++++++ 4 files changed, 208 insertions(+) create mode 100644 .github/workflows/audit.yml create mode 100644 .github/workflows/conventional-commits.yml create mode 100644 .github/workflows/license_headers_check.yml create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml new file mode 100644 index 0000000..f661b9b --- /dev/null +++ b/.github/workflows/audit.yml @@ -0,0 +1,33 @@ +name: Security audit +on: + push: + paths: + - '**/Cargo.toml' + - '**/Cargo.lock' + +permissions: + issues: write + checks: write + contents: read + +jobs: + security_audit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Cache dependencies + uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 #v2.7.3 + if: ${{ !startsWith(github.head_ref, 'renovate/') }} + - name: Configure sccache + run: | + echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV + echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV + if: ${{ !startsWith(github.head_ref, 'renovate/') }} + - name: Run sccache-cache + uses: mozilla-actions/sccache-action@89e9040de88b577a072e3760aaf59f585da083af #v0.0.5 + if: ${{ !startsWith(github.head_ref, 'renovate/') }} + - name: Install Protoc + uses: arduino/setup-protoc@v3 + - uses: rustsec/audit-check@v1.4.1 + with: + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/conventional-commits.yml b/.github/workflows/conventional-commits.yml new file mode 100644 index 0000000..36c87d9 --- /dev/null +++ b/.github/workflows/conventional-commits.yml @@ -0,0 +1,22 @@ +name: "Lint PR" + +on: + pull_request: + +jobs: + conventional-commits-check: + name: Check conventional commits + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 + with: + fetch-depth: 0 + ref: ${{ github.event.pull_request.head.sha }} + - uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5 + with: + python-version: "3.10" + - name: Install commitizen + run: pip install commitizen + - name: commitizen check + run: cz check --rev-range ${{ github.event.pull_request.base.sha }}..HEAD diff --git a/.github/workflows/license_headers_check.yml b/.github/workflows/license_headers_check.yml new file mode 100644 index 0000000..4cea7cf --- /dev/null +++ b/.github/workflows/license_headers_check.yml @@ -0,0 +1,31 @@ +name: License headers check + +on: + push: + branches: [main] + pull_request: + workflow_dispatch: + +jobs: + check: + name: License headers check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 + - name: Install addlicense + run: | + wget https://github.com/google/addlicense/releases/download/v1.1.1/addlicense_1.1.1_Linux_x86_64.tar.gz + tar -xzf addlicense_1.1.1_Linux_x86_64.tar.gz + sudo mv addlicense /usr/local/bin + - name: Check license headers + run: > + addlicense \ + -check \ + -c "Semiotic AI, Inc." \ + -l "apache" \ + -s=only \ + -ignore '.github/workflows/*.yml' \ + -ignore '.github/*.yml' \ + -ignore '.github/workflows/*.yaml' \ + -ignore '.github/*.yaml' \ + . diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..6e226f5 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,122 @@ +name: tests + +on: + push: + branches: [main] + pull_request: + workflow_dispatch: + +jobs: + fmt: + name: cargo fmt + runs-on: ubuntu-latest + container: + image: rust:1.82-bookworm + steps: + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 + - run: | + rustup component add rustfmt + cargo fmt --all -- --check + + clippy: + name: cargo clippy + runs-on: ubuntu-latest + container: + image: rust:1.82-bookworm + steps: + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 + - name: Cache dependencies + uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 #v2.7.3 + if: ${{ !startsWith(github.head_ref, 'renovate/') }} + - name: Configure sccache + run: | + echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV + echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV + if: ${{ !startsWith(github.head_ref, 'renovate/') }} + - name: Run sccache-cache + uses: mozilla-actions/sccache-action@89e9040de88b577a072e3760aaf59f585da083af #v0.0.5 + if: ${{ !startsWith(github.head_ref, 'renovate/') }} + - name: Install Protoc + uses: arduino/setup-protoc@v3 + - run: | + rustup component add clippy + # Temporarily allowing dead-code, while denying all other warnings + cargo clippy --all-features --all-targets -- -A dead-code -D warnings + + test: + name: cargo test + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + actions: read + container: + image: rust:1.82-bookworm + steps: + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 + - name: Cache dependencies + uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 #v2.7.3 + if: ${{ !startsWith(github.head_ref, 'renovate/') }} + - name: Configure sccache + run: | + echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV + echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV + if: ${{ !startsWith(github.head_ref, 'renovate/') }} + - name: Run sccache-cache + uses: mozilla-actions/sccache-action@89e9040de88b577a072e3760aaf59f585da083af #v0.0.5 + if: ${{ !startsWith(github.head_ref, 'renovate/') }} + - name: Install Protoc + uses: arduino/setup-protoc@v3 + - name: Run tests + run: cargo test --all-features --workspace + + # Cannot do with llvm-cov, see https://github.com/taiki-e/cargo-llvm-cov/issues/2 + test-docs: + name: cargo test docs code snippets + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + actions: read + container: + image: rust:1.82-bookworm + steps: + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 + - name: Cache dependencies + uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 #v2.7.3 + if: ${{ !startsWith(github.head_ref, 'renovate/') }} + - name: Configure sccache + run: | + echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV + echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV + if: ${{ !startsWith(github.head_ref, 'renovate/') }} + - name: Run sccache-cache + uses: mozilla-actions/sccache-action@89e9040de88b577a072e3760aaf59f585da083af #v0.0.5 + if: ${{ !startsWith(github.head_ref, 'renovate/') }} + - name: Install Protoc + uses: arduino/setup-protoc@v3 + - name: Test documentation code snippets + run: cargo test --doc --all-features --workspace + + build: + name: cargo check + runs-on: ubuntu-latest + container: + image: rust:1.82-bookworm + steps: + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 + - name: Cache dependencies + uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 #v2.7.3 + if: ${{ !startsWith(github.head_ref, 'renovate/') }} + - name: Configure sccache + run: | + echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV + echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV + if: ${{ !startsWith(github.head_ref, 'renovate/') }} + - name: Run sccache-cache + uses: mozilla-actions/sccache-action@89e9040de88b577a072e3760aaf59f585da083af #v0.0.5 + if: ${{ !startsWith(github.head_ref, 'renovate/') }} + - name: Install Protoc + uses: arduino/setup-protoc@v3 + - name: Cargo check + run: cargo check From a221a2c1a7c58384ffae44eed5b922c00f24f5de Mon Sep 17 00:00:00 2001 From: Joseph Livesey Date: Fri, 29 Nov 2024 15:24:00 -0500 Subject: [PATCH 2/4] fix(client): add missing spdx --- src/client.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/client.rs b/src/client.rs index f40d5a7..82c99a0 100644 --- a/src/client.rs +++ b/src/client.rs @@ -1,3 +1,6 @@ +// Copyright 2024-, Semiotic AI, Inc. +// SPDX-License-Identifier: Apache-2.0 + use std::str::FromStr; use crate::error::ClientError; From 9129268eb80641cc3857eb27152ab4f10e0bc64f Mon Sep 17 00:00:00 2001 From: Joseph Livesey Date: Fri, 29 Nov 2024 15:29:37 -0500 Subject: [PATCH 3/4] docs: fix import path in docstring --- Cargo.lock | 12 ++++++------ examples/fetch_beacon.rs | 2 +- examples/fetch_ethereum.rs | 2 +- examples/stream_ethereum.rs | 2 +- src/lib.rs | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ad1f971..32be759 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -838,7 +838,7 @@ checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] name = "beacon-protos" version = "0.1.1" -source = "git+https://github.com/semiotic-ai/beacon-protos.git?branch=main#8110fadbe86c421f90651cc017cf75c83f88c218" +source = "git+https://github.com/semiotic-ai/beacon-protos.git?branch=main#3fe9a2e91dd1788d53f97acb6fd3616cdfa1fda3" dependencies = [ "bls", "firehose-rs", @@ -2062,7 +2062,7 @@ dependencies = [ [[package]] name = "firehose-protos" version = "0.1.0" -source = "git+https://github.com/semiotic-ai/veemon.git?branch=main#16df05cc93e737b3422b59560fbbcfb3cbd32ed7" +source = "git+https://github.com/semiotic-ai/veemon.git?branch=main#8534fb8dcda37d89a1527ed4db4c5dce18766c90" dependencies = [ "alloy-consensus", "alloy-eip2930", @@ -2087,7 +2087,7 @@ dependencies = [ [[package]] name = "firehose-rs" version = "0.1.0" -source = "git+https://github.com/semiotic-ai/firehose-rs.git?branch=main#55851f4e89ba4191c0dab83b3391d9c3b5bbbcf1" +source = "git+https://github.com/semiotic-ai/firehose-rs.git?branch=main#d6ac5c1f3228fffc4cfb0f1cf623a948477cf167" dependencies = [ "prost", "prost-build", @@ -2120,7 +2120,7 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "flat-files-decoder" version = "0.1.0" -source = "git+https://github.com/semiotic-ai/veemon.git?branch=main#16df05cc93e737b3422b59560fbbcfb3cbd32ed7" +source = "git+https://github.com/semiotic-ai/veemon.git?branch=main#8534fb8dcda37d89a1527ed4db4c5dce18766c90" dependencies = [ "alloy-consensus", "alloy-eip2930", @@ -2451,7 +2451,7 @@ dependencies = [ [[package]] name = "header-accumulator" version = "0.1.0" -source = "git+https://github.com/semiotic-ai/veemon.git?branch=main#16df05cc93e737b3422b59560fbbcfb3cbd32ed7" +source = "git+https://github.com/semiotic-ai/veemon.git?branch=main#8534fb8dcda37d89a1527ed4db4c5dce18766c90" dependencies = [ "alloy-primitives 0.8.14", "base64 0.21.7", @@ -6076,7 +6076,7 @@ checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" [[package]] name = "vee" version = "0.1.0" -source = "git+https://github.com/semiotic-ai/veemon.git?branch=main#16df05cc93e737b3422b59560fbbcfb3cbd32ed7" +source = "git+https://github.com/semiotic-ai/veemon.git?branch=main#8534fb8dcda37d89a1527ed4db4c5dce18766c90" dependencies = [ "firehose-protos", "flat-files-decoder", diff --git a/examples/fetch_beacon.rs b/examples/fetch_beacon.rs index 2404627..6150450 100644 --- a/examples/fetch_beacon.rs +++ b/examples/fetch_beacon.rs @@ -7,7 +7,7 @@ use beacon_protos::{Block as BeaconBlock, Body}; use firehose_client::{Chain, FirehoseClient}; -use vee::protos::EthBlock; +use vee::EthBlock; #[tokio::main] async fn main() { diff --git a/examples/fetch_ethereum.rs b/examples/fetch_ethereum.rs index eb5d822..a929609 100644 --- a/examples/fetch_ethereum.rs +++ b/examples/fetch_ethereum.rs @@ -6,7 +6,7 @@ //! Demonstrates how to fetch a single block from Ethereum firehose. use firehose_client::{Chain, FirehoseClient}; -use vee::protos::EthBlock as Block; +use vee::EthBlock as Block; #[tokio::main] async fn main() { diff --git a/examples/stream_ethereum.rs b/examples/stream_ethereum.rs index d752d73..4bc4019 100644 --- a/examples/stream_ethereum.rs +++ b/examples/stream_ethereum.rs @@ -6,7 +6,7 @@ //! This example demonstrates how to stream Ethereum blocks using the Firehose client. use firehose_client::{Chain, FirehoseClient}; use futures::StreamExt; -use vee::protos::EthBlock as Block; +use vee::EthBlock as Block; #[tokio::main] async fn main() { diff --git a/src/lib.rs b/src/lib.rs index 5d1fc2e..1fc41ae 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,7 +8,7 @@ //! //! ## Fetching an Ethereum Block //! -//! ```no_run +//! ```rust,no_run //! # use firehose_client::{Chain, FirehoseClient}; //! # use vee::EthBlock as Block; //! # #[tokio::main] @@ -29,7 +29,7 @@ //! //! ## Streaming Ethereum Blocks //! -//! ```no_run +//! ```rust,no_run //! # use firehose_client::{Chain, FirehoseClient}; //! # use futures::StreamExt; //! # #[tokio::main] From 7ecef0745051c0205a76685cf69e12d947442dca Mon Sep 17 00:00:00 2001 From: Joseph Livesey Date: Fri, 29 Nov 2024 15:52:13 -0500 Subject: [PATCH 4/4] fix: example docstring --- src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 1fc41ae..005e7d1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -32,6 +32,7 @@ //! ```rust,no_run //! # use firehose_client::{Chain, FirehoseClient}; //! # use futures::StreamExt; +//! # use vee::EthBlock as Block; //! # #[tokio::main] //! # async fn main() -> Result<(), vee::ProtosError> { //! const TOTAL_BLOCKS: u64 = 8192; @@ -39,7 +40,7 @@ //! //! let mut client = FirehoseClient::new(Chain::Ethereum); //! let mut stream = client -//! .stream_blocks(START_BLOCK, TOTAL_BLOCKS) +//! .stream_blocks::(START_BLOCK, TOTAL_BLOCKS) //! .await //! .unwrap(); //!