Skip to content

feat(ci): add coverage check workflow and auto reviewer assignment#6635

Merged
kuny0707 merged 21 commits intotronprotocol:developfrom
bladehan1:feat/code_coverage
Apr 8, 2026
Merged

feat(ci): add coverage check workflow and auto reviewer assignment#6635
kuny0707 merged 21 commits intotronprotocol:developfrom
bladehan1:feat/code_coverage

Conversation

@bladehan1
Copy link
Copy Markdown
Collaborator

@bladehan1 bladehan1 commented Apr 2, 2026

What does this PR do?

  • Introduces a base vs PR coverage comparison gate in PR CI to prevent unnoticed regression of overall coverage.

  • Aggregates multi-module jacocoTestReport.xml using madrapps/jacoco-report (without using the Gradle aggregation plugin).

  • Adds/adjusts the coverage task pipeline:

    • coverage-base: generates base coverage using pull_request.base.sha
    • coverage-pr (reuses Debian11 unit test results): generates PR coverage
    • coverage-gate: performs gate comparison and outputs results
  • Gate rules:

    • changed files coverage > 60%
    • pr_overall - base_overall >= -0.1%
  • Standardizes coverage execution environment to Debian11 + JDK8 (x86_64), executed in parallel to avoid increasing wall-clock time significantly.

  • Disables automatic PR comments (update-comment: false) to reduce noise, while retaining logs and step summary outputs.

  • Removes the macos x86 runner (macos-26-intel) execution item to reduce the impact of occasional failures in this environment on CI stability.

  • Adds auto reviewer assignment workflow (pr-reviewer.yml) that assigns reviewers based on PR title scope (conventional commit format), replacing CODEOWNERS.

  • Disables Gradle build cache (--no-build-cache) selectively for coverage jobs to ensure accurate coverage data.

Why are these changes required?

  • Passing a static threshold does not guarantee that the current changes did not introduce regression.

  • Compared to maintaining historical baseline storage (artifact/JSON state), base-vs-PR comparison under the same conditions is lighter, more practical, and has lower maintenance cost.

  • Avoids using Gradle aggregation to prevent potential conflicts in multi-module class/exec merging; instead, uses Action-side XML aggregation for better stability.

  • Auto reviewer assignment ensures consistent, scope-based review coverage without relying on CODEOWNERS.

--no-build-cache Strategy

Problem: GitHub Actions actions/cache persists ~/.gradle/caches/ (including build-cache-1/) across workflow runs. When the Gradle build cache is restored, test tasks are marked as FROM-CACHE and skipped entirely — no tests execute, and no .exec files are generated. This was observed in run #23942322694 where debian11, rockylinux, and coverage-base completed in ~1 min instead of 20+ min.

Root cause: Gradle build cache keys are computed from task inputs (source code, JDK version, JVM args, dependencies). When inputs are identical across runs, cached test outputs (including .exec files) are reused. While the cached data is technically valid for identical inputs, it means tests are not actually executed and coverage data comes from a previous run.

Solution — selective --no-build-cache:

Job --no-build-cache Reason
macos26 Verification only — build cache speeds up CI, no coverage needed
ubuntu24 Verification only — same as above
rockylinux Verification only — same as above
debian11 Must generate fresh .exec files for PR coverage
coverage-base Must generate fresh .exec files for base coverage

Cache isolation: coverage-base uses an independent cache key prefix (coverage-base-x86_64-gradle-) to prevent cross-contamination with debian11's dependency cache.

Note: --no-build-cache only disables Gradle's task output cache. Dependency download cache (modules-2/) and Gradle wrapper cache remain active, so dependency resolution is still fast.

Testing

  • Unit Tests
  • Manual Testing
  • Coverage gate scenario validation (4 cases):
    • overall < 60%
    • overall > 60%
    • delta < -0.1%
    • delta >= -0.1%
  • Validation points:
    • changed files gate pass/fail
    • delta gate pass/fail
    • output includes Changed/PR/Base/Delta and is readable
  • Auto reviewer workflow validated on fork repository PR
  • Verified --no-build-cache fix: confirmed test tasks execute fully (not FROM-CACHE) and .exec files are freshly generated

Note: -0.1 means -0.1% (not -1%)

Auto Reviewer Behavior

Reviewer assignment follows a "first-assign-only" policy — the workflow only assigns reviewers when no reviewers are currently requested on the PR. Once reviewers are assigned (either automatically or manually), subsequent title edits or reopens will not trigger reassignment. This design preserves manually added reviewers and avoids unintended accumulation from title scope changes.

Follow Up

Future optimization: refine trigger conditions from paths-ignore to whitelist-based (paths / paths-filter) to reduce unnecessary runs.

Extra Details

@Sunny6889 Sunny6889 closed this Apr 2, 2026
@Sunny6889 Sunny6889 reopened this Apr 2, 2026
@Sunny6889 Sunny6889 requested a review from halibobo1205 as a code owner April 2, 2026 09:37
@bladehan1 bladehan1 closed this Apr 2, 2026
@bladehan1 bladehan1 reopened this Apr 2, 2026
@bladehan1 bladehan1 closed this Apr 2, 2026
@bladehan1 bladehan1 reopened this Apr 2, 2026
Add pr-reviewer.yml that automatically assigns reviewers based on the
PR title scope (conventional commit format). Remove CODEOWNERS as it
is now superseded by the workflow-based approach.
Signed-off-by: bladehan1 <bladehan@163.com>
@bladehan1 bladehan1 requested a review from 317787106 as a code owner April 3, 2026 04:19
@bladehan1 bladehan1 changed the title ci: add coverage check workflow feat(ci): add coverage check workflow and auto reviewer assignment Apr 3, 2026
Codecov integration is no longer active. Coverage is now handled by
JaCoCo + madrapps/jacoco-report in pr-build.yml.

- Remove stale codecov badge from README.md
- Add DEPRECATED header to codecov.yml for clarity
@kuny0707 kuny0707 merged commit 3ab5adf into tronprotocol:develop Apr 8, 2026
12 checks passed
@github-project-automation github-project-automation bot moved this to Done in java-tron Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants