Skip to content

Add upload_coverage_files for uploading coverage reports from disk - #135

Open
shibanalex wants to merge 4 commits into
prooflinedev:mainfrom
shibanalex:feat/upload-coverage-files
Open

shibanalex wants to merge 4 commits into
prooflinedev:mainfrom
shibanalex:feat/upload-coverage-files

Conversation

@shibanalex

Copy link
Copy Markdown

Summary

Adds upload_coverage_files on ProoflineClient and AsyncProoflineClient, along with CoverageFile and read_coverage_files in proofline/coverage.py (re-exported from proofline), bringing Python parity with uploadCoverageFiles / readCoverageFiles in prooflinedev/sdk-typescript (#43).

Who this helps

CI jobs uploading LCOV, Cobertura XML, JaCoCo XML, or Go cover profiles from disk no longer need to normalize relative POSIX report names, validate commit SHAs, preserve UTF-8 BOMs, or preflight the 30 MiB request-body limit manually before calling upload_coverage_reports.

Design & prior-art attribution

Follows the src/coverage.ts design merged in prooflinedev/sdk-typescript#43 (@IsraelAfangideh), incorporates maintainer review feedback on prooflinedev/sdk-python#37 (@Aadhi-07), and closes edge cases surfaced across sdk-python#71 (@aymandakir), sdk-typescript#76 (@mariyam552), and sdk-typescript#79 (@Rohit-998):

  • Explicit commit identity: tested_sha is required explicitly (full 40-character hex SHA) and never defaults to GITHUB_SHA.
  • Strict root containment: both the logical path and resolved realpath must sit strictly inside realpath(root), including when CoverageFile(..., name=...) supplies an explicit report name or when symlinks exist under root.
  • Strict report names: rejects empty names, . / .. segments, empty segments (a//b), leading/trailing slashes, backslashes, Windows drive prefixes, and NUL bytes instead of silently rewriting them.
  • Bounded descriptor reads & exact 30 MiB wire check: opens files with O_NONBLOCK | O_NOFOLLOW, requires S_ISREG (refusing FIFOs/devices without blocking while letting missing files and directories raise native OSErrors), preserves leading UTF-8 BOMs, bounds raw bytes before allocation, and checks the exact compact UTF-8 JSON payload size (separators=(",", ":"), ensure_ascii=False) sent by httpx2.
  • Async input isolation: AsyncProoflineClient.upload_coverage_files validates and snapshots files into an immutable tuple before running disk reads via anyio.to_thread.run_sync.
  • Contract check registration: registers upload_coverage_files in scripts/contracts.py.

How it was tested

  • Added tests/test_coverage.py covering sync/async HTTP uploads, BOM preservation, mixed-case 40-char SHAs, GITHUB_SHA non-fallback, path and symlink escapes (with and without explicit name), invalid POSIX names, duplicate names, non-UTF-8 files, non-regular POSIX FIFOs, sparse files > 30 MiB, exact 30 MiB ± 1 byte wire-JSON boundaries, native OSError propagation, and concurrent list mutation during async uploads.
  • Extended scripts/install_smoke.py to exercise sync and async upload_coverage_files from both built artifacts.
  • Ran python3 scripts/check.py on v10.2.3 (scripts/generate.py --check, scripts/contracts.py, ruff check, ruff format --check, mypy proofline scripts, 233 pytest tests, and wheel + sdist install smoke tests).

@shibanalex

Copy link
Copy Markdown
Author

its me

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