Skip to content

Commit 9648370

Browse files
authored
Merge pull request #13 from 0xbigapple/feature/migrate_ci_2
ci: add code coverage check
2 parents 3fc3b53 + 8b9fbbf commit 9648370

5 files changed

Lines changed: 130 additions & 60 deletions

File tree

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Codecov Upload
2+
3+
on:
4+
workflow_run:
5+
workflows: ["RockyLinux Coverage Build"]
6+
types: [completed]
7+
branches: [ 'develop', 'release_**' ]
8+
9+
jobs:
10+
upload-coverage:
11+
name: Upload Coverage
12+
13+
if: >
14+
github.event.workflow_run.conclusion == 'success' &&
15+
github.event.workflow_run.event == 'pull_request'
16+
17+
runs-on: ubuntu-latest
18+
timeout-minutes: 10
19+
20+
steps:
21+
22+
- name: Extract PR info
23+
id: pr
24+
uses: actions/github-script@v7
25+
with:
26+
script: |
27+
const prs = context.payload.workflow_run.pull_requests;
28+
29+
if (!prs || prs.length === 0) {
30+
core.setFailed("No PR found");
31+
return;
32+
}
33+
34+
const pr = prs[0];
35+
core.setOutput("number", pr.number);
36+
core.setOutput("sha", pr.head.sha);
37+
core.setOutput("ref", pr.head.ref);
38+
core.setOutput("run", context.payload.workflow_run.id);
39+
40+
- name: Download artifact
41+
uses: actions/download-artifact@v4
42+
with:
43+
name: jacoco-rockylinux
44+
run-id: ${{ steps.pr.outputs.run }}
45+
path: coverage
46+
github-token: ${{ secrets.GITHUB_TOKEN }}
47+
48+
- name: Show files
49+
run: find coverage -type f
50+
51+
- name: Upload to Codecov
52+
uses: codecov/codecov-action@v5
53+
with:
54+
token: ${{ secrets.CODECOV_TOKEN }}
55+
files: coverage/**/jacocoTestReport.xml
56+
disable_search: true
57+
override_commit: ${{ steps.pr.outputs.sha }}
58+
override_branch: ${{ steps.pr.outputs.ref }}
59+
override_pr: ${{ steps.pr.outputs.number }}
60+
fail_ci_if_error: true

.github/workflows/pr-check.yml

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -178,66 +178,6 @@ jobs:
178178
- name: Build
179179
run: ./gradlew clean build --no-daemon
180180

181-
docker-build-rockylinux:
182-
name: Build rockylinux (JDK 8 / x86_64)
183-
if: github.event.action != 'edited' && !failure()
184-
needs: [pr-lint, checkstyle]
185-
runs-on: ubuntu-latest
186-
timeout-minutes: 60
187-
188-
container:
189-
image: rockylinux:8
190-
191-
env:
192-
GRADLE_USER_HOME: /github/home/.gradle
193-
LANG: en_US.UTF-8
194-
LC_ALL: en_US.UTF-8
195-
196-
steps:
197-
- name: Checkout code
198-
uses: actions/checkout@v4
199-
200-
- name: Install dependencies (Rocky 8 + JDK8)
201-
run: |
202-
set -euxo pipefail
203-
dnf -y install java-1.8.0-openjdk-devel git wget unzip which jq bc curl glibc-langpack-en
204-
dnf -y groupinstall "Development Tools"
205-
206-
- name: Check Java version
207-
run: java -version
208-
209-
- name: Cache Gradle
210-
uses: actions/cache@v4
211-
with:
212-
path: |
213-
/github/home/.gradle/caches
214-
/github/home/.gradle/wrapper
215-
key: ${{ runner.os }}-rockylinux-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
216-
restore-keys: |
217-
${{ runner.os }}-rockylinux-gradle-
218-
219-
- name: Grant execute permission
220-
run: chmod +x gradlew
221-
222-
- name: Stop Gradle daemon
223-
run: ./gradlew --stop || true
224-
225-
- name: Build
226-
run: ./gradlew clean build --no-daemon --no-build-cache
227-
228-
- name: Generate JaCoCo report
229-
run: ./gradlew jacocoTestReport --no-daemon --no-build-cache
230-
231-
- name: Upload JaCoCo artifacts
232-
uses: actions/upload-artifact@v4
233-
with:
234-
name: jacoco-rockylinux
235-
path: |
236-
**/build/reports/jacoco/test/jacocoTestReport.xml
237-
**/build/reports/**
238-
**/build/test-results/**
239-
if-no-files-found: error
240-
241181
docker-build-debian11:
242182
name: Build debian11 (JDK 8 / x86_64)
243183
if: github.event.action != 'edited' && !failure()
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: RockyLinux Coverage Build
2+
3+
on:
4+
pull_request:
5+
branches: [ 'develop', 'release_**' ]
6+
types: [ opened, synchronize, reopened ]
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
10+
cancel-in-progress: false
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
17+
docker-build-rockylinux:
18+
name: Build rockylinux (JDK8)
19+
20+
runs-on: ubuntu-latest
21+
timeout-minutes: 60
22+
23+
container:
24+
image: rockylinux:8
25+
26+
env:
27+
GRADLE_USER_HOME: /github/home/.gradle
28+
29+
steps:
30+
31+
- name: Checkout
32+
uses: actions/checkout@v4
33+
34+
- name: Install dependencies
35+
run: |
36+
dnf -y install java-1.8.0-openjdk-devel git wget unzip which jq bc curl
37+
38+
- name: Java version
39+
run: java -version
40+
41+
- name: Build
42+
run: |
43+
chmod +x gradlew
44+
./gradlew clean build --no-daemon --no-build-cache
45+
46+
- name: Generate coverage
47+
run: |
48+
./gradlew jacocoTestReport --no-daemon --no-build-cache
49+
50+
- name: Upload jacoco artifact
51+
uses: actions/upload-artifact@v4
52+
with:
53+
name: jacoco-rockylinux
54+
path: |
55+
**/build/reports/jacoco/test/jacocoTestReport.xml
56+
**/build/test-results/**
57+
**/build/reports/**
58+
if-no-files-found: error

codecov.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
comment: false
2+
3+
coverage:
4+
status:
5+
project:
6+
default:
7+
target: auto # must not decrease from base branch
8+
threshold: 0.1% # allow 0.1% fluctuation
9+
patch:
10+
default:
11+
target: 0% # minimum coverage for changed lines

framework/src/test/java/org/tron/common/TestConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ public class TestConstants {
44

55
public static final String TEST_CONF = "config-test.conf";
66
public static final String NET_CONF = "config.conf";
7+
78
}

0 commit comments

Comments
 (0)