Skip to content

Commit ffc82eb

Browse files
committed
init coverage check workflow
1 parent 7e5bbbd commit ffc82eb

10 files changed

Lines changed: 553 additions & 166 deletions

.github/workflows/codeql.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929

3030
steps:
3131
- name: Checkout repository
32-
uses: actions/checkout@v4
32+
uses: actions/checkout@v5
3333

3434
# Initializes the CodeQL tools for scanning.
3535
- name: Initialize CodeQL
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Base Coverage Upload
2+
3+
on:
4+
push:
5+
branches: [ 'develop', 'release_**' ]
6+
7+
permissions:
8+
contents: read
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
build-base-coverage:
16+
name: Build Base Coverage
17+
runs-on: ubuntu-latest
18+
timeout-minutes: 60
19+
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v5
23+
with:
24+
fetch-depth: 0
25+
26+
- name: Set up JDK 8
27+
uses: actions/setup-java@v5
28+
with:
29+
java-version: '8'
30+
distribution: 'temurin'
31+
cache: 'gradle'
32+
33+
- name: Check Java version
34+
run: java -version
35+
36+
- name: Grant execute permission
37+
run: chmod +x gradlew
38+
39+
- name: Stop Gradle daemon
40+
run: ./gradlew --stop || true
41+
42+
- name: Build
43+
run: ./gradlew clean build --no-daemon --no-build-cache --parallel
44+
45+
- name: Generate JaCoCo report
46+
run: ./gradlew jacocoTestReport --no-daemon --no-build-cache
47+
48+
- name: Upload coverage artifacts
49+
uses: actions/upload-artifact@v5
50+
with:
51+
name: base-jacoco-xml
52+
path: |
53+
actuator/build/reports/jacoco/test/jacocoTestReport.xml
54+
chainbase/build/reports/jacoco/test/jacocoTestReport.xml
55+
common/build/reports/jacoco/test/jacocoTestReport.xml
56+
consensus/build/reports/jacoco/test/jacocoTestReport.xml
57+
crypto/build/reports/jacoco/test/jacocoTestReport.xml
58+
framework/build/reports/jacoco/test/jacocoTestReport.xml
59+
plugins/build/reports/jacoco/test/jacocoTestReport.xml
60+
if-no-files-found: error
61+
62+
upload-base-coverage:
63+
name: Upload Base Coverage to Codecov
64+
needs: build-base-coverage
65+
runs-on: ubuntu-latest
66+
timeout-minutes: 20
67+
68+
steps:
69+
- name: Checkout repo
70+
uses: actions/checkout@v5
71+
with:
72+
fetch-depth: 0
73+
74+
- name: Download coverage artifacts
75+
uses: actions/download-artifact@v5
76+
with:
77+
name: base-jacoco-xml
78+
path: coverage-artifacts
79+
80+
- name: Show coverage files
81+
run: find coverage-artifacts -type f | sort
82+
83+
- name: Upload base coverage to Codecov
84+
uses: codecov/codecov-action@v5
85+
with:
86+
token: ${{ secrets.CODECOV_TOKEN }}
87+
directory: ./coverage-artifacts
88+
root_dir: ./
89+
gcov_executable: ''
90+
override_branch: ${{ github.ref_name }}
91+
fail_ci_if_error: true
92+
verbose: true
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: 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: true
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
build-coverage:
17+
name: Build ubuntu24 (JDK 8 / x86_64)
18+
runs-on: ubuntu-24.04
19+
timeout-minutes: 60
20+
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v5
24+
with:
25+
fetch-depth: 0
26+
27+
- name: Set up JDK 8
28+
uses: actions/setup-java@v5
29+
with:
30+
java-version: '8'
31+
distribution: 'temurin'
32+
cache: 'gradle'
33+
34+
- name: Check Java version
35+
run: java -version
36+
37+
- name: Stop Gradle daemon
38+
run: ./gradlew --stop || true
39+
40+
- name: Build
41+
run: ./gradlew clean build --no-daemon --no-build-cache --parallel
42+
43+
- name: Generate JaCoCo report
44+
run: ./gradlew jacocoTestReport --no-daemon --no-build-cache
45+
46+
- name: Upload JaCoCo artifact
47+
uses: actions/upload-artifact@v5
48+
with:
49+
name: jacoco-coverage
50+
path: |
51+
actuator/build/reports/jacoco/test/jacocoTestReport.xml
52+
chainbase/build/reports/jacoco/test/jacocoTestReport.xml
53+
common/build/reports/jacoco/test/jacocoTestReport.xml
54+
consensus/build/reports/jacoco/test/jacocoTestReport.xml
55+
crypto/build/reports/jacoco/test/jacocoTestReport.xml
56+
framework/build/reports/jacoco/test/jacocoTestReport.xml
57+
plugins/build/reports/jacoco/test/jacocoTestReport.xml
58+
if-no-files-found: error
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Codecov Upload & Compare
2+
3+
on:
4+
workflow_run:
5+
workflows:
6+
- Coverage Build
7+
types:
8+
- completed
9+
10+
permissions:
11+
contents: read
12+
actions: read
13+
pull-requests: read
14+
15+
jobs:
16+
upload-coverage:
17+
name: Upload Coverage
18+
if: >
19+
github.event.workflow_run.conclusion == 'success' &&
20+
github.event.workflow_run.event == 'pull_request'
21+
runs-on: ubuntu-latest
22+
outputs:
23+
pr_number: ${{ steps.pr.outputs.pr_number }}
24+
25+
steps:
26+
- name: Checkout repo
27+
uses: actions/checkout@v5 # must download source code
28+
with:
29+
fetch-depth: 0
30+
persist-credentials: false
31+
32+
- name: Download coverage artifact
33+
uses: actions/download-artifact@v5
34+
with:
35+
name: jacoco-coverage
36+
path: coverage
37+
run-id: ${{ github.event.workflow_run.id }}
38+
github-token: ${{ secrets.GITHUB_TOKEN }}
39+
40+
- name: Get PR details
41+
id: pr
42+
uses: actions/github-script@v8
43+
with:
44+
script: |
45+
const headSha = context.payload.workflow_run.head_sha;
46+
const headOwner = context.payload.workflow_run.head_repository.owner.login;
47+
const headBranch = context.payload.workflow_run.head_branch;
48+
const { data: pulls } = await github.rest.pulls.list({
49+
owner: context.repo.owner,
50+
repo: context.repo.repo,
51+
state: 'open',
52+
head: `${headOwner}:${headBranch}`
53+
});
54+
if (pulls.length > 0) {
55+
const pr = pulls[0];
56+
core.setOutput('pr_number', pr.number);
57+
core.setOutput('pr_sha', headSha);
58+
core.setOutput('pr_branch', headBranch);
59+
core.setOutput('base_sha', pr.base.sha);
60+
} else {
61+
core.setFailed(`No open pull request found for ${headOwner}:${headBranch}`);
62+
}
63+
64+
- name: Upload to Codecov
65+
if: ${{ steps.pr.outputs.pr_number != '' }}
66+
uses: codecov/codecov-action@v5
67+
with:
68+
token: ${{ secrets.CODECOV_TOKEN }}
69+
override_commit: ${{ steps.pr.outputs.pr_sha }}
70+
override_branch: ${{ steps.pr.outputs.pr_branch }}
71+
override_pr: ${{ steps.pr.outputs.pr_number }}
72+
fail_ci_if_error: true
73+
verbose: true
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
name: Waiting Coverage project
2+
3+
on:
4+
pull_request:
5+
branches: [ 'develop', 'release_**' ]
6+
types: [ opened, synchronize, reopened ]
7+
8+
permissions:
9+
contents: read
10+
checks: read
11+
statuses: read
12+
pull-requests: read
13+
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
16+
cancel-in-progress: true
17+
18+
jobs:
19+
waiting-coverage-project:
20+
name: waiting-coverage-report
21+
runs-on: ubuntu-latest
22+
timeout-minutes: 70
23+
24+
steps:
25+
- name: Wait for codecov/project status
26+
uses: actions/github-script@v8
27+
with:
28+
script: |
29+
const owner = context.repo.owner;
30+
const repo = context.repo.repo;
31+
const ref = context.payload.pull_request.head.sha;
32+
33+
const targetContext = 'codecov/project';
34+
const maxAttempts = 120; // 120 * 30s = 60 minutes
35+
const intervalMs = 30 * 1000;
36+
37+
function sleep(ms) {
38+
return new Promise(resolve => setTimeout(resolve, ms));
39+
}
40+
41+
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
42+
core.info(`Polling attempt ${attempt}/${maxAttempts} for ${targetContext} on ${ref}`);
43+
44+
try {
45+
// Check legacy commit statuses
46+
const combined = await github.rest.repos.getCombinedStatusForRef({
47+
owner,
48+
repo,
49+
ref,
50+
per_page: 100
51+
});
52+
53+
const statuses = combined.data.statuses || [];
54+
const matchedStatus = statuses.find(s => s.context === targetContext);
55+
56+
if (matchedStatus) {
57+
core.info(`Found commit status: ${matchedStatus.context} = ${matchedStatus.state}`);
58+
59+
if (matchedStatus.state === 'success') {
60+
core.info(`${targetContext} succeeded.`);
61+
return;
62+
}
63+
64+
if (matchedStatus.state === 'failure' || matchedStatus.state === 'error') {
65+
core.setFailed(`${targetContext} is ${matchedStatus.state}.`);
66+
return;
67+
}
68+
69+
// pending
70+
await sleep(intervalMs);
71+
continue;
72+
}
73+
74+
// Check check-runs as a fallback
75+
const checks = await github.rest.checks.listForRef({
76+
owner,
77+
repo,
78+
ref
79+
});
80+
81+
const checkRuns = checks.data.check_runs || [];
82+
const matchedCheck = checkRuns.find(c => c.name === targetContext);
83+
84+
if (matchedCheck) {
85+
core.info(
86+
`Found check run: ${matchedCheck.name}, status=${matchedCheck.status}, conclusion=${matchedCheck.conclusion}`
87+
);
88+
89+
if (matchedCheck.status === 'completed') {
90+
if (matchedCheck.conclusion === 'success') {
91+
core.info(`${targetContext} succeeded.`);
92+
return;
93+
}
94+
95+
core.setFailed(
96+
`${targetContext} completed with conclusion=${matchedCheck.conclusion}.`
97+
);
98+
return;
99+
}
100+
101+
// queued / in_progress
102+
await sleep(intervalMs);
103+
continue;
104+
}
105+
106+
core.info(`${targetContext} not reported yet. Waiting...`);
107+
} catch (error) {
108+
core.warning(
109+
`Attempt ${attempt}/${maxAttempts} failed with transient error: ${error.message}. Retrying in ${intervalMs / 1000}s...`
110+
);
111+
}
112+
113+
await sleep(intervalMs);
114+
}
115+
116+
core.setFailed(
117+
`Timed out waiting for ${targetContext} to report success on commit ${ref}.`
118+
);

.github/workflows/math-check.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ubuntu-latest
1313

1414
steps:
15-
- uses: actions/checkout@v4
15+
- uses: actions/checkout@v5
1616

1717
- name: Check for java.lang.Math usage
1818
id: check-math
@@ -55,14 +55,14 @@ jobs:
5555
5656
- name: Upload findings
5757
if: steps.check-math.outputs.math_found == 'true'
58-
uses: actions/upload-artifact@v4
58+
uses: actions/upload-artifact@v5
5959
with:
6060
name: math-usage-report
6161
path: math_usage.txt
6262

6363
- name: Create comment
6464
if: github.event_name == 'pull_request' && steps.check-math.outputs.math_found == 'true'
65-
uses: actions/github-script@v6
65+
uses: actions/github-script@v8
6666
with:
6767
script: |
6868
const fs = require('fs');

0 commit comments

Comments
 (0)