chore(libcalibre): delete dead api.rs (#126) #153
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: libcalibre Tests & Coverage | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| jobs: | |
| setup: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Install Rust | |
| run: rustup update stable | |
| - name: Install cargo-llvm-cov | |
| uses: taiki-e/install-action@cargo-llvm-cov | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| prefix-key: "v0-rust" | |
| shared-key: "build" | |
| workspaces: "." | |
| - name: Build | |
| working-directory: crates/libcalibre | |
| run: cargo build --all-features | |
| report-coverage: | |
| needs: setup | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Install Rust | |
| run: rustup update stable | |
| - name: Install cargo-llvm-cov | |
| uses: taiki-e/install-action@cargo-llvm-cov | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| prefix-key: "v0-rust" | |
| shared-key: "build" | |
| workspaces: "." | |
| - name: Generate HTML coverage report | |
| run: | | |
| cargo llvm-cov --package libcalibre --all-features --html | |
| - name: Upload HTML coverage report | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-report-html | |
| path: target/llvm-cov/html/ | |
| retention-days: 14 | |
| - name: Generate JSON coverage report (required for comment) | |
| run: | | |
| mkdir -p target/llvm-cov | |
| cargo llvm-cov --package libcalibre --all-features --json --output-path target/llvm-cov/coverage-summary.json | |
| - name: Extract coverage percentage | |
| id: coverage | |
| run: | | |
| COVERAGE=$(jq -r '.data[0].totals.lines.percent' target/llvm-cov/coverage-summary.json | xargs printf "%.2f") | |
| echo "percentage=$COVERAGE" >> $GITHUB_OUTPUT | |
| echo "Coverage: $COVERAGE%" | |
| - name: Comment coverage on PR | |
| if: github.event_name == 'pull_request' | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const coverage = '${{ steps.coverage.outputs.percentage }}'; | |
| const comment = `## libcalibre Test Coverage Report | |
| **Overall coverage:** ${coverage}% | |
| 📊 [Download HTML Report](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) | |
| Coverage breakdown available in the artifacts.`; | |
| github.rest.issues.createComment({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: comment | |
| }); | |
| test: | |
| needs: setup | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Install Rust | |
| run: rustup update stable | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| prefix-key: "v0-rust" | |
| shared-key: "build" | |
| workspaces: "." | |
| - name: Run tests | |
| run: cargo test --package libcalibre --all-features |