Skip to content

Commit 51462c9

Browse files
Copilotwenshao
andauthored
Configure Codecov for PR coverage reporting (#3981)
* Initial plan * feat: add codecov configuration and enhance CI coverage reporting - Add .codecov.yml with PR comment and coverage status configuration - Configure coverage thresholds and targets - Enhance CI workflow to explicitly generate coverage reports - Add PR write permissions for coverage comments - Specify JaCoCo XML report locations for upload Co-authored-by: wenshao <1166785+wenshao@users.noreply.github.com> * refactor: simplify codecov upload to auto-discover all jacoco reports - Remove explicit file list to allow automatic discovery - This ensures all modules' coverage is included Co-authored-by: wenshao <1166785+wenshao@users.noreply.github.com> * fix: improve codecov configuration based on code review - Change if_no_uploads from error to informational for project coverage to avoid blocking PRs - Clarify comment for patch threshold to indicate it allows up to 5% below target Co-authored-by: wenshao <1166785+wenshao@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: wenshao <1166785+wenshao@users.noreply.github.com>
1 parent babcdad commit 51462c9

2 files changed

Lines changed: 63 additions & 1 deletion

File tree

‎.codecov.yml‎

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Codecov configuration for fastjson2
2+
# Documentation: https://docs.codecov.com/docs/codecov-yaml
3+
4+
# Configuration for pull request comments
5+
comment:
6+
layout: "header, diff, files, footer"
7+
behavior: default
8+
require_changes: false
9+
require_base: false
10+
require_head: true
11+
12+
# Coverage status checks configuration
13+
coverage:
14+
status:
15+
# Project-wide coverage status
16+
project:
17+
default:
18+
# Target coverage percentage
19+
target: auto
20+
# Threshold for coverage drop (allow 0.5% drop)
21+
threshold: 0.5%
22+
# Mark as informational if no uploads to avoid blocking PRs
23+
if_no_uploads: informational
24+
if_ci_failed: error
25+
26+
# Patch coverage for new changes
27+
patch:
28+
default:
29+
# Require 80% coverage for new code
30+
target: 80%
31+
# Allow up to 5% below target
32+
threshold: 5%
33+
if_no_uploads: success
34+
if_ci_failed: error
35+
36+
# Precision for coverage percentages
37+
precision: 2
38+
round: down
39+
range: "70...90"
40+
41+
# Ignore certain files/directories from coverage
42+
ignore:
43+
- "benchmark/**/*"
44+
- "benchmark_25/**/*"
45+
- "codegen-test/**/*"
46+
- "example-*/**/*"
47+
- "test-jdk*/**/*"
48+
- "**/src/test/**/*"
49+
- "**/*Test.java"
50+
- "**/*Tests.java"
51+
52+
# Ensure all CI jobs complete before processing
53+
github_checks:
54+
annotations: true

‎.github/workflows/ci.yaml‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ on:
1414

1515
permissions:
1616
contents: read
17+
pull-requests: write # Allow posting PR comments for coverage reports
1718

1819
env:
1920
JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 -Duser.timezone=Asia/Shanghai
@@ -84,6 +85,8 @@ jobs:
8485
steps:
8586
- name: Checkout code
8687
uses: actions/checkout@v4
88+
with:
89+
fetch-depth: 0 # Fetch all history for better coverage analysis
8790

8891
- name: Set up JDK 11
8992
uses: actions/setup-java@v4
@@ -92,11 +95,16 @@ jobs:
9295
java-version: 11
9396
cache: maven
9497

95-
- name: Build with Maven
98+
- name: Build with Maven and generate coverage
9699
run: ./mvnw -V --no-transfer-progress clean package
100+
env:
101+
CI: true # Explicitly set CI to ensure JaCoCo profile is activated
97102

98103
- name: Upload coverage to Codecov
99104
uses: codecov/codecov-action@v4
100105
with:
101106
name: codecov-umbrella
102107
token: ${{ secrets.CODECOV_TOKEN }}
108+
flags: unittests
109+
fail_ci_if_error: false
110+
verbose: true

0 commit comments

Comments
 (0)