Skip to content

Add upload_coverage_files to sync and async clients - #167

Open
daposta wants to merge 1 commit into
prooflinedev:mainfrom
daposta:feat/iter-pull-request-reviews
Open

daposta wants to merge 1 commit into
prooflinedev:mainfrom
daposta:feat/iter-pull-request-reviews

Conversation

@daposta

@daposta daposta commented Dec 4, 2026

Copy link
Copy Markdown

Summary

Adds upload_coverage_files() to ProoflineClient and AsyncProoflineClient. It removes the boilerplate of uploading coverage from CI, so you no longer have to find each report, read it, wrap it in UploadedReport, build a CoverageUploadRequest, and call upload_coverage_reports(). You pass file paths and it does the rest.

with ProoflineClient() as client:
    client.upload_coverage_files(
        organization_id,
        repository_id,
        tested_sha=os.environ["TESTED_SHA"],
        files=["coverage/lcov.info", "coverage/coverage.xml"],
    )

Behavior

  • Relative paths resolve against root (default: the current directory). Every report must stay inside root, including through symlinks, and is named by its path relative to it.
  • Reports are read as raw UTF-8 bytes, so the content (CRLF included) is sent exactly as the coverage tool wrote it, as the UploadedReport.content contract requires.
  • Bad input is refused before anything is sent:
    • a tested SHA that is not a full 40-character hex SHA
    • fewer than 1 or more than 50 files
    • a single path string instead of a list
    • a file outside root, a directory, or a missing file
    • two reports with the same name
  • The async client reads the files in a worker thread (anyio.to_thread), so the event loop is not blocked.

Changes

  • proofline/client.py: the _coverage_upload_request helper, plus the upload_coverage_files method on both clients.
  • scripts/contracts.py: upload_coverage_files is a helper, not an OpenAPI operation, so the contract check accepts it.
  • tests/test_http.py: end-to-end sync and async tests against the loopback server, covering report names, unchanged CRLF content, and no request being sent for a bad SHA. Also edge-case tests: files or symlinks outside the root, 0 or 51 files, a single path, bad SHAs, directories, missing files, a root that is not a directory, and invalid UTF-8.
  • README.md: the Coverage uploads section documents the new method.

Testing

  • ruff check, ruff format --check, mypy proofline scripts and scripts/contracts.py all pass.
  • pytest: 250 passed.
  • Manual run against a local stand-in server: LCOV and Cobertura reports uploaded through both clients, and every bad input was refused with 0 requests sent.
  • Not yet tested against the live Proofline API.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant