Skip to content

Commit

Permalink
Add code coverage (via tarpaulin)
Browse files Browse the repository at this point in the history
  • Loading branch information
measure-fi committed Nov 30, 2022
1 parent 026da32 commit b962252
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 47 deletions.
30 changes: 5 additions & 25 deletions .github/workflows/Basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,8 @@ jobs:
target: wasm32-unknown-unknown
override: true

- name: Run unit tests
uses: actions-rs/cargo@v1
with:
command: unit-test
args: --locked
env:
RUST_BACKTRACE: 1
- run: cargo check --verbose --locked --all-targets
- run: cargo test --verbose --locked --no-fail-fast

- name: Compile WASM contract
uses: actions-rs/cargo@v1
Expand All @@ -51,24 +46,9 @@ jobs:
toolchain: stable
override: true
components: rustfmt, clippy

- 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

- name: Generate Schema
uses: actions-rs/cargo@v1
with:
command: schema
args: --locked
- run: cargo fetch --verbose --locked
- run: cargo clippy --all --all-targets -- -D warnings
- run: cargo fmt --all -- --check

- name: Schema Changes
# fails if any changes not committed
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Coverage

on: [pull_request]

jobs:
coverage:
runs-on: ubuntu-latest
env:
CARGO_TERM_COLOR: always
steps:
- uses: actions/checkout@v3
- name: Install Rust
run: rustup update nightly
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Generate code coverage
run: cargo +nightly llvm-cov --all-features --workspace --lcov --output-path lcov.info
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
files: lcov.info
fail_ci_if_error: true
108 changes: 89 additions & 19 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ optimize = """docker run --rm -v "$(pwd)":/code \
"""

[dependencies]
cosmwasm-schema = "1.1.5"
cosmwasm-std = "1.1.5"
cw-storage-plus = "0.16.0"
cosmwasm-schema = { git = "https://github.com/palomachain/cosmwasm", branch = "cov" }
cosmwasm-std = { git = "https://github.com/palomachain/cosmwasm", branch = "cov" }
#cosmwasm-std = "1.1.5"
cw-storage-plus = { git = "https://github.com/palomachain/cw-storage-plus", branch = "cov"}
schemars = "0.8.11"
serde = { version = "1.0.147", default-features = false, features = ["derive"] }
thiserror = { version = "1.0.37" }
Expand Down
2 changes: 2 additions & 0 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,7 @@ fn add_liquidity_test_6() -> Result<(), ContractError> {
Ok(())
}

#[test]
fn remove_liquidity_test() -> Result<(), ContractError> {
let mut deps = mock_dependencies();
let info = mock_info("admin0", &[]);
Expand Down Expand Up @@ -1114,6 +1115,7 @@ fn remove_liquidity_test() -> Result<(), ContractError> {
Ok(())
}

#[test]
fn swap_test() -> Result<(), ContractError> {
let mut deps = mock_dependencies();
let info = mock_info("admin0", &[]);
Expand Down

0 comments on commit b962252

Please sign in to comment.