diff --git a/.github/workflows/coverage-protocols.yaml b/.github/workflows/coverage-protocols.yaml new file mode 100644 index 0000000000..9e49d26721 --- /dev/null +++ b/.github/workflows/coverage-protocols.yaml @@ -0,0 +1,146 @@ +name: Protocol test Coverage + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + protocols-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-protocols.sh + + - name: Upload protocols coverage to codecov.io + uses: codecov/codecov-action@v4 + with: + directory: ./protocols/target/tarpaulin-reports + file: ./protocols/target/tarpaulin-reports/cobertura.xml + flags: protocols + token: ${{ secrets.CODECOV_TOKEN }} + + - name: Upload binary_codec_sv2-coverage to codecov.io + uses: codecov/codecov-action@v4 + with: + directory: ./protocols/target/tarpaulin-reports/codec-coverage + file: ./protocols/target/tarpaulin-reports/codec-coverage/cobertura.xml + flags: binary_codec_sv2-coverage + token: ${{ secrets.CODECOV_TOKEN }} + + - name: Upload binary_sv2-coverage to codecov.io + uses: codecov/codecov-action@v4 + with: + directory: ./protocols/target/tarpaulin-reports/binary-sv2-coverage + file: ./protocols/target/tarpaulin-reports/binary-sv2-coverage/cobertura.xml + flags: binary_sv2-coverage + token: ${{ secrets.CODECOV_TOKEN }} + + - name: Upload binary_serde_sv2-coverage to codecov.io + uses: codecov/codecov-action@v4 + with: + directory: ./protocols/target/tarpaulin-reports/serde-sv2-coverage + file: ./protocols/target/tarpaulin-reports/serde-sv2-coverage/cobertura.xml + flags: binary_serde_sv2-coverage + token: ${{ secrets.CODECOV_TOKEN }} + + - name: Upload codec_sv2-coverage to codecov.io + uses: codecov/codecov-action@v4 + with: + directory: ./protocols/target/tarpaulin-reports/codec-sv2-coverage + file: ./protocols/target/tarpaulin-reports/codec-sv2-coverage/cobertura.xml + flags: codec_sv2-coverage + token: ${{ secrets.CODECOV_TOKEN }} + + - name: Upload common_messages_sv2-coverage to codecov.io + uses: codecov/codecov-action@v4 + with: + directory: ./protocols/target/tarpaulin-reports/common-messages-coverage + file: ./protocols/target/tarpaulin-reports/common-messages-coverage/cobertura.xml + flags: common_messages_sv2-coverage + token: ${{ secrets.CODECOV_TOKEN }} + + - name: Upload const_sv2-coverage to codecov.io + uses: codecov/codecov-action@v4 + with: + directory: ./protocols/target/tarpaulin-reports/const-sv2-coverage + file: ./protocols/target/tarpaulin-reports/const-sv2-coverage/cobertura.xml + flags: const_sv2-coverage + token: ${{ secrets.CODECOV_TOKEN }} + + - name: Upload framing_sv2-coverage to codecov.io + uses: codecov/codecov-action@v4 + with: + directory: ./protocols/target/tarpaulin-reports/framing-sv2-coverage + file: ./protocols/target/tarpaulin-reports/framing-sv2-coverage/cobertura.xml + flags: framing_sv2-coverage + token: ${{ secrets.CODECOV_TOKEN }} + + - name: Upload job_declaration_sv2-coverage to codecov.io + uses: codecov/codecov-action@v4 + with: + directory: ./protocols/target/tarpaulin-reports/job-declaration-coverage + file: ./protocols/target/tarpaulin-reports/job-declaration-coverage/cobertura.xml + flags: job_declaration_sv2-coverage + token: ${{ secrets.CODECOV_TOKEN }} + + + - name: Upload noise_sv2-coverage to codecov.io + uses: codecov/codecov-action@v4 + with: + directory: ./protocols/target/tarpaulin-reports/noise-sv2-coverage + file: ./protocols/target/tarpaulin-reports/noise-sv2-coverage/cobertura.xml + flags: noise_sv2-coverage + token: ${{ secrets.CODECOV_TOKEN }} + + - name: Upload roles_logic_sv2-coverage to codecov.io + uses: codecov/codecov-action@v4 + with: + directory: ./protocols/target/tarpaulin-reports/roles-logic-sv2-coverage + file: ./protocols/target/tarpaulin-reports/roles-logic-sv2-coverage/cobertura.xml + flags: roles_logic_sv2-coverage + token: ${{ secrets.CODECOV_TOKEN }} + + - name: Upload v1-coverage to codecov.io + uses: codecov/codecov-action@v4 + with: + directory: ./protocols/target/tarpaulin-reports/v1-coverage + file: ./protocols/target/tarpaulin-reports/v1-coverage/cobertura.xml + flags: v1-coverage + token: ${{ secrets.CODECOV_TOKEN }} + + - name: Upload sv2_ffi-coverage to codecov.io + uses: codecov/codecov-action@v4 + with: + directory: ./protocols/target/tarpaulin-reports/sv2-ffi-coverage + file: ./protocols/target/tarpaulin-reports/sv2-ffi-coverage/cobertura.xml + flags: sv2_ffi-coverage + token: ${{ secrets.CODECOV_TOKEN }} + + - name: Upload template_distribution_sv2-coverage to codecov.io + uses: codecov/codecov-action@v4 + with: + directory: ./protocols/target/tarpaulin-reports/template-distribution-coverage + file: ./protocols/target/tarpaulin-reports/template-distribution-coverage/cobertura.xml + flags: template_distribution_sv2-coverage + token: ${{ secrets.CODECOV_TOKEN }} + + - name: Upload mining-coverage to codecov.io + uses: codecov/codecov-action@v4 + with: + directory: ./protocols/target/tarpaulin-reports/mining-coverage + file: ./protocols/target/tarpaulin-reports/mining-coverage/cobertura.xml + flags: mining-coverage + token: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file 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/.github/workflows/coverage-utils.yaml b/.github/workflows/coverage-utils.yaml new file mode 100644 index 0000000000..5fd6ebc1fe --- /dev/null +++ b/.github/workflows/coverage-utils.yaml @@ -0,0 +1,66 @@ +name: Util Test Coverage + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + utils-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-utils.sh + + - name: Upload utils coverage to codecov.io + uses: codecov/codecov-action@v4 + with: + directory: ./utils/target/tarpaulin-reports + file: ./utils/target/tarpaulin-reports/cobertura.xml + flags: utils + token: ${{ secrets.CODECOV_TOKEN }} + + - name: Upload bip32_derivation-coverage to codecov.io + uses: codecov/codecov-action@v4 + with: + directory: ./utils/target/tarpaulin-reports/bip32-key-derivation-coverage + file: ./utils/target/tarpaulin-reports/bip32-key-derivation-coverage/cobertura.xml + flags: bip32_derivation-coverage + token: ${{ secrets.CODECOV_TOKEN }} + + - name: Upload buffer_sv2-coverage to codecov.io + uses: codecov/codecov-action@v4 + with: + directory: ./utils/target/tarpaulin-reports/buffer-coverage + file: ./utils/target/tarpaulin-reports/buffer-coverage/cobertura.xml + flags: buffer_sv2-coverage + + token: ${{ secrets.CODECOV_TOKEN }} + + - name: Upload error_handling-coverage to codecov.io + uses: codecov/codecov-action@v4 + with: + directory: ./utils/target/tarpaulin-reports/error-handling-coverage + file: ./utils/target/tarpaulin-reports/error-handling-coverage/cobertura.xml + flags: error_handling-coverage + token: ${{ secrets.CODECOV_TOKEN }} + + - name: Upload key-utils-coverage to codecov.io + uses: codecov/codecov-action@v4 + with: + directory: ./utils/target/tarpaulin-reports/key-utils-coverage + file: ./utils/target/tarpaulin-reports/key-utils-coverage/cobertura.xml + flags: key-utils-coverage + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/coverage.yaml b/.github/workflows/coverage.yaml deleted file mode 100644 index c8e18d346d..0000000000 --- a/.github/workflows/coverage.yaml +++ /dev/null @@ -1,50 +0,0 @@ -# Performs test coverage of project's libraries using cargo-tarpaulin and generates results using codecov.io. -# The following flags are set inside `tarpaulin.toml`: -# `features = "..."`: Includes the code with the listed features. The following features result in a -# tarpaulin error and are NOT included: derive, alloc, arbitrary-derive, attributes, and -# with_serde -# `run-types = [ "Lib" ]`: Only tests the package's library unit tests. Includes protocols, and utils (without the -# exclude-files flag, it includes this example because it contains a lib.rs file) -# `exclude-files = [ "examples/*" ]`: Excludes all projects in examples directory (specifically added to -# ignore examples that that contain a lib.rs file like interop-cpp) -# `timeout = "120s"`: If unresponsive for 120 seconds, action will fail -# `fail-under = 20`: If code coverage is less than 20%, action will fail -# `out = ["Xml"]`: Required for codecov.io to generate coverage result -# All message-generator test flags are in tests in test/message-generator/test -# This test loops through every test in test/message-generator/test, and runs each one, collecting -# code coverage data for anything in the roles/ directory that is relevant to SV2(pool, mining-proxy) - -name: Test Coverage - -on: - push: - branches: - - main - pull_request: - branches: - - main - -jobs: - tarpaulin-test: - - 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/tarpaulin.sh - - - name: Archive Tarpaulin code coverage results - uses: actions/upload-artifact@v4 - with: - name: tarpaulin-report - path: | - protocols/cobertura.xml - roles/cobertura.xml - utils/cobertura.xml diff --git a/protocols/tarpaulin.toml b/protocols/tarpaulin.toml index d611e2d34d..1a7b3b4609 100644 --- a/protocols/tarpaulin.toml +++ b/protocols/tarpaulin.toml @@ -2,7 +2,7 @@ features = "disable_nopanic prop_test noise_sv2 with_buffer_pool derive_codec_sv2 binary_codec_sv2 default core" run-types = [ "Lib" ] timeout = "120s" -fail-under = 20 +fail-under = 0 [report] out = ["Xml"] 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-protocols.sh b/scripts/coverage-protocols.sh new file mode 100755 index 0000000000..124db36b62 --- /dev/null +++ b/scripts/coverage-protocols.sh @@ -0,0 +1,36 @@ +#!/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" +} + +cd protocols +tarpaulin + +crates=( + "v1" + "v2/binary-sv2/serde-sv2" + "v2/binary-sv2/no-serde-sv2/codec" + "v2/binary-sv2/no-serde-sv2/derive_codec" + "v2/binary-sv2/binary-sv2" + "v2/noise-sv2" + "v2/framing-sv2" + "v2/codec-sv2" + "v2/const-sv2" + "v2/subprotocols/common-messages" + "v2/subprotocols/template-distribution" + "v2/subprotocols/mining" + "v2/subprotocols/job-declaration" + "v2/sv2-ffi" + "v2/roles-logic-sv2" +) + +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 \ No newline at end of file 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 diff --git a/scripts/coverage-utils.sh b/scripts/coverage-utils.sh new file mode 100755 index 0000000000..6f32742984 --- /dev/null +++ b/scripts/coverage-utils.sh @@ -0,0 +1,26 @@ +#!/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 utils +tarpaulin + +crates=( + "buffer" + "error-handling" + "key-utils" + "bip32-key-derivation" +) + +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 diff --git a/scripts/tarpaulin.sh b/scripts/tarpaulin.sh deleted file mode 100755 index 9e0f226f35..0000000000 --- a/scripts/tarpaulin.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -tarpaulin() -{ - cargo +nightly tarpaulin --verbose -} - -cd protocols -tarpaulin -cd ../roles -tarpaulin -cd ../utils -tarpaulin diff --git a/utils/tarpaulin.toml b/utils/tarpaulin.toml index c704c0f94d..8607047202 100644 --- a/utils/tarpaulin.toml +++ b/utils/tarpaulin.toml @@ -1,7 +1,7 @@ [default] run-types = [ "Lib" ] timeout = "120s" -fail-under = 7 +fail-under = 0 [report] out = ["Xml"]