From 3b6e51f2255bffcad0459b75c11d71ac19e7e8bd Mon Sep 17 00:00:00 2001 From: bit-aloo Date: Fri, 11 Oct 2024 21:02:47 +0530 Subject: [PATCH] add roles yaml, coverage-roles and modify roles tarpaulin.toml --- .github/workflows/coverage-roles.yaml | 89 +++++++++++++++++++++++++++ roles/tarpaulin.toml | 2 +- scripts/coverage-roles.sh | 28 +++++++++ 3 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/coverage-roles.yaml create mode 100755 scripts/coverage-roles.sh diff --git a/.github/workflows/coverage-roles.yaml b/.github/workflows/coverage-roles.yaml new file mode 100644 index 0000000000..434417ce8b --- /dev/null +++ b/.github/workflows/coverage-roles.yaml @@ -0,0 +1,89 @@ +name: Roles test Coverage + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + roles-coverage: + + name: tarpaulin Test + runs-on: ubuntu-latest + container: + image: xd009642/tarpaulin:0.27.1-nightly + options: --security-opt seccomp=unconfined + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Generate code coverage + run: | + ./scripts/coverage-roles.sh + + - name: Upload roles coverage to codecov.io + uses: codecov/codecov-action@v4 + with: + directory: ./roles/target/tarpaulin-reports + file: ./roles/target/tarpaulin-reports/cobertura.xml + flags: roles + token: ${{ secrets.CODECOV_TOKEN }} + + - name: Upload jd_client-coverage to codecov.io + uses: codecov/codecov-action@v4 + with: + directory: ./roles/target/tarpaulin-reports/jd-client-coverage + file: ./roles/target/tarpaulin-reports/jd-client-coverage/cobertura.xml + flags: jd_client-coverage + token: ${{ secrets.CODECOV_TOKEN }} + + - name: Upload jd_server-coverage to codecov.io + uses: codecov/codecov-action@v4 + with: + directory: ./roles/target/tarpaulin-reports/jd-server-coverage + file: ./roles/target/tarpaulin-reports/jd-server-coverage/cobertura.xml + flags: jd_server-coverage + token: ${{ secrets.CODECOV_TOKEN }} + + - name: Upload mining_device-coverage to codecov.io + uses: codecov/codecov-action@v4 + with: + directory: ./roles/target/tarpaulin-reports/mining-device-coverage + file: ./rroles/target/tarpaulin-reports/mining-device-coverage/cobertura.xml + flags: mining_device-coverage + token: ${{ secrets.CODECOV_TOKEN }} + + - name: Upload mining_proxy_sv2-coverage to codecov.io + uses: codecov/codecov-action@v4 + with: + directory: ./roles/target/tarpaulin-reports/mining-proxy-coverage + file: ./roles/target/tarpaulin-reports/mining-proxy-coverage/cobertura.xml + flags: mining_proxy_sv2-coverage + token: ${{ secrets.CODECOV_TOKEN }} + + - name: Upload pool_sv2-coverage to codecov.io + uses: codecov/codecov-action@v4 + with: + directory: ./roles/target/tarpaulin-reports/pool-coverage + file: ./roles/target/tarpaulin-reports/pool-coverage/cobertura.xml + flags: pool_sv2-coverage + token: ${{ secrets.CODECOV_TOKEN }} + + - name: Upload sv1-mining-device-coverage to codecov.io + uses: codecov/codecov-action@v4 + with: + directory: ./roles/target/tarpaulin-reports/sv1-mining-device-coverage + file: ./roles/target/tarpaulin-reports/sv1-mining-device-coverage/cobertura.xml + flags: sv1-mining-device-coverage + token: ${{ secrets.CODECOV_TOKEN }} + + - name: Upload translator_sv2-coverage to codecov.io + uses: codecov/codecov-action@v4 + with: + directory: ./roles/target/tarpaulin-reports/translator-coverage + file: ./roles/target/tarpaulin-reports/translator-coverage/cobertura.xml + flags: translator_sv2-coverage + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/roles/tarpaulin.toml b/roles/tarpaulin.toml index 2714d685da..47e6ecba57 100644 --- a/roles/tarpaulin.toml +++ b/roles/tarpaulin.toml @@ -2,7 +2,7 @@ features = "with_buffer_pool async_std tokio with_tokio default" run-types = [ "Lib" ] timeout = "120s" -fail-under = 20 +fail-under = 0 [report] out = ["Xml"] diff --git a/scripts/coverage-roles.sh b/scripts/coverage-roles.sh new file mode 100755 index 0000000000..50fecb521f --- /dev/null +++ b/scripts/coverage-roles.sh @@ -0,0 +1,28 @@ +#!/bin/bash +tarpaulin() { + crate_name=$1 + output_dir="target/tarpaulin-reports/$crate_name" + mkdir -p "$output_dir" + cargo +nightly tarpaulin --verbose --out Xml --output-dir "$output_dir" --all-features +} + +cd roles +tarpaulin + +crates=( + "mining-proxy" + "pool" + "test-utils/mining-device" + "test-utils/sv1-mining-device" + "translator" + "jd-client" + "jd-server" +) + +for crate in "${crates[@]}"; do + echo "Running Tarpaulin for $crate..." + crate_name=$(basename "$crate") + cd "$crate" || exit 1 + tarpaulin "$crate_name-coverage" + cd - || exit 1 +done