yihua opened a new pull request, #19173:
URL: https://github.com/apache/hudi/pull/19173

   ### Describe the issue this Pull Request addresses
   
   There is no CI gate on the test coverage of the code a PR changes. Overall 
project coverage is tracked in Codecov, but a PR can add or modify code with 
little or no test coverage and still pass CI. This adds an enforceable minimum 
on changed-line (patch) coverage, evaluated and reported on the PR itself 
before merge.
   
   ### Summary and Changelog
   
   Adds a new `Patch Coverage` GitHub Actions workflow 
(`.github/workflows/patch_coverage.yml`):
   
   - Runs directly on the pull request (`pull_request`: opened / synchronize / 
reopened), so it evaluates the PR's own changed-line coverage and reports on 
the PR before merge.
   - Skips immediately (passes) when the PR changes no main-source 
`.java`/`.scala` lines, so docs/config/test-only PRs are not blocked and do not 
wait on CI.
   - Otherwise waits for the Java CI matrix to finish uploading and for Codecov 
to finish aggregating this PR's coverage (polls the Codecov commit endpoint 
until `state=complete` and the session count stops growing), then reads the 
changed-line (diff) coverage. This avoids scoring a partially merged report 
from the multi-job matrix and failing PRs spuriously. If Codecov does not 
settle within the time budget it fails open.
   - Fails the check when changed-line coverage is below **80%**; passes at or 
above it. Threshold is a single `MIN_PATCH_COVERAGE` env var.
   - Gates only the lines the PR adds or modifies (patch coverage), never 
overall project coverage, so a PR is not penalized for the repository's 
existing coverage.
   - Reports the result to the run summary and, best-effort, as a PR comment.
   
   Notes:
   - The gate is the job's own pass/fail, which shows as a check on the PR and 
works for fork PRs too. Posting the PR *comment* requires a write-scoped token, 
which GitHub does not grant to `pull_request` runs from forks; in that case the 
result is still shown via the check and the run summary (the comment is 
skipped).
   - A lighter-weight native alternative is Codecov's own 
`coverage.status.patch` target in `.codecov.yml`; this workflow is used instead 
so the gate is a first-class GitHub Actions check. `.codecov.yml` is 
intentionally left untouched here to avoid conflicting with the in-flight 
Codecov config modernization.
   - To make this a merge blocker, add the `Patch Coverage` check to branch 
protection required checks (separate repo-admin step).
   
   ### Impact
   
   CI-only. Adds one job per pull request that changes main source. No change 
to build or test behavior. Becomes a merge blocker only if the check is marked 
required in branch protection.
   
   ### Risk Level
   
   low. New workflow only; no existing workflow or build step is modified. It 
fails open if Codecov is unavailable, and does not alter test execution.
   
   ### Documentation Update
   
   none
   
   ### Validation
   
   Validated end-to-end against two throwaway PRs (both closed), each carrying 
this workflow plus a small hudi-utilities probe:
   
   - #19174 (probe with a test covering every branch): Java CI completed, 
Codecov settled at 40 sessions, gate read **100.0%** patch coverage and 
**passed**.
   - #19175 (identical probe with no test): same wait, gate read **0.0%** patch 
coverage and **failed** (the only failing check).
   
   An earlier iteration scored while CI was still running (Codecov reported 
`state=complete` after a single upload), reading a partial 0% and failing 
#19174 spuriously; the workflow now waits for the Java CI run to complete and 
for the Codecov session count to stabilize before scoring.
   
   ### Contributor's checklist
   
   - [ ] Read through [contributor's 
guide](https://hudi.apache.org/contribute/how-to-contribute)
   - [x] Enough context is provided in the sections above
   - [x] Adequate tests were added if applicable
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to