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/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/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