From c06be93bf53f45bb29b7b23471ca17e75fdffeaa Mon Sep 17 00:00:00 2001 From: ngutech21 Date: Fri, 22 Mar 2024 09:59:21 +0100 Subject: [PATCH 1/8] fix: use glob for ignoring data-dir --- justfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/justfile b/justfile index 89ba610e..2aa8cb59 100644 --- a/justfile +++ b/justfile @@ -45,7 +45,7 @@ run-coverage: 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/ + grcov . --binary-path ./target/debug/deps/ -s . -t lcov,html --branch --ignore-not-existing --ignore '../*' --ignore "/*" --ignore "./data/*" -o target/coverage/ find . -name '*.profraw' -exec rm -r {} \; >&2 echo '💡 Created the report in html-format target/coverage/html/index.html' From 85a2f23e6c3acdb34f525725b111cb6a8bff6b98 Mon Sep 17 00:00:00 2001 From: ngutech21 Date: Fri, 22 Mar 2024 10:52:54 +0100 Subject: [PATCH 2/8] fix: run coverage as root --- .github/workflows/rust.yml | 2 +- justfile | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 5e80bc89..2d1e8d03 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -58,7 +58,7 @@ jobs: - name: chmod data-dir run: sudo chmod -R a+rwx ./data - name: run coverage - run: just run-coverage + run: sudo just run-coverage - name: Upload to codecov.io uses: codecov/codecov-action@v4 with: diff --git a/justfile b/justfile index 2aa8cb59..0be21bb4 100644 --- a/justfile +++ b/justfile @@ -38,6 +38,7 @@ final-check: just run-itests just build-wasm +#--ignore '../*' --ignore '/*' # run coverage and create a report in html and lcov format run-coverage: #!/usr/bin/env bash @@ -45,7 +46,7 @@ run-coverage: 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/ + 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' From 2bfde81714abb2dddd76f56365c45ff9ad4c9d0c Mon Sep 17 00:00:00 2001 From: ngutech21 Date: Fri, 22 Mar 2024 11:03:10 +0100 Subject: [PATCH 3/8] fix: remove sudo --- .github/workflows/rust.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 2d1e8d03..5e80bc89 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -58,7 +58,7 @@ jobs: - name: chmod data-dir run: sudo chmod -R a+rwx ./data - name: run coverage - run: sudo just run-coverage + run: just run-coverage - name: Upload to codecov.io uses: codecov/codecov-action@v4 with: From 8deb21bff9b811678beae0857bcdcc5bb42997ca Mon Sep 17 00:00:00 2001 From: ngutech21 Date: Fri, 22 Mar 2024 12:26:56 +0100 Subject: [PATCH 4/8] chore: split coverage recipes --- .github/workflows/rust.yml | 8 ++++++-- justfile | 19 ++++++++++++++++++- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 5e80bc89..70de8b35 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -57,8 +57,12 @@ jobs: run: cargo generate-lockfile - 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-converage-tests + - name: delete data-dir + run: sudo rm -rf ./data + - name: run coverage-report + run: just run-converage-report - name: Upload to codecov.io uses: codecov/codecov-action@v4 with: diff --git a/justfile b/justfile index 0be21bb4..fc7329d5 100644 --- a/justfile +++ b/justfile @@ -38,7 +38,7 @@ final-check: just run-itests just build-wasm -#--ignore '../*' --ignore '/*' + # run coverage and create a report in html and lcov format run-coverage: #!/usr/bin/env bash @@ -50,6 +50,23 @@ run-coverage: find . -name '*.profraw' -exec rm -r {} \; >&2 echo '💡 Created the report in html-format target/coverage/html/index.html' + +# run coverage and create a report in html and lcov format +run-coverage-tests: + docker compose --profile itest up -d + 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 + + +# run coverage and create a 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}} From 4e4fb868b052b5b8639f2fbe046ac14f728c709e Mon Sep 17 00:00:00 2001 From: ngutech21 Date: Fri, 22 Mar 2024 12:39:51 +0100 Subject: [PATCH 5/8] fix: typos --- .github/workflows/rust.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 70de8b35..04ab4dd2 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -58,11 +58,11 @@ jobs: - name: chmod data-dir run: sudo chmod -R a+rwx ./data - name: run coverage test - run: just run-converage-tests + run: just run-coverage-tests - name: delete data-dir run: sudo rm -rf ./data - name: run coverage-report - run: just run-converage-report + run: just run-coverage-report - name: Upload to codecov.io uses: codecov/codecov-action@v4 with: From b11814de3ac6542bef0b35b55e1828cb64725eeb Mon Sep 17 00:00:00 2001 From: ngutech21 Date: Fri, 22 Mar 2024 12:54:48 +0100 Subject: [PATCH 6/8] fix: install llvm-tools-preview --- .github/workflows/rust.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 04ab4dd2..c97b25bd 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -49,7 +49,9 @@ jobs: - name: Install stable uses: dtolnay/rust-toolchain@stable with: - components: llvm-tools-preview + toolchain: stable + - name: Install llvm-tools-preview + run: rustup component add llvm-tools-preview - name: cargo install cargo-llvm-cov uses: taiki-e/install-action@cargo-llvm-cov - name: cargo generate-lockfile From 02603f9b08cdf6c2b095f9f9881dcf409bd9f132 Mon Sep 17 00:00:00 2001 From: ngutech21 Date: Fri, 22 Mar 2024 13:08:38 +0100 Subject: [PATCH 7/8] chore: cleanup --- .github/workflows/rust.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index c97b25bd..c5406ce2 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -52,11 +52,6 @@ jobs: toolchain: stable - name: Install llvm-tools-preview run: rustup component add 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 - name: chmod data-dir run: sudo chmod -R a+rwx ./data - name: run coverage test From e3494da8356563a087d69ef0a0cde75b0d5b8aa6 Mon Sep 17 00:00:00 2001 From: ngutech21 Date: Fri, 22 Mar 2024 13:15:37 +0100 Subject: [PATCH 8/8] chore: remove duplicated code --- justfile | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/justfile b/justfile index fc7329d5..86358e2a 100644 --- a/justfile +++ b/justfile @@ -41,24 +41,16 @@ final-check: # run coverage and create a report in html and lcov format run-coverage: - #!/usr/bin/env bash - 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/ -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' - + just run-coverage-tests + just run-coverage-report -# run coverage and create a report in html and lcov format +# runs all tests with coverage instrumentation run-coverage-tests: docker compose --profile itest up -d 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 - -# run coverage and create a report in html and lcov format +# creates a coverage report in html and lcov format run-coverage-report: #!/usr/bin/env bash mkdir -p target/coverage