# SPDX-FileCopyrightText: 2023 - 2024 Ali Sajid Imami
#
# SPDX-License-Identifier: Apache-2.0
# SPDX-License-Identifier: MIT

---
name: Code Coverage
on:
    workflow_call:
jobs:
    test:
        name: Generate Coverage
        runs-on: ubuntu-latest
        container:
            image: xd009642/tarpaulin:develop-nightly@sha256:83d62d5325c780251e7207d5184315d920b62b8fa4bb2f6095d8e9592ee7a83c
            options: --security-opt seccomp=unconfined
        steps:
            - name: Checkout repository
              uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
            # Nightly Rust is required for cargo llvm-cov --doc.
            - uses: dtolnay/rust-toolchain@nightly
              with:
                components: llvm-tools-preview
            - uses: taiki-e/install-action@37461a1de4134bec919a737ee9ba018e72011b7c # v2.42.4
              with:
                tool: cargo-llvm-cov,nextest
            - name: Collect coverage data (including doctests)
              run: |
                cargo llvm-cov --no-report nextest --config-file nextest.toml
                cargo llvm-cov --no-report --doc
                cargo llvm-cov report --doctests --lcov --output-path lcov.info
            - name: Upload to codecov.io
              uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0
              with:
                file: lcov.info
                token: ${{ secrets.CODECOV_TOKEN }}
                verbose: true
                working-directory: .
