Skip to content

Commit

Permalink
Merge pull request #8 from rodneylab/test__update_coverage
Browse files Browse the repository at this point in the history
test: ☑️ update coverage
  • Loading branch information
rodneylab authored Feb 5, 2025
2 parents 8027be1 + f853066 commit 041f38e
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 2 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/general.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,18 @@ jobs:
egress-policy: audit
disable-telemetry: true
- name: Install Linux Dependencies
run: sudo apt-get update
run: sudo apt-get update && sudo apt-get install python3-venv
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
- name: Install Python dependencies
run: |
python -m venv .env
source .env/bin/activate
pip install -r "requirements/ci-requirements.txt" --require-hashes
maturin develop
python -m coverage run -m unittest tests/test_subsetter_tool.py
python -m coverage xml
- uses: dtolnay/rust-toolchain@38b70195107dddab2c7bbd522bcf763bac00963b # stable
with:
components: llvm-tools-preview
Expand All @@ -110,6 +119,6 @@ jobs:
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@13ce06bfc6bbe3ecf90edbbf1bc32fe5978ca1d3 # v5.3.1
with:
files: ./target/debug/lcov
files: ./target/debug/lcov,./coverage.xml
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
15 changes: 15 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,27 @@ test:

# run python coverage using coverage
coverage:
# Python coverage
python3 -m coverage run -m unittest tests/test_subsetter_tool.py
python3 -m coverage report
python3 -m coverage html
python3 -m coverage lcov
python3 -m coverage xml

# Rust coverage
rm -f subsetter-*.profraw 2>/dev/null
cargo clean
cargo build
C_COMPILER=$(brew --prefix llvm)/bin/clang RUSTFLAGS="-Cinstrument-coverage" \
LLVM_PROFILE_FILE="subsetter-%p-%m.profraw" cargo test
grcov . -s . --binary-path ./target/debug/ -t html --branch --ignore-not-existing \
-o ./target/debug/coverage/
open --reveal ./target/debug/coverage
sed -i '' "s|href=\"https://cdn.jsdelivr.net/npm/bulma@0.9.1/css/bulma.min.css\"|href=\"file://`pwd`/.cache/bulma.min.css\"|g" ./target/debug/coverage/**/*.html
mkdir -p .cache
curl --time-cond .cache/bulma.min.css -C - -Lo .cache/bulma.min.css \
https://cdn.jsdelivr.net/npm/bulma/css/bulma.min.css

# generate docs for a crate and copy link to clipboard
doc crate:
cargo doc -p {{ crate }}
Expand Down
18 changes: 18 additions & 0 deletions requirements/ci-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Brotli==1.1.0 \
--hash=sha256:d0c5516f0aed654134a2fc936325cc2e642f8a0e096d075209672eb321cff408
coverage==7.6.10 \
--hash=sha256:e67926f51821b8e9deb6426ff3164870976fe414d033ad90ea75e7ed0c2e5022
fonttools==4.55.3 \
--hash=sha256:b8d5e8916c0970fbc0f6f1bece0063363bb5857a7f170121a4493e31c3db3314
maturin==1.8.1 \
--hash=sha256:98f638739a5132962347871b85c91f525c9246ef4d99796ae98a2031e3df029f
mypy==1.14.1 \
--hash=sha256:553c293b1fbdebb6c3c4030589dab9fafb6dfa768995a453d8a5d3b23784af2e
mypy-extensions==1.0.0 \
--hash=sha256:4392f6c0eb8a5668a69e23d168ffa70f0be9ccfd32b5cc2d26a34ae5b844552d
pyperclip==1.9.0 \
--hash=sha256:b7de0142ddc81bfc5c7507eea19da920b92252b548b96186caf94a5e2527d310
pyperclip-stubs==0.0.2 \
--hash=sha256:b5cf9dc188da7b491bbb31a96d13f11811d8b904b5e271cd65d148b1f13a2f4a
typing_extensions==4.6.0 \
--hash=sha256:6ad00b63f849b7dcc313b70b6b304ed67b2b2963b3098a33efe18056b1a9a223
File renamed without changes.
17 changes: 17 additions & 0 deletions src/domain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,3 +205,20 @@ pub fn unicodes(text: &str) -> String {

ranges_string
}

#[cfg(test)]
mod tests {
use super::hash;

#[test]
fn hash_generates_expected_result_for_valid_input() {
// arrange
let text = "Halloa!";

// act
let result = hash(text);

// assert
assert_eq!(result, String::from("69178b77"));
}
}

0 comments on commit 041f38e

Please sign in to comment.