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

Add CI workflow #14

Merged
merged 3 commits into from
Jun 29, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
24 changes: 24 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: release
on:
push:
tags:
- v*
jobs:
check-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Check version
run: |
TAG_VERSION=$(echo ${GITHUB_REF#refs/tags/v})
CRATE_VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')
test "$TAG_VERSION" = "$CRATE_VERSION"
publish:
runs-on: ubuntu-latest
needs: check-version
env:
CARGO_REGISTRY_TOKEN: "${{ secrets.CARGO_REGISTRY_TOKEN }}"
Copy link
Member Author

Choose a reason for hiding this comment

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

@michaelsproul I think it will need this secret added to the project

Copy link
Member

Choose a reason for hiding this comment

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

cool, will add that before trying to publish the first release

steps:
- uses: actions/checkout@v3
- name: Publish crate
run: cargo publish -p milhouse
44 changes: 44 additions & 0 deletions .github/workflows/test-suite.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: test-suite

on:
push:
branches:
- main
- 'pr/*'
pull_request:
env:
# Deny warnings in CI
RUSTFLAGS: "-D warnings"
jobs:
cargo-fmt:
name: cargo-fmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Get latest version of stable Rust
run: rustup update stable
- name: Check formatting with cargo fmt
run: cargo fmt --all -- --check
clippy:
name: clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Get latest version of stable Rust
run: rustup update stable
- name: Lint code for quality and style with Clippy
run: cargo clippy --all
test:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
name: test-${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Get latest version of stable Rust
run: rustup update stable
- name: Run tests
run: cargo test --release
- name: Check all examples, binaries, etc
run: cargo check --all-targets
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
Cargo.lock

/proptest-regressions

# IntelliJ / Clion
.idea
1 change: 1 addition & 0 deletions src/cow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ impl<'a, T: Clone> Cow<'a, T> {
}

pub trait CowTrait<'a, T: Clone>: Deref<Target = T> {
#[allow(clippy::wrong_self_convention)]
fn to_mut(self) -> &'a mut T;
}

Expand Down
5 changes: 3 additions & 2 deletions src/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ impl<T: TreeHash + Clone, N: Unsigned, U: UpdateMap<T>> List<T, N, U> {
impl<T: TreeHash + Clone, N: Unsigned> ImmList<T> for ListInner<T, N> {
fn get(&self, index: usize) -> Option<&T> {
if index < self.len().as_usize() {
self.tree.get_recursive(index, self.depth, self.packing_depth)
self.tree
.get_recursive(index, self.depth, self.packing_depth)
} else {
None
}
Expand Down Expand Up @@ -298,7 +299,7 @@ impl<'a, T: TreeHash + Clone, N: Unsigned, U: UpdateMap<T>> IntoIterator for &'a
}
}

impl<'a, T: TreeHash + Clone, N: Unsigned, U: UpdateMap<T>> Serialize for List<T, N, U>
impl<T: TreeHash + Clone, N: Unsigned, U: UpdateMap<T>> Serialize for List<T, N, U>
where
T: Serialize,
{
Expand Down
2 changes: 1 addition & 1 deletion src/tests/packed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ fn u64_packed_vector_tree_hash() {
let len = 16;
let vec = (0..len).map(|i| 2 * i).collect::<Vec<u64>>();
let vector = Vector::<u64, U16>::new(vec.clone()).unwrap();
let fixed_vector = FixedVector::<u64, U16>::new(vec.clone()).unwrap();
let fixed_vector = FixedVector::<u64, U16>::new(vec).unwrap();

assert_eq!(vector.tree_hash_root(), fixed_vector.tree_hash_root());
}
Expand Down
3 changes: 2 additions & 1 deletion src/vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ impl<T: TreeHash + Clone, N: Unsigned, U: UpdateMap<T>> From<Vector<T, N, U>> fo
impl<T: TreeHash + Clone, N: Unsigned> ImmList<T> for VectorInner<T, N> {
fn get(&self, index: usize) -> Option<&T> {
if index < self.len().as_usize() {
self.tree.get_recursive(index, self.depth, self.packing_depth)
self.tree
.get_recursive(index, self.depth, self.packing_depth)
} else {
None
}
Expand Down