diff --git a/.github/actions-rs/grcov.yml b/.github/actions-rs/grcov.yml new file mode 100644 index 0000000..2ef4c15 --- /dev/null +++ b/.github/actions-rs/grcov.yml @@ -0,0 +1,2 @@ +output-type: lcov +output-file: ./lcov.info diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 0000000..a94936f --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,40 @@ +on: push + +name: Coverage + +jobs: + coverage: + name: Codecov + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install minimal nightly toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: nightly + override: true + + - name: Run cargo test + uses: actions-rs/cargo@v1 + with: + command: test + args: --all-features --no-fail-fast + 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 + id: coverage + uses: actions-rs/grcov@v0.1 + + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v4.0.1 + with: + token: ${{ secrets.CODECOV_TOKEN }} + file: ${{ steps.coverage.outputs.report }} + verbose: true + fail_ci_if_error: true diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..6df8ae4 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,31 @@ +on: push + +name: Lint + +jobs: + lint: + name: Clippy + rustfmt + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install minimal nightly toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: nightly + components: rustfmt, clippy + override: true + + - name: Run cargo fmt + uses: actions-rs/cargo@v1 + with: + command: fmt + args: --all -- --check + + - name: Run cargo clippy + uses: actions-rs/cargo@v1 + with: + command: clippy + args: -- -D warnings diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..35314fe --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,28 @@ +on: push + +name: Test + +jobs: + test: + name: Check + test + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install minimal nightly toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: nightly + override: true + + - name: Run cargo check + uses: actions-rs/cargo@v1 + with: + command: check + + - name: Run cargo test + uses: actions-rs/cargo@v1 + with: + command: test diff --git a/fa-compression/src/decode.rs b/fa-compression/src/decode.rs index 6c738e0..1568102 100644 --- a/fa-compression/src/decode.rs +++ b/fa-compression/src/decode.rs @@ -26,7 +26,7 @@ static PREFIXES: [&str; 3] = ["EC:", "GO:", "IPR:IPR"]; /// # Examples /// /// ``` -/// use fa_compression::decode::decode; +/// use fa_compression::decode; /// /// let input = &[ 44, 44, 44, 189, 17, 26, 56, 173, 18, 116, 117, 225, 67, 116, 110, 17, 153, 39 ]; /// let result = decode(input); diff --git a/fa-compression/src/encode.rs b/fa-compression/src/encode.rs index 2b7bc12..9249b8c 100644 --- a/fa-compression/src/encode.rs +++ b/fa-compression/src/encode.rs @@ -23,7 +23,7 @@ use crate::{ /// # Examples /// /// ``` -/// use fa_compression::encode::encode; +/// use fa_compression::encode; /// /// let input = "IPR:IPR016364;EC:1.1.1.-;GO:0009279"; /// let encoded = encode(input); diff --git a/fa-compression/src/lib.rs b/fa-compression/src/lib.rs index 939f716..645756c 100644 --- a/fa-compression/src/lib.rs +++ b/fa-compression/src/lib.rs @@ -223,4 +223,22 @@ mod tests { } } } + + #[test] + #[should_panic] + fn test_encode_invalid() { + CharacterSet::encode(b'A'); + } + + #[test] + #[should_panic] + fn test_decode_invalid() { + CharacterSet::decode(15); + } + + #[test] + #[should_panic] + fn test_decode_pair_invalid() { + CharacterSet::decode_pair(0b11111111); + } }