From 84edc18c4fe3b3412a0d4bc4d7e43f97f0170dc9 Mon Sep 17 00:00:00 2001 From: tibvdm Date: Thu, 16 May 2024 15:25:46 +0200 Subject: [PATCH] add coverage for bitarray and small README --- .github/workflows/coverage.yml | 29 +++++++++++++++++++++++++++++ bitarray/README.md | 21 +++++++++++++++++++++ bitarray/src/lib.rs | 1 - codecov.yml | 12 ++++++++++++ 4 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 bitarray/README.md diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index bf98de4..88368eb 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -19,6 +19,33 @@ jobs: toolchain: nightly override: true + + + - name: Run cargo test (bitarray) + uses: actions-rs/cargo@v1 + with: + command: test + args: --all-features --no-fail-fast -p bitarray + env: + CARGO_INCREMENTAL: 0 + RUSTFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' + RUSTDOCFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' + + - name: Gather coverage information (bitarray) + id: coverage-bitarray + uses: actions-rs/grcov@v0.1 + + - name: Upload coverage reports to Codecov (bitarray) + uses: codecov/codecov-action@v4.0.1 + with: + token: ${{ secrets.CODECOV_TOKEN }} + file: ${{ steps.coverage-bitarray.outputs.report }} + flags: bitarray + verbose: true + fail_ci_if_error: true + + + - name: Run cargo test (fa-compression) uses: actions-rs/cargo@v1 with: @@ -42,6 +69,8 @@ jobs: verbose: true fail_ci_if_error: true + + - name: Run cargo test (sa-mappings) uses: actions-rs/cargo@v1 with: diff --git a/bitarray/README.md b/bitarray/README.md new file mode 100644 index 0000000..074f7c5 --- /dev/null +++ b/bitarray/README.md @@ -0,0 +1,21 @@ +# Bitarray + +![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/unipept/unipept-index/test.yml?logo=github) +![Codecov](https://img.shields.io/codecov/c/github/unipept/unipept-index?token=IZ75A2FY98&flag=bitarray&logo=codecov) +![Static Badge](https://img.shields.io/badge/doc-rustdoc-blue) + +The `bitarray` offers a special array where each item is represented by a specified amount of bits (smaller than 64). The bitarray uses a pre-alocated vector and allows you to `set` or `get` a value from the array. + +## Example + +```rust +use bitarray; + +fn main() { + let bitarray = BitArray::<40>::with_capacity(4); + + bitarray.set(0, 0b0001110011111010110001000111111100110010); + + assert_eq!(bitarray.get(0), 0b0001110011111010110001000111111100110010); +} +``` diff --git a/bitarray/src/lib.rs b/bitarray/src/lib.rs index d8a1e9b..5a721dc 100644 --- a/bitarray/src/lib.rs +++ b/bitarray/src/lib.rs @@ -83,7 +83,6 @@ mod tests { #[test] fn test_bitarray_set() { let mut bitarray = BitArray::<40>::with_capacity(4); - bitarray.data = vec![ 0, 0, 0 ]; bitarray.set(0, 0b0001110011111010110001000111111100110010); bitarray.set(1, 0b1100001001010010011000010100110111001001); diff --git a/codecov.yml b/codecov.yml index 030fcbe..6d769bf 100644 --- a/codecov.yml +++ b/codecov.yml @@ -3,6 +3,10 @@ coverage: project: default: target: 90% + bitarray: + target: 90% + flags: + - bitarray fa-compression: target: 90% flags: @@ -14,6 +18,10 @@ coverage: patch: default: target: 90% + bitarray: + target: 90% + flags: + - bitarray fa-compression: target: 90% flags: @@ -24,6 +32,10 @@ coverage: - sa-mappings flags: + bitarray: + paths: + - bitarray + carryforward: true fa-compression: paths: - fa-compression