Skip to content

ci: add coverage check workflow#6582

Open
0xbigapple wants to merge 2 commits intotronprotocol:developfrom
0xbigapple:feature/migrate_ci_8
Open

ci: add coverage check workflow#6582
0xbigapple wants to merge 2 commits intotronprotocol:developfrom
0xbigapple:feature/migrate_ci_8

Conversation

@0xbigapple
Copy link
Contributor

Summary

This PR improves the CI pipeline by adding a complete coverage reporting workflow and reorganizing PR checks.

Changes

  • Add PR coverage workflow to generate and upload JaCoCo reports to Codecov
  • Add base coverage upload workflow for develop and release_* branches
  • Add a workflow to wait for Codecov project status to produce a stable PR check result
  • Move multi-platform build checks into a separate workflow
  • Add codecov.yml configuration for project coverage checks
  • Upgrade some action version to use NodeJs 24

Coverage Check Sequence Diagram(s)

sequenceDiagram
    participant GH as GitHub (PR Event)
    participant CGB as Coverage Build<br/>(PR Gen Artifact)
    participant AS as Artifact Storage
    participant CUP as Codecov Upload<br/>(PR Upload)
    participant CV as Codecov API
    participant CPW as Coverage Project<br/>(Waiting)

    GH->>CGB: Trigger on PR to develop/<br/>release_*
    CGB->>CGB: Checkout, setup JDK 8,<br/>build project
    CGB->>CGB: Generate JaCoCo<br/>reports
    CGB->>AS: Upload jacoco-coverage<br/>artifact
    CGB-->>CUP: Workflow complete signal
    
    CUP->>AS: Download jacoco-coverage<br/>artifact
    CUP->>GH: Fetch PR details<br/>(PR number, SHA, branch)
    CUP->>CV: Upload coverage data<br/>with PR context
    CV-->>CUP: Coverage upload<br/>acknowledged

    CPW->>CV: Poll codecov/project<br/>status (every 30s)
    CV-->>CPW: Return status<br/>(pending/success/failure)
    CPW->>CPW: Check legacy commit<br/>statuses & check-runs
    
    alt Status Success
        CPW-->>GH: Job succeeds
    else Status Failure
        CPW-->>GH: Job fails
    else Still Pending
        CPW->>CPW: Wait 30s,<br/>retry (max 120x)
    end
Loading

Notes

The coverage comparison report only take effect starting from the next PR.

if-no-files-found: error

upload-base-coverage:
name: Upload Base Coverage to Codecov
Copy link
Contributor

@bladehan1 bladehan1 Mar 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Base coverage should be queried first, and regenerated only if coverage for a corresponding commit is not found. This improves efficiency.

Copy link

@liuyifei001 liuyifei001 Mar 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let’s clarify the roles of the two secrets that only access in tronprotocol environment:

  • secrets.CODECOV_TOKEN: used to upload coverage artifacts
  • secrets.CODECOV_API_TOKEN: used to query coverage reports

Due to GitHub’s permission restrictions, secrets.CODECOV_API_TOKEN is not available in forked pull requests, which prevents querying the base repository’s coverage first.

In addition, the maintainers of java-tron have not configured secrets.CODECOV_API_TOKEN; only the upload token (secrets.CODECOV_TOKEN) is set.

@@ -0,0 +1,58 @@
name: Coverage Build
Copy link
Contributor

@bladehan1 bladehan1 Mar 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is recommended to merge the PR code coverage workflow files.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codecov Upload & Compare runs in tron-protocol environment triggered by another workflow, but Coverage Build can only runs in user' environment.

timeout-minutes: 70

steps:
- name: Wait for codecov/project status
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After uploading the coverage event, check whether it was successful.

Copy link

@liuyifei001 liuyifei001 Mar 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Workflow Codecov Upload & Compare replies on Coverage Build. If we merge Coverage Build and Waiting Coverage project, Codecov Upload & Compare can never be triggered.

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.

4 participants