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

fix coverage in github action #259

Merged
merged 8 commits into from
Mar 22, 2024
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
17 changes: 9 additions & 8 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,17 @@ jobs:
- name: Install stable
uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
- name: cargo install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: cargo generate-lockfile
if: hashFiles('Cargo.lock') == ''
run: cargo generate-lockfile
toolchain: stable
- name: Install llvm-tools-preview
run: rustup component add llvm-tools-preview
- name: chmod data-dir
run: sudo chmod -R a+rwx ./data
- name: run coverage
run: just run-coverage
- name: run coverage test
run: just run-coverage-tests
- name: delete data-dir
run: sudo rm -rf ./data
- name: run coverage-report
run: just run-coverage-report
- name: Upload to codecov.io
uses: codecov/codecov-action@v4
with:
Expand Down
16 changes: 13 additions & 3 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,27 @@ final-check:
just run-itests
just build-wasm


# run coverage and create a report in html and lcov format
run-coverage:
#!/usr/bin/env bash
just run-coverage-tests
just run-coverage-report

# runs all tests with coverage instrumentation
run-coverage-tests:
docker compose --profile itest up -d
mkdir -p target/coverage
RUST_BACKTRACE=1 CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-test-%p-%m.profraw' cargo test -- --test-threads=1
docker compose --profile itest down
grcov . --binary-path ./target/debug/deps/ -s . -t lcov,html --branch --ignore-not-existing --ignore '../*' --ignore "/*" --ignore "./data" -o target/coverage/

# creates a coverage report in html and lcov format
run-coverage-report:
#!/usr/bin/env bash
mkdir -p target/coverage
grcov . --binary-path ./target/debug/ -s . -t lcov,html --branch --ignore-not-existing --ignore "*cargo*" --ignore "./data/*" -o target/coverage/
find . -name '*.profraw' -exec rm -r {} \;
>&2 echo '💡 Created the report in html-format target/coverage/html/index.html'


# run the cashu-mint
run-mint *ARGS:
RUST_BACKTRACE=1 MINT_APP_ENV=dev cargo run --bin moksha-mint -- {{ARGS}}
Expand Down
Loading