Skip to content

Commit

Permalink
Merge pull request #1 from semiotic-ai/joseph/set-up-ci
Browse files Browse the repository at this point in the history
ci: set up CI
  • Loading branch information
suchapalaver authored Nov 29, 2024
2 parents edf275a + 7ecef07 commit 7591ec9
Show file tree
Hide file tree
Showing 10 changed files with 224 additions and 12 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/audit.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
22 changes: 22 additions & 0 deletions .github/workflows/conventional-commits.yml
Original file line number Diff line number Diff line change
@@ -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
31 changes: 31 additions & 0 deletions .github/workflows/license_headers_check.yml
Original file line number Diff line number Diff line change
@@ -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' \
.
122 changes: 122 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -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
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/fetch_beacon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion examples/fetch_ethereum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion examples/stream_ethereum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
3 changes: 3 additions & 0 deletions src/client.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright 2024-, Semiotic AI, Inc.
// SPDX-License-Identifier: Apache-2.0

use std::str::FromStr;

use crate::error::ClientError;
Expand Down
7 changes: 4 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -29,17 +29,18 @@
//!
//! ## Streaming Ethereum Blocks
//!
//! ```no_run
//! ```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;
//! const START_BLOCK: u64 = 19581798;
//!
//! let mut client = FirehoseClient::new(Chain::Ethereum);
//! let mut stream = client
//! .stream_blocks(START_BLOCK, TOTAL_BLOCKS)
//! .stream_blocks::<Block>(START_BLOCK, TOTAL_BLOCKS)
//! .await
//! .unwrap();
//!
Expand Down

0 comments on commit 7591ec9

Please sign in to comment.