Merge pull request #1 from antouhou/feat-ci

feat: add a GitHub actions to run test on PRs and publish on tags
This commit is contained in:
Anton Suprunchuk
2021-10-08 10:35:17 +03:00
committed by GitHub
3 changed files with 46 additions and 1 deletions

24
.github/workflows/publish.yml vendored Normal file
View File

@@ -0,0 +1,24 @@
name: Publish
on:
push:
tags:
- v*
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- name: Run tests
run: cargo test
- shell: bash
env:
CARGO_TOKEN: ${{ secrets.CARGO_TOKEN }}
run: cargo login "$CARGO_TOKEN" && cargo publish

21
.github/workflows/test.yml vendored Normal file
View File

@@ -0,0 +1,21 @@
name: Build and test
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- name: Run tests
run: cargo test

View File

@@ -87,7 +87,7 @@ impl<T: Hasher> MerkleProof<T> {
let proof_indices_by_layers = utils::indices::proof_indices_by_layers(leaf_indices, total_leaves_count);
// The next lines copy hashes from proof hashes and group them by layer index
let mut proof_layers: Vec<Vec<(usize, T::Hash)>> = Vec::with_capacity(tree_depth);
let mut proof_layers: Vec<Vec<(usize, T::Hash)>> = Vec::with_capacity(tree_depth + 1);
let mut proof_copy = self.proof_hashes.clone();
for proof_indices in proof_indices_by_layers {
let proof_hashes = proof_copy.splice(0..proof_indices.len(), []);