From 252849f24a5ca7c3093396bb2c21d1d494d0aa3e Mon Sep 17 00:00:00 2001 From: Jose Celano Date: Tue, 26 Sep 2023 07:50:12 +0100 Subject: [PATCH] ci: add coverage workflow --- .github/workflows/coverage.yaml | 69 +++++++++++++++++++++++++++++++++ README.md | 2 +- 2 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/coverage.yaml diff --git a/.github/workflows/coverage.yaml b/.github/workflows/coverage.yaml new file mode 100644 index 0000000..b4807c6 --- /dev/null +++ b/.github/workflows/coverage.yaml @@ -0,0 +1,69 @@ +name: Coverage + +on: + push: + branches: + - main + pull_request_target: + branches: + - main + +env: + CARGO_TERM_COLOR: always + +jobs: + report: + name: Report + environment: coverage + runs-on: ubuntu-latest + env: + CARGO_INCREMENTAL: "0" + RUSTFLAGS: "-Z profile -C codegen-units=1 -C inline-threshold=0 -C link-dead-code -C overflow-checks=off -C panic=abort -Z panic_abort_tests" + RUSTDOCFLAGS: "-Z profile -C codegen-units=1 -C inline-threshold=0 -C link-dead-code -C overflow-checks=off -C panic=abort -Z panic_abort_tests" + + steps: + - id: checkout_push + if: github.event_name == 'push' + name: Checkout Repository (Push) + uses: actions/checkout@v4 + + - id: checkout_pull_request_target + if: github.event_name == 'pull_request_target' + name: Checkout Repository (Pull Request Target) + uses: actions/checkout@v4 + with: + ref: "refs/pull/${{ github.event.pull_request.number }}/head" + + - id: setup + name: Setup Toolchain + uses: dtolnay/rust-toolchain@stable + with: + toolchain: nightly + components: llvm-tools-preview + + - id: cache + name: Enable Workflow Cache + uses: Swatinem/rust-cache@v2 + + - id: tools + name: Install tools + uses: taiki-e/install-action@v2 + with: + tool: grcov,cargo-llvm-cov,nextest + + - id: print + name: Print Coverage Report + run: cargo llvm-cov nextest + + - id: report + name: Generate Coverage Report + uses: alekitto/grcov@v0.2 + + - id: upload + name: Upload Coverage Report + uses: codecov/codecov-action@v3 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: ${{ steps.coverage.outputs.report }} + verbose: true + fail_ci_if_error: true diff --git a/README.md b/README.md index 6625e77..a66dc5a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Torrust Serde Bencode -[![Checking](https://github.com/torrust/torrust-serde-bencode/actions/workflows/checking.yml/badge.svg)](https://github.com/torrust/torrust-serde-bencode/actions/workflows/checking.yml) [![Formatting](https://github.com/torrust/torrust-serde-bencode/actions/workflows/formatting.yml/badge.svg)](https://github.com/torrust/torrust-serde-bencode/actions/workflows/formatting.yml) [![Testing](https://github.com/torrust/torrust-serde-bencode/actions/workflows/testing.yaml/badge.svg)](https://github.com/torrust/torrust-serde-bencode/actions/workflows/testing.yaml) [![Benchmarking](https://github.com/torrust/torrust-serde-bencode/actions/workflows/benchmarking.yml/badge.svg)](https://github.com/torrust/torrust-serde-bencode/actions/workflows/benchmarking.yml) +[![Checking](https://github.com/torrust/torrust-serde-bencode/actions/workflows/checking.yml/badge.svg)](https://github.com/torrust/torrust-serde-bencode/actions/workflows/checking.yml) [![Formatting](https://github.com/torrust/torrust-serde-bencode/actions/workflows/formatting.yml/badge.svg)](https://github.com/torrust/torrust-serde-bencode/actions/workflows/formatting.yml) [![Testing](https://github.com/torrust/torrust-serde-bencode/actions/workflows/testing.yaml/badge.svg)](https://github.com/torrust/torrust-serde-bencode/actions/workflows/testing.yaml) [![Benchmarking](https://github.com/torrust/torrust-serde-bencode/actions/workflows/benchmarking.yml/badge.svg)](https://github.com/torrust/torrust-serde-bencode/actions/workflows/benchmarking.yml) [![Coverage](https://github.com/torrust/torrust-serde-bencode/actions/workflows/coverage.yml/badge.svg)](https://github.com/torrust/torrust-serde-bencode/actions/workflows/coverage.yml) A [Serde](https://github.com/serde-rs/serde) backed [Bencode](https://en.wikipedia.org/wiki/Bencode) encoding/decoding library for Rust.