Merge pull request #214 from acgetchell/chore/automate-python-dev-pin… #442
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Codecov | |
| concurrency: | |
| # Ensure only one Codecov analysis runs per branch/ref | |
| group: codecov-${{ github.ref_name }} | |
| cancel-in-progress: true | |
| on: | |
| push: | |
| branches: ["main"] | |
| pull_request: | |
| branches: ["main"] | |
| # Least-privilege permissions | |
| permissions: | |
| contents: read | |
| jobs: | |
| coverage: | |
| name: Code Coverage | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| fetch-depth: 0 # Needed for Codecov diff analysis | |
| persist-credentials: false | |
| - name: Install Rust toolchain | |
| uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0 | |
| with: | |
| cache: true # toolchain/components are specified in rust-toolchain.toml | |
| cache-bin: false | |
| - name: Set up just | |
| uses: ./.github/actions/setup-just | |
| - name: Export coverage tool versions | |
| id: tool_versions | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| resolve_version() { | |
| local name="$1" | |
| local value | |
| if ! value="$(just --evaluate "$name")"; then | |
| echo "::error::Failed to resolve $name from justfile" >&2 | |
| return 1 | |
| fi | |
| if [[ -z "$value" ]]; then | |
| echo "::error::Resolved empty $name from justfile" >&2 | |
| return 1 | |
| fi | |
| printf '%s\n' "$value" | |
| } | |
| cargo_llvm_cov_version="$(resolve_version cargo_llvm_cov_version)" | |
| cargo_nextest_version="$(resolve_version cargo_nextest_version)" | |
| { | |
| echo "CARGO_LLVM_COV_VERSION=$cargo_llvm_cov_version" | |
| echo "CARGO_NEXTEST_VERSION=$cargo_nextest_version" | |
| } >> "$GITHUB_OUTPUT" | |
| - name: Install LLVM coverage tools | |
| run: rustup component add llvm-tools-preview | |
| - name: Install cargo-llvm-cov | |
| uses: taiki-e/cache-cargo-install-action@9ee83daaa7b96a6fab930949ecf1122bba04a389 # v3.0.8 | |
| with: | |
| tool: cargo-llvm-cov@${{ steps.tool_versions.outputs.CARGO_LLVM_COV_VERSION }} | |
| - name: Install cargo-nextest | |
| uses: taiki-e/cache-cargo-install-action@9ee83daaa7b96a6fab930949ecf1122bba04a389 # v3.0.8 | |
| with: | |
| tool: cargo-nextest@${{ steps.tool_versions.outputs.CARGO_NEXTEST_VERSION }} | |
| - name: Run coverage | |
| run: | | |
| mkdir -p coverage | |
| chmod 755 coverage | |
| echo "::group::Running coverage" | |
| # Single source of truth: coverage configuration lives in justfile | |
| just coverage-ci | |
| echo "::endgroup::" | |
| echo "::group::Coverage verification" | |
| ls -la coverage/ || true | |
| if [ ! -f coverage/cobertura.xml ]; then | |
| echo "::error::coverage/cobertura.xml not found. cargo-llvm-cov failed to generate XML output." | |
| exit 2 | |
| fi | |
| echo "::notice::Coverage report generated successfully: $(wc -l < coverage/cobertura.xml) lines" | |
| if [ ! -f target/nextest/coverage/test-results/junit.xml ]; then | |
| echo "::error::nextest JUnit report was not generated." | |
| exit 2 | |
| fi | |
| echo "::notice::Test results generated successfully." | |
| echo "::endgroup::" | |
| env: | |
| RUST_BACKTRACE: 1 | |
| - name: Upload coverage to Codecov | |
| if: ${{ success() && hashFiles('coverage/cobertura.xml') != '' }} | |
| uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0 | |
| with: | |
| files: coverage/cobertura.xml | |
| flags: unittests | |
| name: codecov-umbrella | |
| fail_ci_if_error: false | |
| env: | |
| CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
| - name: Upload test results to Codecov | |
| if: ${{ success() && hashFiles('target/nextest/coverage/test-results/junit.xml') != '' }} | |
| uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0 | |
| with: | |
| files: target/nextest/coverage/test-results/junit.xml | |
| flags: unittests | |
| name: nextest-results | |
| report_type: test_results | |
| fail_ci_if_error: false | |
| env: | |
| CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
| - name: Archive coverage results | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | |
| if: always() | |
| with: | |
| name: coverage-report | |
| path: coverage/ | |
| - name: Archive test results | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | |
| if: always() | |
| with: | |
| name: test-results | |
| path: target/nextest/coverage/test-results/ |