Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add rust_ci.yaml github workflow #15

Merged
merged 13 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 132 additions & 0 deletions .github/workflows/rust_ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
name: Rust CI

on:
push:
branches: [master]
merge_group:
pull_request:

env:
CARGO_TERM_COLOR: always

jobs:
cargo-tests:
runs-on: ubuntu-latest
timeout-minutes: 20
name: test
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
submodules: true
- uses: taiki-e/install-action@just
- name: Install Rust stable toolchain
uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- uses: taiki-e/install-action@nextest
- name: cargo test
run: just test
cargo-lint:
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
matrix:
# TODO: add back cannon and asterisc once we are using them
# See https://github.com/Layr-Labs/kona/blob/main/.github/workflows/rust_ci.yaml
target: ["native"]
name: lint-${{ matrix.target }}
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
submodules: true
- uses: taiki-e/install-action@just
- name: Install Rust nightly toolchain
uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
prefix-key: ${{ matrix.target }}
- name: Log into ghcr
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: fmt + lint
run: just lint-${{ matrix.target }}
- name: chown target
run: |
sudo chown -R $(id -u):$(id -g) ./target
cargo-build:
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
matrix:
# TODO: add back cannon and asterisc once we are using them
# See https://github.com/Layr-Labs/kona/blob/main/.github/workflows/rust_ci.yaml
target: ["native"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we actually want to build? it takes super long

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name: build-${{ matrix.target }}
continue-on-error: true
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
submodules: true
- uses: taiki-e/install-action@just
- name: Install Rust stable toolchain
uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
prefix-key: ${{ matrix.target }}
- name: Log into ghcr
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: build
run: just build-${{ matrix.target }}
- name: chown target
run: |
sudo chown -R $(id -u):$(id -g) ./target
cargo-doc:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
submodules: true
- uses: taiki-e/install-action@just
- name: Install Rust stable toolchain
uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: doclint
run: just lint-docs
- name: doctest
run: just test-docs
cargo-hack:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
submodules: true
- uses: taiki-e/install-action@just
- name: Install Rust stable toolchain
uses: dtolnay/rust-toolchain@stable
- uses: taiki-e/install-action@cargo-hack
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: cargo hack
run: just hack
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[workspace]
resolver = "2"
members = ["bin/*"]
members = ["bin/*", "crates/*"]

[workspace.dependencies]
# Workspace
Expand Down
32 changes: 32 additions & 0 deletions crates/eigenda/src/eigenda_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,35 @@ impl EigenDABlobData {
Ok(self.blob.clone())
}
}

#[cfg(test)]
mod tests {
use super::*;
use alloc::vec;
use alloy_primitives::Bytes;

#[test]
fn test_decode_success() {
let data = EigenDABlobData {
blob: Bytes::from(vec![1, 2, 3, 4]),
};
let result = data.decode();
assert!(result.is_ok());
assert_eq!(result.unwrap(), Bytes::from(vec![1, 2, 3, 4]));
}

#[test]
fn test_decode_empty_blob() {
let data = EigenDABlobData {
blob: Bytes::from(vec![]),
};
let result = data.decode();
assert!(result.is_ok());
assert_eq!(result.unwrap(), Bytes::from(vec![]));
}

#[test]
fn test_decode_invalid_blob() {
// TODO: implement this once decode actually does something
}
}
Loading